| Sign In/My Account | View Cart |
A while ago, I had a tiny portable electronic address book. I took it for granted until the day it stopped working. The salesperson who sold it to me couldn't retrieve my contacts, but offered to replace it. That day I learned that data is important. This shiny gizmo was worth nothing compared to the bits stored on it.
In part one of this series, we introduced Eclipse's plugin development environment and developed a simple plugin. In part two, we added a toolbar button, a menu item, and dialogs. The result was a shiny gizmo that didn't do much for us. It simply displayed sample text using a font. Now we need to make it manage actual data. We will massage the plugin so that it does what we need it to do. This article discusses editor documents and shows how to customize a wizard.
But first, let's elaborate on Invokatron itself. As discussed in the previous articles, Invokatron is an graphical tool that generates Java code. You can code up a class' methods simply by dragging and dropping. The dragged-in method is "invoked" by the edited method; thus, the name of the plugin. We will let the data drive the design of our application. In a later article, we're going to develop this GUI. For now, all we need to do is to figure out the important data our plugin will input and store. This is often referred to as the model of the application. Here are the things we'll need to worry about when designing our system:
|
Related Reading
|
These decisions have to be resolved before we go on. There is no right answer that is good for all projects; it all depends on your needs. In our case, I made arbitrary, questionable decisions as follows:
Properties class. This constitutes the "document
class" of our editor.Properties class.The next step is to write the document class. Create a new
package named invokatron.model, and a new class named
InvokatronDocument. Here's the first shot at our
document class:
public class InvokatronDocument
extends Properties
{
public static final String PACKAGE = "package";
public static final String SUPERCLASS = "superclass";
public static final String INTERFACES = "interfaces";
}
Using the Properties class allows for simple
parsing and saving of our data. The getter and setter methods are
not necessary, but you could add them if you want to. This class is
not finished; we will add the interfaces that Eclipse requires
later on.
With this class, getting a property is as simple as:
String package =
document.getProperty(InvokatronDocument.PACKAGE);
Have a look at our wizard as it was in the previous article (get the source code if you don't have it already). Remember, you can access it by clicking on the toolbar button or menu item we added. Here it is in figure 1:

Figure 1. Old wizard
It has only one page, with no graphic in the upper-right corner. We'd like to enter more information and have a nice graphic. In other words, we'd like to customize this wizard.
Let's dissect our wizard. Open the file
InvokatronWizard.java. Notice how this class extends
Wizard and implements INewWizard. These
have many methods you should know about. To customize the wizard, we
simply invoke or override some of these methods. Here are a few
important ones: