更改 Eclipse 插件中菜单项的属性?

发布于 2024-09-27 23:44:07 字数 440 浏览 1 评论 0原文

我正在尝试修改 File -> 的行为在我的 Eclispe 插件的菜单栏中刷新。我实际上正在尝试覆盖“org.eclipse.ui.file.refresh”命令的 activeWhen 行为,以便它始终处于活动状态。

关于创建这些菜单项的信息似乎有很多,但关于覆盖它们的信息却很少,有什么想法吗?

我尝试过的代码是:

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

但这并不能解决问题

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情丝乱 2024-10-04 23:44:07

您无法像这样启用该命令。命令的启用由工作台通过咨询活动处理程序(如果有)来完成。有关更详细的信息,请参阅此链接:http:// www.eclipse-tips.com/tutorials/1-actions-vs-commands?start=1

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

怎会甘心 2024-10-04 23:44:07

命令的启用是在运行时计算的:
您可以阅读这篇文章来获取一些提示

萨卢蒂

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

saluti

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文