blob: bd62e48383066fd10db8a29f3071b05728c6f0ed [file] [log] [blame]
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.75 [en] (Windows NT 5.0; U) [Netscape]">
<title>Eclipse Workbench Extension Point: Editor Actions</title>
</head>
<body link="#0000FF" vlink="#800080">
<center>
<h1>
Editor Menus, Toolbars and Actions</h1></center>
<b><i>Identifier: </i></b>org.eclipse.ui.editorActions
<p><b><i>Description: </i></b>This extension point is used to add actions
to the menu and toolbar for editors registered by other plug-ins.
<p>The initial contribution set for an editor is defined by another extension
point (<a href="org_eclipse_ui_editors.html">org.eclipse.ui.editors</a>).
One set of actions is created and shared by all instances of the same editor
type.&nbsp; When invoked, these action act upon the active editor.&nbsp;
This extension point follows the same pattern.&nbsp; Each action extension
is created and shared by all instances of the same editor type.&nbsp; The
action class is required to implement <tt>org.eclipse.ui.IEditorActionDelegate</tt>.&nbsp;
The active editor is passed to the delegate by invoking <tt>IEditorActionDelegate#setActiveEditor</tt>.
<p><b><i>Configuration Markup:</i></b>
<p><tt>&nbsp;&nbsp; &lt;!ELEMENT editorContribution (menu | action)*></tt>
<br><tt>&nbsp;&nbsp; &lt;!ATTLIST editorContribution</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
CDATA #REQUIRED</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; targetID&nbsp;&nbsp; CDATA #REQUIRED</tt>
<br><tt>&nbsp;&nbsp; ></tt>
<blockquote>
<li>
<b>id</b> - a unique identifier that can be used to reference this contribution</li>
<li>
<b>editorID</b> - a unique identifier of a previously registered editor
that is the target of this contribution</li>
</blockquote>
<tt>&nbsp;&nbsp; &lt;!ELEMENT menu (separator)+></tt>
<br><tt>&nbsp;&nbsp; &lt;!ATTLIST menu</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
CDATA #REQUIRED</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; label&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
CDATA #REQUIRED</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; path&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
CDATA #IMPLIED</tt>
<br><tt>&nbsp;&nbsp; ></tt>
<ul>
<li>
<b>id</b> - a unique identifier that can be used to reference this menu</li>
<li>
<b>label</b> - the text label of the new menu. The label should include
mnemonic information.</li>
<li>
<b>path</b> - the location of the menu starting from the root of the menu
bar. If omitted, the menu will be added into the slot <tt>additions</tt>
on the menu bar. Each token in the path must refer to an existing menu
in the workbench, except the last one, which represents a named group in
the last menu in the path.</li>
</ul>
<tt>&nbsp;&nbsp; &lt;!ELEMENT separator EMPTY></tt>
<br><tt>&nbsp;&nbsp; &lt;!ATTLIST separator</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
CDATA #REQUIRED</tt>
<br><tt>&nbsp;&nbsp; ></tt>
<blockquote>
<li>
<b>name</b> - 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 can be added.</li>
</blockquote>
<tt>&nbsp;&nbsp; &lt;!ELEMENT action (selection)* (enablement)?></tt>
<br><tt>&nbsp;&nbsp; &lt;!ATTLIST action</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
NMTOKEN #REQUIRED</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; label&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
CDATA #REQUIRED</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; accelerator&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
CDATA #IMPLIED</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; menubarPath&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
CDATA #IMPLIED</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; toolbarPath&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
CDATA #IMPLIED</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; icon&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
CDATA #IMPLIED</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; disabledIcon&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
CDATA #OPTIONAL</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hoverIcon&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
CDATA #OPTIONAL</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tooltip&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
CDATA #IMPLIED</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; helpContextId&nbsp;&nbsp;&nbsp;&nbsp;
CDATA #IMPLIED</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; state&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
(true | false) #IMPLIED</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; class&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
CDATA #REQUIRED</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; enablesFor&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
CDATA #IMPLIED</tt>
<br><tt>&nbsp;&nbsp; ></tt>
<ul>
<li>
<b>id</b> - a unique identifier that can be used as a reference for this
action.</li>
<li>
<b>label</b> - a translatable name that is used in various ways, depending
on the context. In menus, it is used as the menu text. In toolbars, it
is used as the button label. The label can contain JFace-encoded mnemonic
and accelerator information (see example).</li>
<li>
<b>accelerator</b> - the accelerator for the action. This is specified
as a combination of the keys CTRL, SHIFT and ALT and an accelrator key.
These values are not internationalized and should not be translated. Specification
of the accelerator for the entry title should be done in the label - this
value will not be used to build a menu entry.</li>
<li>
<b>menubarPath</b> - a slash-delimited absolute path ('/') that is used
to specify the location of the action in the menu bar. The path may only
point to menus that belong to the target editor. The last token represents
the named separator group into which the action will be added. If the path
is omitted, the action will not appear in menu bar.</li>
<li>
<b>toolbarPath</b> - a slash-delimited path ('/') that is used to specify
the location of the action in the toolbar. The first token represents the
toolbar ID (with "Normal" being the default toolbar), while the second
token is the named group within the toolbar. If the group does not exist
in the toolbar, it will be created. If toolbarPath is omitted, the action
will not appear.</li>
<li>
<b>icon</b> - a relative path of an icon that will be used to visually
represent the action in its context. If it is omitted and the action should
appear in the toolbar, the workbench will use a place holder icon. The
path is relative to the location of the plugin.xml file of the contributing
plug-in.</li>
<li>
<b>disabledIcon</b> - a relative path of an icon that will be used to visually
represent the action in its context when the action is disabled. If it
is omitted the normal icon will simply appear grayed out. The path is relative
to the location of the plugin.xml file of the contributing plug-in.</li>
<li>
<b>hoverIcon</b> - a relative path of an icon that will be used to visually
represent the action in its context when the mouse is over the action.
If it is omitted the normal icon will be used. The path is relative to
the location of the plugin.xml file of the contributing plug-in.</li>
<li>
<b>tooltip</b> - used if the action is to appear in the tool bar. Otherwise,
it is ignored.</li>
<li>
<b>helpContextId -</b> a unique identifier indicating the help context
id for this action. If the action appears as a menu item, then pressing
F1 while the menu item is highlighted will display help for the given context
id.</li>
<li>
<b>state</b> - an optional attribute indicating that the action should
be of a toggle type. When added to a menu, it will manifest itself as a
check box item. When added to a tool bar, it will become a toggle button.
If defined, attribute value will be used as initial state (either <tt>true</tt>
or <tt>false</tt>).</li>
<li>
<b>class</b> - the name of the fully qualified class that implements <tt>org.eclipse.ui.IEditorActionDelegate</tt>.</li>
<li>
<b>enablesFor</b> - a value indicating the selection count which must be
met to enable the action.&nbsp; If this attribute is specified and the
condition is met the action is enabled.&nbsp; If the condition is not met
the action is disabled.&nbsp; If no attribute is specified the action is
enabled for any number of items selected.&nbsp; The following attribute
formats are supported:</li>
<ul>&nbsp;
<br><b>!</b> - 0 items selected
<br><b>?</b> - 0 or 1 items selected
<br><b>+</b> - 1 or more items selected
<br><b>multiple, 2+</b> - 2 or more items selected
<br><b>n</b> - a precise number of items selected.&nbsp; Example: 4.
<br><b>*</b> - any number of items selected</ul>
</ul>
<tt>&nbsp;&nbsp; &lt;!ELEMENT selection EMPTY></tt>
<br><tt>&nbsp;&nbsp; &lt;!ATTLIST selection</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; class&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
CDATA #REQUIRED</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
CDATA #IMPLIED</tt>
<br><tt>&nbsp;&nbsp; ></tt>
<ul>
<li>
<b>class</b> - a fully qualified name of the class or interface that each
object in the selection must subclass or implement in order to enable the
action.</li>
<li>
<b>name</b> - a wild card filter that can optionally be applied to objects
in the selection. If this filter is specified and the match fails, the
action will be disabled.</li>
</ul>
<tt>&nbsp;&nbsp; &lt;!ELEMENT enablement (and | or | not | objectClass
| objectState | systemProperty</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | pluginState)></tt>
<br><tt>&nbsp;&nbsp; &lt;!ATTLIST enablement EMPTY></tt>
<blockquote>In version 2.0 of Eclipse, an <tt>enablement</tt> element may
be used to define the enablement for the action.&nbsp; For more information
on the use of <tt>enablement</tt> element, refer to <a href="actionExpressions.html">actionExpressions.html</a>.</blockquote>
The enablement criteria for an action extension are initially defined by
<tt>enablesFor,
selection</tt> and <tt>enablement</tt>.&nbsp; However, once the action
delegate has been instantiated, it may control the action enable state
directly within its
<tt>selectionChanged</tt> method.
<p>Action and menu labels may contain special characters that encode mnemonics
and accelerators using the following rules:
<ol>
<li>
Mnemonics are specified using the ampersand ('&amp;') character in front
of a selected character in the translated text. Since ampersand is not
allowed in XML strings, use <tt>&amp;amp;</tt> character entity.</li>
<li>
Optional accelerators are specified at the and of the name string, using
<tt>@</tt>
followed by the series of modifiers and the final accelerator character
(for example, <tt>&amp;amp;Save@Ctrl+S</tt>). Modifiers can be chained
using the '+' sign as the delimiter (as in <tt>@Ctrl+Shift+S</tt>).</li>
</ol>
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.&nbsp;
However, it was discovered after the&nbsp; Eclipse Platform API was frozen.&nbsp;
Changing the behavior now would break every plug-in which relies upon the
existing behavior.
<p><b><i>Examples:</i></b>
<p>The following is an example of an editor action extension point:
<p><tt>&nbsp;&nbsp; &lt;extension point="org.eclipse.ui.editorActions"></tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;editorContribution</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; id="com.xyz.xyzContribution"</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; targetID="com.ibm.XMLEditor"></tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;menu id="XYZ"
label="&amp;amp;XYZ Menu"></tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;separator name="group1"/></tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/menu></tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;action</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
id="com.xyz.runXYZ"</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
label="&amp;amp;Run XYZ Tool"</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
menubarPath="XYZ/group1"</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
toolbarPath="Normal/additions"</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
state="true"</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
icon="icons/runXYZ.gif"</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
tooltip="Run XYZ Tool"</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
helpContextId="com.xyz.run_action_context"</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
class="com.xyz.actions.RunXYZ"></tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/action></tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/editorContribution></tt>
<br><tt>&nbsp;&nbsp; &lt;/extension></tt>
<p>In the example above, the specified action will appear as a check box
item in the new top-level menu named "XYZ Menu", and as a toggle button
in the toolbar.
<p>The following is an example of an editor action extension point:
<p><tt>&nbsp;&nbsp; &lt;extension point="org.eclipse.ui.editorActions"></tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;editorContribution</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; id="com.xyz.xyz2Contribution"</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; targetID="com.ibm.XMLEditor"></tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;menu</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
id="XYZ2"</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
label="&amp;amp;XYZ2 Menu"</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
path="edit/additions"></tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;separator name="group1"/></tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/menu></tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;action</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
id="com.xyz.runXYZ2"</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
label="&amp;amp;Run XYZ2 Tool"</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
menubarPath="edit/XYZ2/group1"</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
state="true"</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
icon="icons/runXYZ2.gif"</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
tooltip="Run XYZ2 Tool"</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
helpContextId="com.xyz.run_action_context2"</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
class="com.xyz.actions.RunXYZ2"></tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/action></tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/editorContribution></tt>
<br><tt>&nbsp;&nbsp; &lt;/extension></tt>
<p>In the example above, the specified action will appear as a check box
item in the sub-menu named "XYZ2 Menu" in the top level "Edit" menu.
<p><b><i>API Information: </i></b>The value of the <tt>class</tt> attribute
must be a fully qualified name of a Java class that implements <tt>org.eclipse.ui.IEditorActionDelegate</tt>.
This interface is loaded as late as possible to avoid loading the entire
plug-in before it is really needed. The method <tt>setActiveEditor</tt>
will be called each time an editor of the specified type is activated.
Only one set of actions and menus will be created for all instances of
the specified editor type, regardless of the number of editor instances
currently opened in the workbench.
<p>This extension point can be used to contribute actions into menus previously
created by the target editor. In addition, menus and actions can be contributed
to the workbench window.&nbsp; The identifiers for actions and major groups
within the workbench window are defined in <tt>org.eclipse.ui.IWorkbenchActionConstants</tt>.&nbsp;
These should be used as a reference point for the addition of new actions.&nbsp;
Top level menus are created by using the following values for the <tt>path</tt>
attribute:
<ul>
<li>
<tt>additions</tt> - represents a group to the left of the Window menu.</li>
</ul>
Actions and menus added into these paths will only be shown while the associated
editor is active. When the editor is closed, menus and actions will be
removed.
<p><b><i>Supplied Implementation:</i></b> The workbench provides a built-in
"Default Text Editor". Plug-ins can contribute into this default editor
or editors provided by other plug-ins.
<p><a href="hglegal2002.htm"><img SRC="ngibmcpy2002.gif" ALT="Copyright IBM Corporation and others 2000, 2002." BORDER=0></a>
</body>
</html>