Action Sets

Identifier: org.eclipse.ui.actionSets

Description: This extension point is used to add menus, menu items and toolbar buttons to the common areas in the workbench window. These contributions are collectively known as an action set and appear within the workbench window by user preference.

Configuration Markup:

   <!ELEMENT actionSet (menu)* (action)* (description?)>
   <!ATTLIST actionSet
      id        CDATA #REQUIRED
      label     CDATA #REQUIRED
      visible   (true | false) #IMPLIED
    >
    <!ELEMENT description (#PCDATA)>

   <!ELEMENT menu (separator)+ (groupMarker)*>
   <!ATTLIST menu
      id         CDATA #REQUIRED
      label      CDATA #REQUIRED
      path       CDATA #IMPLIED
   >    <!ELEMENT separator EMPTY>
   <!ATTLIST separator
      name       CDATA #REQUIRED
   >
  • name - a name of the separator that can later be referenced as the last token in the action path. Therefore, separators serve as named groups into which actions and submenus can be added.
  •    <!ELEMENT groupMarker EMPTY>
       <!ATTLIST groupMarker
          name       CDATA #REQUIRED
       >
  • name - a name of the group marker that can later be referenced as the last token in the action path.
  •    <!ELEMENT action (selection)* (enablement)?>
       <!ATTLIST action
          id                NMTOKEN #REQUIRED
          label             CDATA #REQUIRED
          accelerator       CDATA #IMPLIED
          definitionId      CDATA #IMPLIED
          menubarPath       CDATA #IMPLIED
          toolbarPath       CDATA #IMPLIED
          icon              CDATA #IMPLIED
          disabledIcon      CDATA #OPTIONAL
          hoverIcon         CDATA #OPTIONAL
          tooltip           CDATA #IMPLIED
          helpContextId     CDATA #IMPLIED
          state             (true | false) #IMPLIED
          pulldown          (true | false) #IMPLIED
          class             CDATA #OPTIONAL
          retarget          (true | false) #OPTIONAL
          allowLabelUpdate  (true | false) #OPTIONAL
          enablesFor        CDATA #IMPLIED
       >    <!ELEMENT selection EMPTY>
       <!ATTLIST selection
          class             CDATA #REQUIRED
          name              CDATA #IMPLIED
       >    <!ELEMENT enablement (and | or | not | objectClass | objectState | systemProperty | pluginState)*>
       <!ATTLIST enablement EMPTY>
    In version 2.0 of Eclipse, an enablement element may be used to define the enablement for the action.  For more information on the use of enablement element, refer to actionExpressions.html.
    Examples:

    The following is an example of an action set (note the subelements and the way attributes are used):

        <extension point = "org.eclipse.ui.actionSets">
            <actionSet id="com.xyz.actionSet"
                label="My Actions"
                visible="true">
                <menu id="com.xyz.xyzMenu"
                    label="XYZ Menu"
                    path="additions">
                    <separator name="group1"/>
                </menu>
                <action id="com.xyz.runXYZ"
                    label="&amp;Run XYZ Tool"
                    menubarPath="com.xyz.xyzMenu/group1"
                    toolbarPath="Normal/XYZ"
                    icon="icons/runXYZ.gif"
                    tooltip="Run XYZ Tool"
                    helpContextId="com.xyz.run_action_context"
                    class="com.xyz.actions.RunXYZ"
                    enablesFor="1">
                    <selection class="org.eclipse.core.resources.IFile" name="*.java"/>
                </action>
                <action id="com.xyz.runABC"
                    label="&amp;Run ABC Tool"
                    menubarPath="com.xyz.xyzMenu/group1"
                    toolbarPath="Normal/XYZ"
                    icon="icons/runABC.gif"
                    tooltip="Run ABC Tool"
                    helpContextId="com.xyz.run_abc_action_context"
                    retarget="true"
                    allowLabelUpdate="true">
                </action>
            </actionSet>
        </extension>

    In the example above, the specified action, named "My Actions", is initially visible within each perspective.  It will only enable for a single selection (enablesFor attribute). In addition, objects within the selection must implement the specified interface (IFile) and must be a Java file.

    API Information: The value of the class attribute must be the fully qualified name of a class that implements org.eclipse.ui.IWorkbenchWindowActionDelegate or org.eclipse.ui.IWorkbenchWindowPulldownDelegate.  The latter should be implemented in cases where pulldown is true.  This class is loaded as late as possible to avoid loading the entire plug-in before it is really needed.

    The enablement criteria for an action extension is initially defined by enablesFor, selection and enablement.  However, once the action delegate has been instantiated, it may control the action enable state directly within its selectionChanged method.

    It is important to note that the workbench does not generate menus on plug-ins' behalf: menu paths must reference menus that already exist.

    Action and menu labels may contain special characters that encode mnemonics and accelerators using the following rules:

    1. Mnemonics are specified using the ampersand ('&') character in front of a selected character in the translated text. Since ampersand is not allowed in XML strings, use &amp; character entity.
    2. Optional accelerators are specified at the end of the name string, using @ followed by a series of modifiers and the final accelerator character (for example, &amp;Save@Ctrl+S). Modifier can be chained using the '+' sign as the delimiter (as in @Ctrl+Shift+S).
    If two or more actions are contributed to a menu or toolbar by a single extension the actions will appear in the reverse order of how they are listed in the plugin.xml file. This behavior is admittedly unintuitive.  However, it was discovered after the  Eclipse Platform API was frozen.  Changing the behavior now would break every plug-in which relies upon the existing behavior.

    Supplied Implementation: Plug-ins may use this extension point to add new top level menus (for example, Debug). Plug-ins can also define named groups which allow other plug-ins to contribute their actions into them.

    Top level menus are created by using the following values for the path attribute:

    Omitting the path attribute will result in adding the new menu into the additions menu bar group.

    The default groups in a workbench window are defined in the IWorkbenchActionConstants interface.  These constants can be used in code for dynamic contribution.  The values can also be copied into an XML file for fine grained integration with the existing workbench menus and toolbar.

    Various menu and toolbar items within the workbench window are defined algorithmically.  In these cases a separate mechanism must be used to extend the window.  For example, adding a new workbench view results in a new menu item appearing in the Window menu. Import, Export, and New Wizards extensions are also added automatically to the window.
     

    Copyright IBM Corporation and others 2000, 2002.