Plugin Option Pane Classes

The plugin API provides a mechanism for displaying a plugin's configuration options in the Global Options dialog. A plugin that allows user configuration should provide one or more implementations of jEdit's OptionPane interface to have configuration options displayed in a manner consistent with the rest of the application.

Class AbstractOptionPane

Most plugin option panes extend this implementation of OptionPane, instead of implementing OptionPane directly. It provides a convenient default framework for laying out configuration options in a manner similar to the option panes created by jEdit itself. It is derived from Java's JPanel class and contains a GridBagLayout object for component management. It also contains shortcut methods to simplify layout.

The constructor for a class derived from AbstractOptionPane should call the parent constructor and pass the option pane's "internal name" as a parameter. The internal name is used to key a property where the option pane's label is stored; see the section called "Plugin Properties". It should also implement two methods:

  • protected void _init();

    This method should create and arrange the components of the option pane and initialize the option data displayed to the user. This method is called when the option pane is first displayed, and is not called again for the lifetime of the object.

  • protected void _save();

    This method should save any settings, to the jEdit properties or other data store.

AbstractOptionPane also contains three shortcut methods, typically called from _init(), for adding components to the option pane:

  • protected void addComponent(String label, Component comp);

  • protected void addComponent(Component comp);

    These shortcut methods add components to the option pane in a single vertical column, running top to bottom. The first displays the text of the label parameter to the left of the Component represented by comp.

  • protected void addSeparator(String label);

    This is another shortcut method that adds a text label between two horizontal separators to the option pane. The label parameter represents the name of a property (typically a property defined in the plugin's property file) whose value will be used as the separator text.

Class OptionGroup

In those cases where a single option pane is inadequate to present all of a plugin's configuration options, this class can be used to create a group of options panes. The group will appear as a single node in the options dialog tree-based index. The member option panes will appear as leaf nodes under the group's node. Three simple methods create and populate an option pane:

  • public OptionGroup(String name);

    The constructor's single parameter represents the internal name of the option group. The internal name is used to key a property where the option group's label is stored; see the section called "Plugin Properties".

  • public void addOptionPane(OptionPane pane);

  • public void addOptionGroup(OptionGroup group);

    This pair of methods adds members to the option group. The second method enables option groups to be nested, for plugins with a particularly large set of configurable options.