Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Form ToolBar from plugin.xml definition(How to create a toolbar IContributionItem from plugin.xml)
Form ToolBar from plugin.xml definition [message #1065847] Thu, 27 June 2013 14:46 Go to next message
Kimbal G. Welch is currently offline Kimbal G. Welch
Messages: 5
Registered: July 2009
Junior Member
I'm trying to add a toolbar to an Form on an Editor page. The toolbar will show at the stop of the page rather than on the coolbar, and I'm using the forms plugin API.

What I'd like to do is define the bar in the plugin.xml and use that definition to create a toolbar contribution item that I can add to the form's toolbar manager.

I can write a lot of code to get the menu extension point "org.eclipse.ui.menus" using "Platform.getExtensionRegistry().getExtensionPoint" and parse it for the toolbar definition and then fill in a toolbar contribution item.

However, code for this already has to exist somewhere in Eclipse, and I'm hoping it is accessible to RCP developers so I don't have to reproduce that work.

Can someone tell me if there is an object or method that will return the contribution item from the plugin.xml when given the toolbar URI?

Thanks,
Re: Form ToolBar from plugin.xml definition [message #1065992 is a reply to message #1065847] Fri, 28 June 2013 13:02 Go to previous message
Paul Webster is currently offline Paul Webster
Messages: 6850
Registered: July 2009
Location: Ottawa
Senior Member

On 06/27/2013 02:46 PM, Kimbal G. Welch wrote:
> I'm trying to add a toolbar to an Form on an Editor page. The toolbar
> will show at the stop of the page rather than on the coolbar, and I'm
> using the forms plugin API.
> What I'd like to do is define the bar in the plugin.xml and use that
> definition to create a toolbar contribution item that I can add to the
> form's toolbar manager.

Yes, you can use the IMenuService to take advantage of the existing
org.eclipse.ui.menus extension point.

// your toolbar manager for the toolbar in your editor
ToolBarManager toolBarManager = ....;

Then:
IMenuService menuService
= (IMenuService) getSite().getService(IMenuService.class);
menuService.populateContributionManager(toolBarManager,
"toolbar:some.useful.toolbar.id");

On your editor dispose, you have to remember to do:
menuService.releaseContributions(toolBarManager);


This works in Kepler. I'm not sure if it works in Juno SR2.

Later,
Paul

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/workbench.htm


Previous Topic:Kepler: New & Noteworthy for e4 Applications
Next Topic:Opening a view in a non-active perspective
Goto Forum:
  


Current Time: Sun Apr 20 09:26:02 EDT 2014

Powered by FUDForum. Page generated in 0.02501 seconds