Action Sets

Your plug-in can contribute menus, menu items, and tool bar items to the workbench menus and toolbar by using the org.jlense.uiworks.actionSets extension point.

The JLedger application uses an action set to contribute a menu for opening and closing a "Company" (a Chart of Accounts really). The markup follows:

<extension point = "org.jlense.uiworks.actionSets">
    <actionSet id="org.jledger.ui" label="Standard JLedger Actions" visible="true">

        <!--
        add 'Company' menu to the main menu bar.
        -->
        <menu id="org.jledger.ui.company" label="Company" path="additions">
            <separator name="new.ext"/>
            <separator name="actions.ext"/>
            <separator name="group1.ext"/>
            <separator name="group2.ext"/>
            <separator name="group3.ext"/>
            <separator name="history.list.ext"/>
        </menu>

        <!--
        add an 'open' menu.
        -->
        <action id="org.jledger.ui.company.open"
            menubarPath="org.jledger.ui.company/new.ext"
            toolbarPath="new.ext"
            definitionID="org.jledger.ui.company.open"
            label="&Open Company@Ctrl+O"
            tooltip="Open an existing Company"
            helpContextId="org.jledger.ui.company.open"
            class="org.jledger.ui.company.OpenCompanyActionDelegate"/>

        <!--
        add a 'close' menu.
        -->
        <action id="org.jledger.ui.company.close"
            menubarPath="org.jledger.ui.company/new.ext"
            definitionID="org.jledger.ui.company.open"
            label="&Close Company@Ctrl+C"
            tooltip="Close currently open Company"
            helpContextId="org.jledger.ui.company.close"
            class="org.jledger.ui.company.CloseCompanyActionDelegate"/>

    </actionSet>
</extension>

Wow, there's a lot going on here! Let's take it a step at a time, looking only at the first action for now.

First, the action set is declared and given a label. The action set label is not really used in the default JLense workbench. The rest of the action set declaration is concerned with defining the menu in which the actions appears and the actions themselves.

We define a menu whose label, Company, appears in the workbench menus. The menu's path tells the workbench to place the new menu in the additions slot of the main menu bar. We also define some slots in our new menu so that actions can be inserted by other plugins at specific locations in our menu.

This markup alone is enough to cause the menu to appear in the workbench menu bar.