Preparing to Create the Feed Reader Application

Before beginning to code the FeedReader application, it's a good idea to familiarize yourself with some of the frequently used terms in the area of application development in NetBeans IDE. In the process, you will build a general understanding of the application that you will create, find out about what you are about to learn, and set up everything that you are going to need.

Table of Contents

About Frequently Used Terms

This tutorial assumes that you have a basic conceptual understanding of the infrastructure that is built right into NetBeans. There is less to understand than you might think. Common terms to be familiar with are as follows:

About the Feed Reader Application

While writing the Feed Reader Application, you will leverage a lot of the NetBeans infrastructure. The first piece you leverage is the System Filesystem. As pointed out earlier, the System Filesystem consists of configuration data: it is built from the configuration files (each of which is stored on disk as layer.xml files) of all the plug-in modules in the system, which it writes into the user's settings directory.

The System Filesystem uses the same infrastructure for recognizing files that is used for recognizing a user's files on disk. That means you can show a view of a folder inside the configuration data of the IDE just as easily as you can show a folder on disk. This way you can use all of the plumbing that is built into NetBeans for viewing files and showing trees and so forth. In fact, many views you see in the IDE use the same technique. For example, the Favorites window is a view of a folder in the System Filesystem, which contains links to files on disk. The contents of the Runtime window are also a view of a folder in the System Filesystem, which is why plug-in modules are able to add nodes to it. Since it uses the same mechanisms as are used for recognizing files on disk, the objects inside a folder can have whatever icons and display names you choose to give them.

The other piece you use is the Nodes API . The Nodes API is a generalization of TreeNode, though Nodes can be displayed in a variety of viewer components, not just trees. Nodes typically represent DataObjects. A DataObject is basically a parsed file, in other words, a Java object that knows the meaning of what is in a file or what the file represents and can do something with it. Nodes add features to DataObjects that the user interacts with, such as actions, localized display names, and icons.

So, after using wizards to generate some basic templates, you will use the layer.xml file to create a folder in the System Filesystem for RSS feed objects ( Creating the RssFeeds Folder ). Next, you will provide a view of the folder, similar to the IDE's Projects window or Files window, by building on top of one of the generated files ( Extending the Feed Window ). The view is rooted in your folder for RSS feed objects. Then you get the DataObject representing that folder, and its Node. You will wrap that node in a FilterNode ( Creating the RssFeeds Folder ). A FilterNode is a node that can act as a wrapper for another node; by default it behaves exactly as the other node does, but you can override methods on it to change things, so that you can give it your own icon, display name and actions. Then you wrap each of the node's children as well, doing the same thing for them as for the node.

Next, you will create an Add Feed action on the root node. When the user adds an RSS feed, you do something very simple: you create a new Feed object (really just an object that contains the URL, Creating the Feed Object ) and then serialize that Feed object as a file in your RSSFeeds folder. Since you're using NetBeans built-in infrastructure for visualizing files (because you're just getting the standard node for the folder, which can notice when files are added or removed), in a split second the node for the newly added feed will appear in the user interface. Using the System Filesystem this way means that the amount of code you have to write to save the list of RSS feeds on exit is... none at all! You save a feed when the user creates it, and that data is persisted to disk automatically. So, basically, you are just dropping Feed POJOs into a folder, and you happen to be showing a view of that folder. The system takes care of virtually everything else.

About this Tutorial

This tutorial intends to teach you the following:

Playing with the Application

Before you start writing the application, you might want to acquaint yourself with the final product. Fortunately, the Feed Reader Application is an official NetBeans sample, bundled with the IDE, and waiting for you to pull it from the New Project wizard.

Installing the Application

Take the following steps to install the sample:

  1. Start the IDE.
  2. Choose File > New Project (Ctrl-Shift-N), then expand Samples, then select NetBeans Plug-in Modules, and choose FeedReader. Click Next.
  3. Name the project whatever you like, choose a location to store your project, and click Finish. The IDE opens the FeedReader sample.
  4. Right-click the Feed Reader Application project node and choose Run Project. The application starts up. During installation, notice that a splash screen is displayed.

Introducing the Application

The Feed Reader Application displays the RSS/Atom Feeds window, containing a node called RSS/Atom Feeds.

  1. Right-click RSS/Atom Feeds node, choose Add, and enter a URL to an RSS/Atom feed. For example:
  2. Click OK. A node is added for the feed; its children are the feed entries. Normally, feed entries are articles or topics that the feed makes available.
  3. Repeat the process and add more feeds.
  4. Double-click a feed entry to open it in the IDE's default browser.
Other functionality provided by the rich-client application:

Introducing the Sources

The FeedReader sample consists of main files (Java classes) and supporting files.

Main files:

Supporting files: