Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Eclipse toolbar icon dynamically

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

like image 738
Marco A. Avatar asked Feb 23 '23 19:02

Marco A.


1 Answers

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.

like image 200
Martti Käärik Avatar answered Mar 05 '23 04:03

Martti Käärik