Implementing plugins

On the <oXygen/> website there is a plugin development kit with some sample plugins (source code and compiled code) and the Javadoc API necessary for developing custom plugins. On the Plugins page there is a developer manual with instructions for developing custom plugins.

The minimal implementation of a plugin must provide two classes: one that extends the Plugin class and another that implements the plugin extension and a plugin descriptor file. There are five available extensions SelectionPluginExtension, DocumentPluginExtension, GeneralPluginExtension, URLStreamHandlerPluginExtension and StartupPluginExtension.

A PluginDescriptor object is passed to the plugin class on constructor containing information about the plugin

The PluginDescriptor fields are filled with information from the plugin descriptor file.

The plugin descriptor defines how the plugin will be integrated in <oXygen/> and what libraries should be loaded. The structure of the plugin descriptor file is fully described in a DTD grammar located in OXYGEN_INSTALLATION_FOLDER/plugins/plugin.dtd.

Here is a sample plugin descriptor used by the Capitalize Lines sample plugin:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plugin SYSTEM "../plugin.dtd">
<plugin
    name="Capitalize Lines"
    description="Capitalize the first character on each line"
    version="1.0.0"
    vendor="SyncRO"
    class="ro.sync.sample.plugin.caplines.CapLinesPlugin">
    <runtime>
        <library name="lib/caplines.jar"/>
    </runtime>
    <extension type="selectionProcessor" 
    class="ro.sync.sample.plugin.caplines.CapLinesPluginExtension" keyboardShortcut="ctrl shift EQUALS"/>
</plugin>

If your plugin is of type selectionProcessor, documentProcessor or generalExtension and thus contributes an action either to the contextual menu or to the main menu then you can assign a keyboard shortcut for it. You can use the keyboardShortcut attribute for each extension to specify the desired shortcut.

[Tip]Tip

To compose string representations of the desired shortcut keys you can go to the <oXygen/> Menu Shortcut Keys preferences page, press Edit on any action, press the desired key sequence and use the representation which appears in the edit dialog.

 General plugins

GeneralPluginExtension - this interface is intended for general purpose plugins - kind of external tools but triggered from the Plugins main menu. The implementing classes must contain the method process(GeneralPluginContext) which should provide the plugin processing. This method takes as a parameter an GeneralPluginContext object.

GeneralPluginContext - represents the context in which the general plugin extension does its processing. The only method available is getFrame() which returns the currently editing frame (java.awt.Frame). It is useful if the plugin wants to display graphical components as they in general need a parent in order to appear properly on screen.