How do I enable global actions such as Cut, Paste, and Print in my editor?
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
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。
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
所有评论(0)