以编程方式更改 eclipse RCP 命令的图标
我在酷栏中有一个菜单下拉操作。它有 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,基本上,如果您不想使用“自定义”控件,那么该怎么做就是让您的处理程序(链接到特定命令的处理程序)实现 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.
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.