Menu contribution to a submenu? [message #827090] |
Thu, 22 March 2012 22:07 |
|
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 |
|
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
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
|
|
|
Re: Menu contribution to a submenu? [message #827872 is a reply to message #827479] |
Fri, 23 March 2012 22:44 |
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.04342 seconds