The jEdit Plugin API provides a framework for hosting plugin applications without imposing any requirements on the design or function of the plugin itself. You could write a application that performs spell checking, displays a clock or plays chess and turn it into a jEdit plugin. There are currently over 50 released plugins for jEdit. While none of them play chess, they perform a wide variety of editing and file management tasks. A detailed listing of available plugins is available at the jEdit Plugin Central web site. You can also find beta versions of new plugins in the "Downloads" area of the jEdit Community site.
Using the "Plugin Manager" feature of jEdit, users with an Internet connection can check for new or updated plugins and install and remove them without leaving jEdit. See Chapter 8 for details.
In order to "plug in" to jEdit, a plugin must implement interfaces or data that deal with the following matters:
This plugin must supply information about itself, such as its name, version, author, and compatibility with versions of jEdit.
The plugin must provide for activating, displaying and deactivating itself upon direction from jEdit, typically in response to user input.
The plugin may, but need not, provide a user interface.
If the plugin has a visible interface, it can be shown in any object derived from one of Java top-level container classes: JWindow, JDialog, or JFrame. jEdit also provides a dockable window API, which allows plugin windows derived from the JComponentto be docked into views or shown in top-level frames, at the user's request.
Plugins can also act directly upon jEdit's text area. They can add graphical elements to the text display (like error highlighting in the case of the ErrorList plugin) or decorations surrounding the text area (like the JDiff plugin's summary views).
Plugins may (and typically do) define actions that jEdit will perform on behalf of the plugin upon user request. Actions are small blocks of BeanShell code that provide the "glue" between user input and specific plugin routines.
By convention, plugins display their available actions in submenus of jEdit's Plugins menu; each menu item corresponds to an action. The user can also assign actions to keyboard shortcuts, toolbar buttons or entries in the text area's right-click menu.
Plugins may provide a range of options that the user can modify to alter its configuration.
If a plugin provides configuration options in accordance with the plugin API, jEdit will make them available in the Global Options dialog. Each plugin with options is listed in the tree view in that dialog under Plugin Options. Clicking on the tree node for a plugin causes the corresponding set of options to be displayed.
As noted, many of these features are optional; it is possible to write a plugin that does not provide actions, configuration options, or dockable windows. The majority of plugins, however, provide most of these services.
In the following chapters, we will begin by briefly describing jEdit's host capabilities, which includes the loading and display of plugins. Next we will describe the principal classes and data structures that a plugin must implement. Finally, we will outline the building of a modest plugin, "QuickNotepad", that illustrates the requirements and some of the techniques of jEdit plugin design.