Submenu does not show up [message #636564] |
Mon, 01 November 2010 17:50  |
Eclipse User |
|
|
|
I have a set of buttons in a toolbar shown in IViewPart. One of the
buttons has a pull-down list attached. The following XML code for the
toolbar works fine:
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI=" toolbar:com.kelman.basemap.ui.view.BasemapView?after=additio ns ">
<command
commandId="com.kelman.basemap.ui.command.plotTypeDisplay.pulldown "
icon="icons/elcl16/error_display.gif"
id="com.kelman.basemap.ui.toolbar.plotTypeDisplay"
label="Display type"
style="pulldown"
tooltip="Select type of display">
<visibleWhen>
<reference
definitionId="com.kelman.basemap.ui.activeEditor">
</reference>
</visibleWhen>
</command>
</menuContribution>
<menuContribution
locationURI=" menu:com.kelman.basemap.ui.toolbar.plotTypeDisplay?after=add itions ">
<command
commandId="com.kelman.basemap.ui.command.option1"
label="Option 1"
style="radio">
<parameter
name="com.kelman.basemap.ui.command.parameter.option1"
value="OPTION_1">
</parameter>
</command>
<command
commandId="com.kelman.basemap.ui.command.option2"
label="Option 2"
style="radio">
<parameter
name="com.kelman.basemap.ui.command.parameter.option2"
value="OPTION_2">
</parameter>
</command>
</menuContribution>
</extension>
However, when I try to compose a similarly-populated pop-up menu (as a
mirror image of the toolbar), I cannot get the submenu shown where the
toolbar has the button with pull-down list. I tried to use the "menu"
item as the anchor point for the submenu, adding it to the pop-up.
Here is the relevant part of my pop-up menu definition:
<menuContribution
locationURI="popup:#BaseMapViewPopup?after=additions">
<menu
icon="icons/elcl16/error_display.gif"
label="Display type">
<command
commandId="com.kelman.basemap.ui.command.option1"
label="Option 1"
style="radio">
<parameter
name="com.kelman.basemap.ui.command.parameter.option1"
value="OPTION_1">
</parameter>
</command>
<command
commandId="com.kelman.basemap.ui.command.option2"
label="Option 2"
style="radio">
<parameter
name="com.kelman.basemap.ui.command.parameter.option2"
value="OPTION_2">
</parameter>
</command>
</menu>
</menuContribution>
All other (plain) items do show up in the menu.
Any ideas what I am doing wrong?
Thanks,
Alex Molochnikov
Kelman Technologies Inc.
|
|
|
|
|
|
|
Re: Submenu does not show up [message #636797 is a reply to message #636747] |
Tue, 02 November 2010 15:40   |
Eclipse User |
|
|
|
Sorry, but you lost me on this one.
I have a menu contribution where I list a number of items (commands).
The contribution's locationURI is
popup:#BaseMapViewPopup?after=additions. There is a
registerContextMenu() call for this ID in the code.
In the toolbar contribution (which is fairly symmetrical to the popup
menu) I have a command that serves as an anchor point for the pull-down
menu. The command has a unique ID, that is also referenced in another
menu contribution, which lists the submenu items. This part works as
expected.
Now, the context menu needs an anchor point too, otherwise how does the
framework know where to put the submenu in?
Anyway, I did the following:
1. added registerContextMenu() for "#BaseMapViewPopup.displayType" in
the code
2. added the new menu contribution to plugin.xml with locationURI
"popup:#BaseMapViewPopup.displayType?after=additions"
3. populated this contribution with a menu item (ID
#BaseMapViewPopup.displayType1)
4. populated this menu item with commands.
<menuContribution
locationURI="popup:#BaseMapViewPopup.displayType?after=additions ">
<menu
icon="icons/elcl16/error_display.gif"
id="#BaseMapViewPopup.displayType1"
label="Options">
<command
commandId="com.kelman.basemap.ui.command.option1"
label="Option 1"
style="radio">
<parameter
name="com.kelman.basemap.ui.command.parameter.option1"
value="OPTION_1">
</parameter>
</command>
... (more similar commands here)
</menu>
</menuContribution>
No submenu shown anywhere. Which makes sense, because there is nothing
to tell the framework how to stick this in the main context menu.
AM
Paul Webster wrote:
> Alex Molochnikov wrote:
>> In my code I added:
>>
>> site.registerContextMenu("#BaseMapViewPopup.displayType", menuManager,
>> null);
>
> The ID you pass into registerContextMenu(*) has to match the locationURI
> of your menuContribution: ex, for that registerContextMenu(*) you would
> be using popup:#BaseMapViewPopup.displayType?after=additions
>
> Then make sure your <menu/> element in that menu contribution has its
> own unique ID (and not #BaseMapViewPopup.displayType again).
>
> PW
>
|
|
|
|
Re: Submenu does not show up [message #636987 is a reply to message #636945] |
Wed, 03 November 2010 12:40  |
Eclipse User |
|
|
|
Thank you, Paul. Worked fine this time.
AM
Paul Webster wrote:
> Ah, sorry.
>
> Recap: You already have one context menu, #BaseMapViewPopup. You create
> a toolbar contribution with a command+dropdown, and provide a
> menu:tool.item.id to fill in the dropdown menu.
>
> So your question is how could you also contribute that dropdown menus as
> a submenu in your context menu? If so ...
>
> There's no easy way to share them, because they're in different
> namespaces: context menus start with popup: and dropdown menus start
> with menu:.
>
> If I was creating a shared menu like that, I would:
>
> 1) create the first one with menu:tool.item.id
>
> 2) create a copy of #1 with popup:tool.item.id
>
> 3) in my regular context menu contribution, create a submenus with an id
> of "tool.item.id" so that the contribution for #2 will be applied to it.
>
> PW
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.06129 seconds