Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How to call a handler from a popup menu or generate an ExecutionEvent?
How to call a handler from a popup menu or generate an ExecutionEvent? [message #735352] Tue, 11 October 2011 15:17 Go to next message
Neslepaks  is currently offline Neslepaks Friend
Messages: 37
Registered: April 2011
Member
Hi,

I am not sure if this is the right forum but let's try.

I have implemented some functionality that is executed from top menu bar. These actions are triggered by handlers. For example, this is the way I have defined the actions in plugin.xml and they are working nicely:

  <extension
         point="org.eclipse.ui.handlers">
      <handler
            commandId="org.eclipse.papyrus.myCommands.myCommand"
            class="org.eclipse.papyrus.myHandlers.myHandler">
      </handler>
   </extension>


I'd like to execute the same functionality from context popup menu, so I created an entry like this:


	<extension point="org.eclipse.ui.popupMenus">
   	   <objectContribution
            adaptable="false"
            id="org.eclipse.papyrus.mymenus.mypopupmenu"
            objectClass="org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeEditPart">
         <menu 
            id="mypopup" 
            label="&amp;My Menu" 
            path="additions"> 
            <separator name="group1"/>
         </menu>
          <action
               class="org.eclipse.papyrus.ossli.myActions.myAction"
               definitionId="org.eclipse.papyrus.myCommands.myCommand"
               enablesFor="1"
               id="org.eclipse.papyrus.ossli.menus.myPopupaction"
               label="&amp;My Action"
               menubarPath="mypopup/group1">
         </action>
      </objectContribution>        
	</extension>


This works fine and the runWithEvent-method from myAction is executed. myAction implements IActionDelegate2.



1. Is there a way to execute a handler straight from popupMenu extension point?

2. If not. How can I generate an ExecutionEvent needed by the myHandler's (implements AbstactHandler) execute-method as a parameter?

I am using Papyrus if it matters.

[Updated on: Tue, 11 October 2011 15:20]

Report message to a moderator

Re: How to call a handler from a popup menu or generate an ExecutionEvent? [message #735577 is a reply to message #735352] Wed, 12 October 2011 09:27 Go to previous messageGo to next message
Neslepaks  is currently offline Neslepaks Friend
Messages: 37
Registered: April 2011
Member
I managed to do the second approach. ExecutionEvent's constructor just wants some parameters that are not important for the functionality, so I made a map of temporary parameters and passed them there.
Re: How to call a handler from a popup menu or generate an ExecutionEvent? [message #741531 is a reply to message #735577] Wed, 19 October 2011 16:11 Go to previous message
Craig Foote is currently offline Craig FooteFriend
Messages: 195
Registered: July 2009
Senior Member
You could also use the "menus" extension point rather than "popupMenus", referencing your command id.
Previous Topic:common navigator framework: adding popup menu entry under New Submenu
Next Topic:Hide menus thr' activities/perspectiveExtensions not working
Goto Forum:
  


Current Time: Wed Nov 26 05:59:02 GMT 2014

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

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