|Dynamically change icon on the toolbar [message #1396362]
||Tue, 08 July 2014 07:44
| Page Wang
Registered: July 2009
We need to add an option to our RCP application's view toolbar, where it will switch the icons to bigger size.
To try out, I used the sample from rcp tutorial part 3 (http://eclipse.org/articles/Article-RCP-3/tutorial3.html), added a new action called "SwitchIconAction" to the toolbar, if user clicks on it, it will get the ToolBarManager, get all the items on this toolbar, then set the icon to a larger size icon.
IContributionItem tbItems = tbMgr.getItems();
if( tbItems != null && tbItems.length > 0 )
for( IContributionItem item : tbItems )
if( item instanceof ActionContributionItem )
IAction action = ( (ActionContributionItem) item ).getAction();
// find the 1st action and change it's icon to 32x32
ImageDescriptor desc = org.eclipse.ui.tutorials.rcp.part3.Part3Plugin.getImageDescriptor(
"/icons/default_search_32.png" ); //$NON-NLS-1$
action.setImageDescriptor( desc );
action.setHoverImageDescriptor( desc );
tbMgr.update( true );
I do see the icon is changed, but not displayed in 32x32. I have attached my test program.
Is this supported by Eclipse? Is there a way to achieve this?
Thanks for the help!
Powered by FUDForum
. Page generated in 0.02347 seconds