Table of Contents
One way to organize a plugin project is to design the software as if it were a "stand alone" application, with three exceptions:
The plugin can access the View object with which it is associated, as well as static methods of the jEdit class, to obtain and manipulate various data and host application objects;
If the plugin has visible components, they are ultimately contained in a JPanel object instead of a top-level frame window; and
The plugin implements the necessary elements of the jEdit plugin API that were outlined in the last chapter: a plugin core class, perhaps a number of plugin window classes, maybe a plugin option pane class, and a set of required plugin resources.
Not every plugin has configurable options; some do not have a visible window. However, all will need a plugin core class and a minimum set of other resources.
We will now illustrate this approach by introducing an example plugin.
There are many applications for the leading operating systems that provide a "scratch-pad" or "sticky note" facility for the desktop display. A similar type of facility operating within the jEdit display would be a convenience. The use of docking windows would allow the notepad to be displayed or hidden with a single mouse click or keypress (if a keyboard shortcut were defined). The contents of the notepad could be saved at program exit (or, if earlier, deactivation of the plugin) and retrieved at program startup or plugin activation.
We will keep the capabilities of this plugin modest, but a few other features would be worthwhile. The user should be able to write the contents of the notepad to storage on demand. It should also be possible to choose the name and location of the file that will be used to hold the notepad text. This would allow the user to load other files into the notepad display. The path of the notepad file should be displayed in the plugin window, but will give the user the option to hide the file name. Finally, there should be an action by which a single click or keypress would cause the contents of the notepad to be written to the new text buffer for further processing.
The full source code for QuickNotepad is contained in jEdit's source code distribution. We will provide excerpts in this discussion where it is helpful to illustrate specific points. You are invited to obtain the source code for further study or to use as a starting point for your own plugin.