您的位置:首页 > 其它

How do I enable global actions such as Cut, Paste, and Print in my editor?

2011-12-11 14:20 441 查看

FAQHowdoIenableglobalactionssuchasCut,Paste,andPrintinmyeditor?


如何在Editor激活时关联全局的RetargetAction?

Youreditor'sIEditorActionBarContributor,definedintheeditordefinitioninthe
plugin.xmlfile,isresponsibleforenablingglobalactions.Wheneveryoureditorbecomestheactivepart,themethod
setActiveEditoriscalledontheactionbarcontributor.Thisiswhereyoucanretargettheglobalactionsforyoureditor.Keepinmindthateacheditortypehasonlyoneeditoractionbarcontributor,soyouneedtoupdateyouractionstoreflect
thecurrenteditor.Inthisexample,theglobalPrintactionisbeingretargetedtotheactiveeditor:

IActionprint=...;
publicvoidsetActiveEditor(IEditorPartpart){
IActionBarsbars=getActionBars();
if(bars==null)
return;
print.setEditor(part);
bars.setGlobalActionHandler(
IWorkbenchActionConstants.PRINT,print);
bars.updateActionBars();
}


来自EclipseRCPFAQ。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: