JimmyD JimmyD - 1 year ago 152
Java Question

Add items to toolbar in Eclipse RCP

I'm searching for a way to dynamicly add items to a toolbar in Eclipse RCP.

I use the EModelSerivce to lookup the toolbar in the view of my application.

List<MToolBar> toolbar = service.findElements(application, "toolbar_top", MToolBar.class , null);
MToolBar toolbar = toolbar.get(0);

Now I need to add some Toolbar items to it. How can I do this?

Answer Source

I placed all the toolitems in the .e4xmi file. Default the toolitems are hidden by disable the flag on "To be Rendered". When some MPart need to enable a tooltitem it will be enabled by using:


Hiding it when some other part need to be rendered can be done by setting all the flags back to false.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download