动态更改Eclipse工具栏图标 [英] Change Eclipse toolbar icon dynamically

查看:206
本文介绍了动态更改Eclipse工具栏图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在plugin.xml文件中定义了一个带有其自己图标的工具栏项,例如:

I've got a toolbar item with its own icon, defined in the plugin.xml file like:

<action
class="MyActionClass"
id="MyActionID"
label="MyActionLabel"
menubarPath="MyActionMenuBarPath"
toolbarPath="MyActionToolBarPath"
icon="icon/myicon.png" <---- this one
     ...
</action>

如何在需要时动态更改?我的意思是从代码中更改它

How do I change this dynamically when needed? I mean changing it from code

推荐答案

使用 org.eclipse.ui.menus 扩展点,并添加 menuContribution dynamic dynamic class 应该是 ControlContribution 并实施 createControl 方法来创建按钮。

Use org.eclipse.ui.menus extension point instead and add menuContribution with dynamic. The class of dynamic should subclass ControlContribution and implement createControl method to create a button.

这篇关于动态更改Eclipse工具栏图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆