Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Commands and dynamic menu
Commands and dynamic menu [message #1804260] Thu, 21 March 2019 11:38 Go to next message
vlad tsepesh is currently offline vlad tsepeshFriend
Messages: 5
Registered: January 2012
Junior Member
Hi all,

I'm developing an RCP application in which I had to communicate data over a COM port.
I'd like the plugin dedicated to the serial communication had a contribution to the menu in order to select the port to which the data had to be sent.

The plugin declare an extension point to make the contribution
  <extension
         point="org.eclipse.ui.menus">
      <menuContribution
            allPopups="true"
            locationURI="menu:org.eclipse.ui.main.menu">
         <menu
               id="my.rcp.plugin.comportselection"
               label="COM Port">
         </menu>
      </menuContribution>
      <menuContribution
            allPopups="false"
            class="my.rcp.protocol.command.ComPortEnumeration"
            locationURI="menu:my.rcp.plugin.comportselection">
      </menuContribution>
   </extension>


The class my.rcp.protocol.command.ComPortEnumeration is a subclass of org.eclipse.ui.menus.ExtensionContributionFactory for every available COM port it creates an instance of org.eclipse.ui.menus.CommandContributionItemParameter and add to the org.eclipse.ui.services.IServiceLocator via the addContributionItem() method as adapted from an example out there in the web, i.e. a Vogella one.

Unfortunately the result is not what I want, we get an unusable menu because is itself disable.

index.php/fa/35101/0/

The first question is obvious, how do I get the menu enabled?

And the second one: how to connect a command, with the name of the Port as a a parameter, to perform the binding to the selected COM port?

TIA.

  • Attachment: menu.png
    (Size: 1.17KB, Downloaded 388 times)
Re: Commands and dynamic menu [message #1805185 is a reply to message #1804260] Tue, 09 April 2019 13:18 Go to previous message
Eclipse UserFriend
A bit late, but... Commands are bound to (possibly many) handlers. If your entry is disabled it's either because a handler cannot be found or the handler is not enabled.

You can use command parameters to pass along parameters. Your handler will receive an ExecutionEvent object with the parameter map.

Brian.
Previous Topic:References plugin
Next Topic:RCP app widgets styling looks whitewashed in Mac OS Mojave
Goto Forum:
  


Current Time: Thu Mar 28 21:57:35 GMT 2024

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

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

Back to the top