To display a user interface, plugins provide a top-level component derived (directly or indirectly) from the Swing JComponent class. This component will be embedded in a docking of floating window created by the Plugin API. It is typically defined in a class that is part of the plugin package but separate from the plugin core class (if one exists).
A View is jEdit's top-level frame window. The largest component it contains is an edit pane that in turn contains a text area that displays a buffer. A view can have more than one edit pane in a split window configuration. The view also contains a menu bar, an optional toolbar and other window decorations, as well as docked windows.
The View class performs two important operations dealing with plugins: creating plugin menu items, and managing dockable windows.
When a view is being created, its initialization routine iterates through the collection of loaded plugins and calls the createMenuItems() method of each plugin core class. In the parent class, EditPlugin, this method is an empty "no-op". In order to add items to jEdit's menu bar under the Plugins menu, the plugin core class must supply its own version of createMenuItems(). As we will explain in the section called "The EditPlugin Class", the typical plugin, instead of creating Java JMenu and JMenuItem objects directly, relies on a wrapper method in a utility class to create menu entries.
The View also creates and initializes a DockableWindowManager object. This object is responsible for creating, closing and managing dockable windows. It will be discussed in more detail below.
Finally, the View and DockableWindowManager classes contain a number of methods that can be called from plugins; see the section called "Class View" and the section called "Class DockableWindowManager" for details.
The DockableWindowManager in each View object keeps track of docked and floating windows. When the View object initializes its DockableWindowManager, the manager iterates through the list of registered dockable windows and examines options supplied by the user in the Global Options dialog box. It displays any plugins that the user designated for one of the four docking positions when the corresponding button a docking pane is selected.
To create an instance of a dockable window, the DockableWindowManager finds and executes the BeanShell code extracted from the plugin's dockables.xml file during application startup. This code will typically consist of a call to the constructor of the docking window component that passes two parameters: the View associated with the docking window component, and a String representing the component's docking or floating position. The result of the BeanShell expression, typically a newly constructed component, is placed inside the docking or floating window managed by the DockableWindowManager.
Eventually the DockableWindowManager destroys the plugin window, whether docking or floating, in response to user action or as part of the destruction of the corresponding View object.
With this broad outline of how jEdit behaves as a plugin host in the background, we will next review the programming elements that make up a plugin.