Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Submenu does not show up
Submenu does not show up [message #636564] Mon, 01 November 2010 21:50 Go to next message
Alex Molochnikov is currently offline Alex MolochnikovFriend
Messages: 25
Registered: July 2009
Junior Member
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 #636673 is a reply to message #636564] Tue, 02 November 2010 12:45 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Alex Molochnikov wrote:

> 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>
>

If you used getSite().registerContextMenu(*) that takes an ID and passed
in #BaseMapViewPopup, this should work.

Anything in your .log when you try and popup the menu?

PW



--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Submenu does not show up [message #636721 is a reply to message #636673] Tue, 02 November 2010 14:41 Go to previous messageGo to next message
Alex Molochnikov is currently offline Alex MolochnikovFriend
Messages: 25
Registered: July 2009
Junior Member
I configured the menuContribution like this:

<command.... /command> (a few command items before the submenu)
<menu
icon="icons/elcl16/error_display.gif"
id="#BaseMapViewPopup.displayType"
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>
</menu>
<command.... /command> (a few command items after the submenu)

In my code I added:

site.registerContextMenu("#BaseMapViewPopup.displayType", menuManager,
null);

Now the command "Option 1" gets added at the top of the context menu,
instead of being in the submenu (and no submenu item in the menu).

No errors in the .log

Thanks.

AM

Paul Webster wrote:
> If you used getSite().registerContextMenu(*) that takes an ID and passed
> in #BaseMapViewPopup, this should work.
>
> Anything in your .log when you try and popup the menu?
>
> PW
>
>
>
Re: Submenu does not show up [message #636730 is a reply to message #636673] Tue, 02 November 2010 15:23 Go to previous messageGo to next message
Alex Molochnikov is currently offline Alex MolochnikovFriend
Messages: 25
Registered: July 2009
Junior Member
I forgot to mention: this is Eclipse 3.6.1, the same behavior on Win XP
and Linux 64 bit (GTK).

AM
Re: Submenu does not show up [message #636747 is a reply to message #636721] Tue, 02 November 2010 16:21 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

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

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Submenu does not show up [message #636797 is a reply to message #636747] Tue, 02 November 2010 19:40 Go to previous messageGo to next message
Alex Molochnikov is currently offline Alex MolochnikovFriend
Messages: 25
Registered: July 2009
Junior Member
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 #636945 is a reply to message #636797] Wed, 03 November 2010 13:24 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

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


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Submenu does not show up [message #636987 is a reply to message #636945] Wed, 03 November 2010 16:40 Go to previous message
Alex Molochnikov is currently offline Alex MolochnikovFriend
Messages: 25
Registered: July 2009
Junior Member
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
>
>
Previous Topic:Eclipse SDK for "hpux.motif.ia64" 64 bit
Next Topic:Content Assist displayed as tree in separate view
Goto Forum:
  


Current Time: Fri Mar 29 04:49:18 GMT 2024

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

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

Back to the top