以编程方式更改 eclipse RCP 命令的图标

发布于 2024-08-25 23:57:33 字数 252 浏览 5 评论 0原文

我在酷栏中有一个菜单下拉操作。它有 3 个子项,组成一个单选组。当用户选择这些选项之一时,我想更改酷栏中显示的图标。

我用谷歌搜索发现我应该看看: org.eclipse.ui.commands.ICommandService.refreshElements(字符串,地图) 和 org.eclipse.ui.commands.IElementUpdater

查看异常可能是正确的,因为它的信息不足。一两个小代码片段就很棒了。

提前致谢。

I have a menu drop down action in the coolbar. It has 3 sub items that form a radio group. I would like to change the icon shown in the coolbar when the user selects one of these options.

I've googled and seen that I should look at:
org.eclipse.ui.commands.ICommandService.refreshElements(String, Map)
and
org.eclipse.ui.commands.IElementUpdater

Its probably the right thing to look at exception its not enough information. One or two small code snippets will be excellent.

Thanks in advance.

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

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

发布评论

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

评论(2

太阳公公是暖光 2024-09-01 23:57:33

好吧,基本上,如果您不想使用“自定义”控件,那么该怎么做就是让您的处理程序(链接到特定命令的处理程序)实现 IElementUpdater。当显示或单击每个工具栏项时(即,如果用户选择单选按钮),将调用方法:updateElement(UIElement element, Mapparameters)。
该元素有一个 setIcon() 方法,这就是我用来更改菜单下拉操作的图标的方法。

Ok basically if you don't want to use a "custom" control the what to do it is to have your handler (handler that is linked to the specific command) implement IElementUpdater. When every the toolbar item gets shown or clicked on (i.e if the user selects on the the radio buttons) the method: updateElement(UIElement element, Map parameters) gets called.
The element has a setIcon() method and this is what i used to change the icon of the menu drop down action.

白云悠悠 2024-09-01 23:57:33

Coolbar 的每次更新都指向 的专业化WorkbenchWindowControlContribution

这个 bug 186800 中有一些有趣的代码示例。

Every update to the Coolbar points to the specialization of the WorkbenchWindowControlContribution class.

This bug 186800 has some code example in it which can be of interest.

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