Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Reuse of Menu Elements / MenuContributions
Reuse of Menu Elements / MenuContributions [message #819246] Mon, 12 March 2012 17:12 Go to next message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 482
Registered: December 2010
Location: Germany
Senior Member
Hello,

is it possible to re-use MMenu elements?

I have two cases where this would help:
1) Use a menu (or parts of it) in the menu bar and as a popup
2) Use the same popup in multiple parts

What are "Menu Contributions" in the Application e4Xmi?

Greetings
Christoph
Re: Reuse of Menu Elements / MenuContributions [message #819338 is a reply to message #819246] Mon, 12 March 2012 19:55 Go to previous messageGo to next message
Lars Vogel is currently offline Lars VogelFriend
Messages: 1098
Registered: July 2009
Senior Member

I think Popups are currently not supported. Did you make them work?
Re: Reuse of Menu Elements / MenuContributions [message #819841 is a reply to message #819338] Tue, 13 March 2012 11:47 Go to previous messageGo to next message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 482
Registered: December 2010
Location: Germany
Senior Member
Hi Lars

yes.

Step 1) Create a Menu as a child of the Part with the Model Editor
Step 2) Edit the e4xmi directly and change the xsi:txpe from "menu:Menu" to "menu:PopupMenu"
Step 3) Hook the Menu to the control with EMenuService.registerContextMenu

That works great.

At the moment I am also using a MenuDetectListener on an SWT-Tree to switch the popup menu depending on the current selection. That works too, but raised the issue in question "re-using menu definitions".

Thanks for your reply on "Snippets". Is the usage of Menu, Toolbar and Trim Contributions similar to this approach? => Use a processor to copy the MMenuElements in a MenuContribution into all the places the menu should be available (i.e. as a View-Menu and as a Popup-Menu)?

Smile
Christoph
Re: Reuse of Menu Elements / MenuContributions [message #819853 is a reply to message #819841] Tue, 13 March 2012 12:04 Go to previous messageGo to next message
Lars Vogel is currently offline Lars VogelFriend
Messages: 1098
Registered: July 2009
Senior Member

Cool. Thanks for the tip with the context menu. I point Tom (Schindl) also to this discussion, he may want to adjust the model editor.

Yes, the other items (Menu, Toolbar and Trim Contribution) can be used similiar to Snippets IMHO.
Re: Reuse of Menu Elements / MenuContributions [message #819882 is a reply to message #819853] Tue, 13 March 2012 12:46 Go to previous messageGo to next message
Lars Vogel is currently offline Lars VogelFriend
Messages: 1098
Registered: July 2009
Senior Member

Opened bug for support of PopupMenu in Model editor https://bugs.eclipse.org/bugs/show_bug.cgi?id=374062
Re: Reuse of Menu Elements / MenuContributions [message #819896 is a reply to message #819882] Tue, 13 March 2012 13:10 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
This bug has already been fixed with 371549 by Brian some weeks ago so
if you are on an I-build or switch to M6 once it is out things should
just work.

Tom

Am 13.03.12 13:46, schrieb Lars Vogel:
> Opened bug for support of PopupMenu in Model editor
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=374062
Re: Reuse of Menu Elements / MenuContributions [message #819919 is a reply to message #819896] Tue, 13 March 2012 13:46 Go to previous messageGo to next message
Lars Vogel is currently offline Lars VogelFriend
Messages: 1098
Registered: July 2009
Senior Member

@Tom: cool, thanks.
Re: Reuse of Menu Elements / MenuContributions [message #825896 is a reply to message #819246] Wed, 21 March 2012 11:54 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Each MMenu or MMenuItem can only have one parent, so there must be a separate instance in each menu that you need.

MMenuContributions contain menu templates that can be added to regular menus and popup menus. They follow the same convention for specifying where to apply the template as the org.eclipse.ui.menus/menuContribution does.

PW


Re: Reuse of Menu Elements / MenuContributions [message #870392 is a reply to message #825896] Mon, 07 May 2012 23:17 Go to previous messageGo to next message
Lars Vogel is currently offline Lars VogelFriend
Messages: 1098
Registered: July 2009
Senior Member

Thanks again Christoph.

I added the creation of Popup-menus with the e4 tooling to my Eclipse 4 tutorial - Defining Popup Menus
Re: Reuse of Menu Elements / MenuContributions [message #1173443 is a reply to message #870392] Wed, 06 November 2013 14:25 Go to previous message
Cedric Marin is currently offline Cedric MarinFriend
Messages: 1
Registered: November 2013
Junior Member
I bring back the subject to life because I found in the Eclipse source code other ways to share menus that look like Eclipse 3 menu contributions.
I have tested them in my project and it works:

You can add MMenuContribution to a MApplication 'menuContributions' feature.
This MMenuContribution has a 'parentId' : the menu ID of the menu you want to complete and
menu items that will be added to a menu.

You can also add "popup:an.identifier" tags to MMenu and MPopupMenu elements.

With all these elements, the MMenuContribution will be added to a MMenu if:

  • the MMenu identifier equals the contribution parentId
  • parentId is 'popup' : the contribution will be added to ALL popup menus
  • the MMenu has a "popup:an.identifier" tag equals to the MMenuContribution parentId "an.identifier"


So to share a MMenuContribution to many MMenu elements you:

  • put a "popup:an.identifier" tags to MMenu
  • set parentId "an.identifier" on the MMenuContribution


The MMenuContribution also has a position attribute to specify where the contribution will be inserted.
Previous Topic:Restarting RCP application
Next Topic:How to set start perspective
Goto Forum:
  


Current Time: Fri Mar 29 00:56:37 GMT 2024

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

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

Back to the top