EditPlugin Class Changes
Prev | Chapter 2. API Changes | Next

## EditPlugin Class Changes

Documentation for the properties mentioned below, and their possible values, can be found in the documentation for the EditPlugin class.

jEdit distinguishes between jEdit 4.1 and 4.2-style plugins by checking for the presence of a single property, `plugin.`class name`.activate`. If this property is present, the plugin is loaded using the new API.

Since the plugin's menu might need to be displayed before its core class is fully loaded, there is a new way of specifying the plugin menu using properties; the `createMenuItems()` method of the EditPlugin class has been deprecated.

For example, the jEdit 4.1 version of the QuickNotepad plugin had the following `createMenuItems()` method:

    public void createMenuItems(Vector menuItems)
    {
        menuItems.addElement(GUIUtilities.loadMenu("quicknotepad.menu"));
    }

Additionally, the following two properties were defined in `QuickNotepad.props`:

    quicknotepad.menu.label=QuickNotepad
    quicknotepad.menu=quicknotepad - quicknotepad.choose-file \
        quicknotepad.save-file quicknotepad.copy-to-buffer

The jEdit 4.2 version of this plugin no longer has a `createMenuItems()` method, and instead defines the following property:

    plugin.QuickNotepadPlugin.menu=quicknotepad \
        - \
        quicknotepad.choose-file \
        quicknotepad.save-file \
        quicknotepad.copy-to-buffer

Note that specifying a `.label` property for the menu is no longer necessary, as the label becomes the name of the plugin.

If the content of your plugin's menu is determined at runtime, you must use the new dynamic menu API by defining a property like so:

    plugin.MyPlugin.menu.code=new MyPluginMenuProvider();

The value of the property is a BeanShell snippet that should evaluate to a DynamicMenuProvider instance.

Similarly, option panes should are now specified using properties, and the `createOptionPanes()` method of the EditPlugin class has been deprecated.

In QuickNotepad's case, the `createOptionPanes()` method has been removed:

    public void createOptionPanes(OptionsDialog od)
        {
            od.addOptionPane(new QuickNotepadOptionPane());
        }

The new properties look like this:

    plugin.QuickNotepadPlugin.option-pane=quicknotepad
    options.quicknotepad.code=new QuickNotepadOptionPane();

Prev | Up | Next
Dynamic Plugin Loading | Home | Actions