WARNING: This extension point is DEPRECATED.
Do not use this extension point, it will be removed in future versions of this product.
Instead, use the extension point org.eclipse.ui.commands
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 the user customizing a perspective.
You can now use org.eclipse.ui.menus to place commands in menus and toolbars as well.
There is an implementation limitation which currently affects action sets. It is important to define the entire menu structure that is to be referenced within the action set. So, for example, if another action set defines a menu called "example", it is not possible to rely on "example" existing. It is necessary to redefine the "example" menu in every action set that wishes to use it.
<!ELEMENT extension (actionSet+)>
<!ATTLIST extension
point CDATA #REQUIRED
id CDATA #IMPLIED
name CDATA #IMPLIED>
<!ELEMENT actionSet (menu* , action*)>
<!ATTLIST actionSet
id CDATA #REQUIRED
label CDATA #REQUIRED
visible (true | false)
description CDATA #IMPLIED>
This element is used to define a group of actions and/or menus.
<!ELEMENT action ((selection* | enablement?) , class?)>
<!ATTLIST action
id CDATA #REQUIRED
label CDATA #REQUIRED
accelerator CDATA #IMPLIED
definitionId IDREF #IMPLIED
menubarPath CDATA #IMPLIED
toolbarPath CDATA #IMPLIED
icon CDATA #IMPLIED
disabledIcon CDATA #IMPLIED
hoverIcon CDATA #IMPLIED
tooltip CDATA #IMPLIED
helpContextId CDATA #IMPLIED
style (push|radio|toggle|pulldown) "push"
state (true | false)
pulldown (true | false)
class CDATA #IMPLIED
retarget (true | false)
allowLabelUpdate (true | false)
enablesFor CDATA #IMPLIED
mode (FORCE_TEXT)
initialEnabled (true | false) >
This element defines an action that the user can invoke in the UI.
ISharedImages
constant. The icon will appear in toolbars but not in menus. Enabled actions will be represented in menus by the hoverIcon.push | - as a regular menu item or tool item. | |
radio | - as a radio style menu item or tool item. Actions with the radio style within the same menu or toolbar group behave as a radio set. The initial value is specified by the state attribute. | |
toggle | - as a checked style menu item or as a toggle tool item. The initial value is specified by the state attribute. | |
pulldown | - as a cascading style menu item or as a drop down menu beside the tool item. |
pulldown
and retarget
is not supported. Commands can be used to provide this type of functionality, see org.eclipse.ui.menus and the command element with a style of pulldown
.! | - 0 items selected | |
? | - 0 or 1 items selected | |
+ | - 1 or more items selected | |
multiple, 2+ | - 2 or more items selected | |
n | - a precise number of items selected.a precise number of items selected. For example: enablesFor=" 4" enables the action only when 4 items are selected | |
* | - any number of items selected |
FORCE_TEXT
will show text even if there is an icon. See ActionContribuitonItem.<!ELEMENT parameter EMPTY>
<!ATTLIST parameter
name CDATA #REQUIRED
value CDATA #REQUIRED>
A parameter element to be used within an IExecutableExtension element. This will be passed as initialization data to the instantiated class.
<!ATTLIST class
class CDATA #IMPLIED>
The element version of the class
attribute. This is used when the class implements org.eclipse.core.runtime.IExecutableExtension
and there is parameterized data that you wish used in its initialization.
org.eclipse.ui.IWorkbenchWindowActionDelegate
. It may also implement org.eclipse.core.runtime.IExecutableExtension
.
<extension point = "org.eclipse.ui.actionSets"> <actionSet id="com.xyz.actionSet" label="My Actions"> <menu id="com.xyz.xyzMenu" label="XYZ Menu" path="additions"> <separator name="group1"/> <separator name="option1"/> </menu> <action id="com.xyz.runXYZ" label="&Run XYZ Tool" style="toggle" state="false" menubarPath="com.xyz.xyzMenu/group1" icon="icons/runXYZ.png" 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="&Run ABC Tool" style="push" menubarPath="com.xyz.xyzMenu/group1" toolbarPath="Normal/XYZ" icon="icons/runABC.png" tooltip="Run ABC Tool" helpContextId="com.xyz.run_abc_action_context" retarget="true" allowLabelUpdate="true"> <enablement> <and> <objectClass name="org.eclipse.core.resources.IFile"/> <not> <objectState name="extension" value="java"/> </not> </and> </enablement> </action> <action id="com.xyz.runDEF" label="&Run DEF Tool" style="radio" state="true" menubarPath="com.xyz.xyzMenu/option1" icon="icons/runDEF.png" tooltip="Run DEF Tool" class="com.xyz.actions.RunDEF" helpContextId="com.xyz.run_def_action_context"> </action> <action id="com.xyz.runGHI" label="&Run GHI Tool" style="radio" state="false" menubarPath="com.xyz.xyzMenu/option1" icon="icons/runGHI.png" tooltip="Run GHI Tool" class="com.xyz.actions.RunGHI" helpContextId="com.xyz.run_ghi_action_context"> </action> <action id="com.xyz.runJKL" label="&Run JKL Tool" style="radio" state="false" menubarPath="com.xyz.xyzMenu/option1" icon="icons/runJKL.png" tooltip="Run JKL Tool" class="com.xyz.actions.RunJKL" helpContextId="com.xyz.run_jkl_action_context"> </action> </actionSet> </extension>
In the example above, the specified action set, named "My Actions", is not initially visible within each perspective because the visible attribute is not specified.
The XYZ action will appear as a check box menu item, initially not checked. It is enabled only if the selection count is 1 and if the selection contains a Java file resource.
The ABC action will appear both in the menu and on the toolbar. It is enabled only if the selection does not contain any Java file resources. Note also this is a label retarget action therefore it does not supply a class attribute.
The actions DEF, GHI, and JKL appear as radio button menu items. They are enabled all the time, independent of the current selection state.
The enablement criteria for an action extension is initially defined by enablesFor, and also either selection or 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 a plug-in's behalf. Menu paths must reference menus that already exist.
Action and menu labels may contain special characters that encode mnemonics using the following rules:
The selection and enablement elements are mutually exclusive. The enablement element can replace the selection element using the sub-elements objectClass and objectState. For example, the following:
<selection class="org.eclipse.core.resources.IFile" name="*.java"> </selection>can be expressed using:
<enablement> <and> <objectClass name="org.eclipse.core.resources.IFile"/> <objectState name="extension" value="java"/> </and> </enablement>
Top level menus are created by using the following values for the path attribute:
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 Perspective menu. Import, Export, and New Wizards extensions are also added automatically to the window.
Copyright (c) 2000, 2019 IBM Corporation and others.
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0 which accompanies
this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html/
SPDX-License-Identifier: EPL-2.0