Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » EditorPart MenuContribution(Adding a Toolbar to a FormPage with the Menu Extension)
EditorPart MenuContribution [message #681749] Thu, 09 June 2011 18:51 Go to next message
sebastian.sprenger is currently offline sebastian.sprengerFriend
Messages: 16
Registered: November 2009
Junior Member
Hello,
I´m new to rcp and i have a lot of problems understanding it.
I wanted to use the org.eclipse.ui.menus extension point to add toolbar items to my application. I successfully added some toolbar items to the toplevel-toolbar and also to the toolbar of a view.
However, I also want to configure the toolbar of a FormPage in a FormEditor declaratively. So I have the following settings in my plugin.xml


<extension
point="org.eclipse.ui.editors">

<editor

<!--this is my EditorPart extending FormPage. I create it programmatically and add it to my FormEditor, so it doesn´t seem to make sense to declare it here. I set the same Id in my code-->

class="org.ssprenger.agenato.editors.ConnectorEditor"
default="false"
id="org.ssprenger.agenato.editors.connector"
name="Connector Editor">
</editor>
</extension>
<extension
point="org.eclipse.ui.menus">
<!-- that´s the way i tried to set the menu contribution-->
<menuContribution
locationURI="toolbar:org.ssprenger.agenato.editors.connector">

<!-- the command worked for another toolbar-->

<command
commandId="org.ssprenger.agenato.addAdapter"
icon="icons/add_adapter.png"
style="push"
tooltip="Create a new Adapter">
</command>


</menuContribution>
</extension>

That doesn´t work. Please help, thank you
Re: EditorPart MenuContribution [message #681777 is a reply to message #681749] Thu, 09 June 2011 20:42 Go to previous messageGo to next message
sebastian.sprenger is currently offline sebastian.sprengerFriend
Messages: 16
Registered: November 2009
Junior Member
I have found a solution. In my editorPart (a formPage) I had to create a MenuService and populate a ContributionManager like this

ToolbarManager manager = ....;
IMenuService menuService = (IMenuService) getSite().getService(
IMenuService.class);
menuService.populateContributionManager(manager, "toolbar:someId");

now I can add menuContributions

<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="toolbar:someId">


<command
commandId="org.ssprenger.agenato.addAdapter"
icon="icons/add_adapter.png"
style="push"
tooltip="Create a new Adapter">
</command>


</menuContribution>
</extension>
Re: EditorPart MenuContribution [message #682123 is a reply to message #681777] Fri, 10 June 2011 13:09 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

That's the correct API to do it. Also remember when your down with that toolbar or form, use IMenuService.releaseContributions(ContributionManager) in your cleanup.

PW


Previous Topic:JasperWave - completely new Eclipse-based designer for JasperReports
Next Topic:How to capture key press event over multiple views
Goto Forum:
  


Current Time: Tue Apr 23 11:04:37 GMT 2024

Powered by FUDForum. Page generated in 0.03070 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top