FAQ How do I enable global actions such as Cut, Paste, and Print in my editor?
如何在Editor激活时关联全局的Retarget Action?
Your editor's IEditorActionBarContributor, defined in the editor definition in the plugin.xml file, is responsible for enabling global actions. Whenever your editor becomes the active part, the method setActiveEditor is called on the action bar contributor. This is where you can retarget the global actions for your editor. Keep in mind that each editor type has only one editor action bar contributor, so you need to update your actions to reflect the current editor. In this example, the global Print action is being retargeted to the active editor:
IAction print = ...;
public void setActiveEditor(IEditorPart part) {
IActionBars bars= getActionBars();
if (bars == null)
return;
print.setEditor(part);
bars.setGlobalActionHandler(
IWorkbenchActionConstants.PRINT, print);
bars.updateActionBars();
}
来自Eclipse RCP FAQ。

本文详细介绍了如何通过Editor的IEditorActionBarContributor接口激活全局动作,如剪切、复制、打印等。具体实现包括在Editor激活时通过setActiveEditor方法更新动作目标,并设置全局动作处理器。
4444

被折叠的 条评论
为什么被折叠?



