我們剛剛見到,當編輯器變為作用中時,它們如何將自己的動作提供給工作台功能表和工具列。 org.eclipse.ui.editorActions 延伸點則可讓外掛程式在另一外掛程式的編輯器進入作用狀態時新增至工作台功能表和工具列。
在 Readme 範例中,外掛程式會利用 editorActions 延伸點來將其他動作提供到 Readme 編輯器所提供的功能表中。 現在,我們的 plugin.xml 其中的定義應該看起來很熟悉。
<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"
/>
</editorContribution>
</extension>
和視圖動作類似,延伸必須指定要接受它提供的動作之編輯器的 targetID。 除了指定的類別必須實作 IEditorActionDelegate 之外,動作本身非常類似視圖動作(id、label、icon 和 toolbarPath ...)。
請注意,這個標記中沒有指定功能表列路徑。因此當編輯器在作用時,動作會出現在工作台工具列中,但不會出現在工作台功能表列中。 (請參閱功能表和工具列路徑,以取得功能表和工具列路徑的討論。)
當然,當編輯器在作用中,我們會在編輯器本身提供的動作旁的工具列中看到我們的編輯器動作。

Readme 工具提供 EditorActionDelegate 來實作這個動作。這個類別非常類似於我們先前見到的視圖動作委派。
public void run(IAction action) {
MessageDialog.openInformation(editor.getSite().getShell(),
MessageUtil.getString("Readme_Editor"),
MessageUtil.getString("Editor_Action_executed"));
}