Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Menu contribution to a submenu?(Is there a way to target a separator (not within the same "menus" extension) when that separator may or may not be within a submenu?)
icon5.gif  Menu contribution to a submenu? [message #827090] Thu, 22 March 2012 22:07 Go to next message
Craig Foote is currently offline Craig FooteFriend
Messages: 217
Registered: July 2009
Senior Member
Plugin-1 has a "menus" extension with a menuContribution that needs to appear in two separate products in two different ways.

Product-A wants it to appear in any context menu.

Product-B wants it to appear in any context menu but within a submenu.

So both products will have their own "menus" extension providing the destination placeholder as a separator. Product-A will place it at the root of any context menu and Product-B will provide it as a separator within a "menu" element.

I can get it to work for one or the other but not both.

Is this possible? I've done lots of "menus" extensions and submenus but never have I needed to place a menu item at the context menu root and beneath a submenu declared in another plugin. What would the locationURI look like?

From trial I found that:

1. Using a locationURI of popup:destination will cause contribution to a (sub)menu of that id but not to a separator of that name.

2. Using a locationURI of popup:org.eclipse.ui.popup.any?after=destination will cause contribution to a separator of that name at the root of a context menu but not in a submenu.

Is there a way to target a separator (not within the same "menus" extension) when that separator may or may not be within a submenu? Either declaratively or programmatically?

Help! Any advice appreciated.

Craig
Re: Menu contribution to a submenu? [message #827479 is a reply to message #827090] Fri, 23 March 2012 11:43 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

No, the constant in the locationURI is the parent menu id. To target a specific view context menu, you would use its id: popup:org.eclipse.ui.views.ProblemsView. To target any view context menu, that's where popup:org.eclipse.ui.popup.any comes in, but it only works at the root level.

If your root context menu was x.id, in your second context menu you could add a submenu that was x.id with the appropriate group marker in it. Then the same popup:x.id contribution would apply to the root menu in one and the submenu in the other.

The other thing you could try adding the root level menu to popup:your.context.menu.id and then creating a second menuContribution to popup:the.second.context.menu.id and actually add something like:

<menu some.random.id>
... the menu contents.
</menu>

Later,
PW


Re: Menu contribution to a submenu? [message #827872 is a reply to message #827479] Fri, 23 March 2012 22:44 Go to previous message
Craig Foote is currently offline Craig FooteFriend
Messages: 217
Registered: July 2009
Senior Member
Thanks Paul, you da man!

I've got it working now with two menu contributions in my "source" plugin: one with a locationURI tailored for (sub)menus and the other for separators in the context menu root. The two consuming products, or "consumers", then have either a menu or a separator contribution. Simple and works great.

Thanks again,
Craig
Previous Topic:Common Navigator Framework - plugin extension
Next Topic:ErrorDialog doesnot show special characters
Goto Forum:
  


Current Time: Tue Apr 23 06:11:42 GMT 2024

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

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

Back to the top