### org.eclipse.ui.editorActions

We've just seen how editors can contribute their own actions to the workbench menus and tool bar when they become active. The org.eclipse.ui.editorActions extension point allows a plug-in to add to the workbench menus and tool bar when another plug-in's editor becomes active.

In the readme example, the plug-in uses the editorActions extension point to contribute additional actions to the menu contributed by the readme editor. The definition in our plugin.xml should look pretty familiar by now.

    <extension
        point = "org.eclipse.ui.editorActions">
          <editorContribution
             id="org.eclipse.ui.examples.readmetool.ec1"
             targetID="org.eclipse.ui.examples.readmetool.ReadmeEditor">
    	   <action id="org.eclipse.ui.examples.readmetool.ea1"
                  label="%Editors.Action.label"
                  toolbarPath="ReadmeEditor"
                  icon="icons/obj16/editor.png"
                  tooltip="%Editors.Action.tooltip"
                  class="org.eclipse.ui.examples.readmetool.EditorActionDelegate"
                  definitionId="org.eclipse.ui.examples.readmetool.ea1"
                  />
          </editorContribution>
     </extension>

Similar to a view action, the extension must specify the targetID of the editor to which it is contributing actions. The action itself is very similar to a view action (id, label, icon, toolbarPath, ...), except that the specified class must implement IEditorActionDelegate and a definitionId can be specified to link this action to a Command specified by the org.eclipse.ui.commands extension, which is important for keybinding. See Commands.

Note that a menu bar path is not specified in this markup. Therefore, the action will appear in the workbench tool bar when the editor is active, but not in the workbench menu bar. (See Menu and toolbar paths for a discussion of toolbar and menu paths.)

Sure enough, when the editor is active, we see our editor action on the tool bar next to the actions that were contributed by the editor itself.

The readme tool supplies EditorActionDelegate to implement the action. This class is very similar to the view action delegate we saw earlier.

    public void run(IAction action) {
    	MessageDialog.openInformation(editor.getSite().getShell(),
    		MessageUtil.getString("Readme_Editor"),
    		MessageUtil.getString("Editor_Action_executed"));
    }