开发者

Alter properties of a menu item in Eclipse Plugin?

I am trying to modify the behaviour of File ->开发者_运维百科 Refresh in the menu bar of my Eclispe plugin. I am effectively trying to override the activeWhen behaviour of the "org.eclipse.ui.file.refresh" command, so that it is always active.

There seems to be plenty of information on creating these menu items but very little on overriding them, any ideas?

Code I tried was:

ICommandService commandService = (ICommandService
     PlatformUI.getWorkbench().getService(ICommandService.class);
Command command = commandService.getCommand("com.example.command");
command.setEnabled(true);

But this doesn't do the trick


You cannot enable the command like that. The enablement of the command is done by the workbench, by consulting the active handler (if any). See this link for a more detailed information: http://www.eclipse-tips.com/tutorials/1-actions-vs-commands?start=1


The enablement of a command is calculated at runtime: you can read this article to get some tips

saluti

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜