Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Drop down menu for view using contributions
Drop down menu for view using contributions [message #1404136] Tue, 29 July 2014 21:19 Go to next message
Jim Klo is currently offline Jim KloFriend
Messages: 49
Registered: September 2012
Member
I'm trying to add a drop down view menu without have to fallback to the really old action sets..

Following the excellent tutorial here: http://www.vogella.com/tutorials/EclipseCommands/article.html#toolbar__viewtoolbar

I can get it to work as a drop-down menu when attaching to the main window, but can't seem to make it work when trying to attach to a the view itself.

Can anyone advise me as to how to make this work? Thanks!

Here's my plugin.xml

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
   <extension-point id="com.sri.sunflower.fxquery.menus" name="MenuItems" schema="schema/com.sri.sunflower.fxquery.menus.exsd"/>

   <extension
         point="org.eclipse.ui.views">
      <view
            category="com.sri.sunflower.view"
            class="com.sri.sunflower.fxquery.views.QueryViewPart"
            icon="icons/sample.gif"
            id="com.sri.sunflower.fxquery.views.QueryViewPart"
            name="Task Results">
      </view>
   </extension>
   <extension
         point="org.eclipse.ui.commands">
      <command
            id="fxquery.displayLabels"
            name="Display Labels">
      </command>
      <command
            defaultHandler="com.sri.sunflower.fxquery.handlers.DisplayLabelsHandler"
            id="referenceToOptionsMenu"
            name="referenceToOptionsMenu">
      </command>
   </extension>
   <extension
         point="org.eclipse.ui.handlers">
      <handler
            class="com.sri.sunflower.fxquery.handlers.DisplayLabelsHandler"
            commandId="fxquery.displayLabels">
      </handler>
   </extension>
   <extension
         point="org.eclipse.ui.menus">
      <menuContribution
            allPopups="false"
            locationURI="toolbar:com.sri.sunflower.fxquery.views.QueryViewPart">
         <command
               commandId="fxquery.displayLabels"
               icon="icons/sample.gif"
               label="Display Labels"
               style="radio">
         </command>
         <toolbar
               id="com.sri.sunflower.fxquery.toolbar1">
            <command
                  commandId="referenceToOptionsMenu"
                  icon="icons/sample.gif"
                  label="Pulldown Menu"
                  style="pulldown">
            </command>
         </toolbar>
      </menuContribution>
      <menuContribution
            allPopups="false"
            locationURI="menu:referenceToOptionsMenu">
         <command
               commandId="fxquery.displayLabels"
               icon="icons/sample.gif"
               label="Display Labels"
               style="push">
         </command>
      </menuContribution>
   </extension>
</plugin>
Re: Drop down menu for view using contributions [message #1404137 is a reply to message #1404136] Tue, 29 July 2014 21:32 Go to previous message
Jim Klo is currently offline Jim KloFriend
Messages: 49
Registered: September 2012
Member
Okay, after some additional tinkering. I figured it out...

Turns out that to make a pull-down menu on a view toolbar, I need to add the reference into the view toolbar itself, not create a new toolbar within the view toolbar.

Here's the relevant modification to the plugin.xml
   <extension
         point="org.eclipse.ui.menus">
      <menuContribution
            allPopups="false"
            locationURI="toolbar:com.sri.sunflower.fxquery.views.QueryViewPart">
         <command
               commandId="referenceToOptionsMenu"
               icon="icons/sample.gif"
               label="Pulldown Menu"
               style="pulldown">
         </command>
      </menuContribution>
      <menuContribution
            allPopups="false"
            locationURI="menu:referenceToOptionsMenu">
         <command
               commandId="fxquery.displayLabels"
               icon="icons/sample.gif"
               label="Display Labels"
               style="toggle">
         </command>
      </menuContribution>
   </extension>
Previous Topic:How can I get the SourceViewer by a known StyledText?
Next Topic:How to create ICO for branding
Goto Forum:
  


Current Time: Fri Apr 19 13:11:18 GMT 2024

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

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

Back to the top