Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Dynamic menu contribution doesn't show up in a toolbar
Dynamic menu contribution doesn't show up in a toolbar [message #709974] Thu, 04 August 2011 14:49 Go to next message
Alexey Romanov is currently offline Alexey RomanovFriend
Messages: 263
Registered: May 2010
Senior Member
In my plugin.xml I have
<menuContribution
      allPopups="false"
      locationURI="menu:arm.views.funblocks?after=additions">
      <menu
           icon="icons/fblock.gif"
           id="arm.views.funblocks.create"
           label="%arm.views.funblocks.create">
           <dynamic class="ru.focusmedia.odp.arm.funblocks.navigator.admin.CreateFunBlockContrib"
               id="arm.views.funblocks.create.menuitems">
           </dynamic>
      </menu>
      <command
           commandId="org.eclipse.ui.edit.delete"
           style="push">
      </command>
</menuContribution>

and this works fine. However, if I replace "menu:" with "toolbar:" in locationURI, only the delete command shows up, but not the menu. I've also tried replacing <menu> element with <toolbar>, but with no result. What am I doing wrong?
Re: Dynamic menu contribution doesn't show up in a toolbar [message #710255 is a reply to message #709974] Thu, 04 August 2011 21:16 Go to previous messageGo to next message
Alexey Romanov is currently offline Alexey RomanovFriend
Messages: 263
Registered: May 2010
Senior Member
I was told on StackOverflow that <menu> and <toolbar> can't be contributed to a toolbar. Now I am wondering where a <toolbar> can be contributed.
Re: Dynamic menu contribution doesn't show up in a toolbar [message #710528 is a reply to message #709974] Fri, 05 August 2011 05:41 Go to previous messageGo to next message
Catalin Gerea is currently offline Catalin GereaFriend
Messages: 89
Registered: July 2009
Location: Bucharest, Romania
Member

This works for me:
<menuContribution locationURI="toolbar:org.eclipse.ui.main.toolbar">
    <toolbar id="com.gcsf.books.toolbar.edit">
        ... some contributions here ...
    </toolbar>
    <toolbar id="com.gcsf.books.toolbar.view">
       <dynamic class="com.gcsf.books.contributions.ToolbarPerspectiveSwitcherMenu"
                  id="com.gcsf.books.dynamic.toolbar.perspectiveSwitcherMenu">
       </dynamic>
    </toolbar>
</menuContribution>


The stackoverflow response was correct: the menu and toolbar can't be contributed to a toolbar. But a toolbar can be contributed to a menu contribution.

In your case the <dynamic> has to be directly under <toolbar> (see my example above).
Just read the extension point description for 'org.eclipse.ui.menus' and you will see how this extension point has to be defined.


Time is what you make of it.
Re: Dynamic menu contribution doesn't show up in a toolbar [message #713897 is a reply to message #710528] Tue, 09 August 2011 10:31 Go to previous message
Alexey Romanov is currently offline Alexey RomanovFriend
Messages: 263
Registered: May 2010
Senior Member
Quote:
But a toolbar can be contributed to a menu contribution.

Makes sense, thanks!
Quote:
An example

I did try this, and it didn't work. I now think the problem is that my contribution class inherits from CompoundContributionItem, but if you look at the definition, CompoundContributionItem.fill(Toolbar, int) does nothing. I wonder why it doesn't...
Previous Topic:Adding Menu Items thru Plugin.xml
Next Topic:Detached views to be brought up independently
Goto Forum:
  


Current Time: Thu Apr 25 00:38:13 GMT 2024

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

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

Back to the top