Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Adding options to context menu dynamically
Adding options to context menu dynamically [message #826713] Thu, 22 March 2012 08:11 Go to next message
ganesh ram is currently offline ganesh ram
Messages: 26
Registered: January 2012
Junior Member
Hi,

How to add options to context menu dynamically ?
for eg. if i right click on a particular node on my GMF diagram, i want to add the list of operations to the context menu ?

Currently, i do that statically using the extension point, but now, want to do that dynamically.

Pls help

-Ganesh
Re: Adding options to context menu dynamically [message #831912 is a reply to message #826713] Thu, 29 March 2012 10:16 Go to previous message
Ralph Gerbig is currently offline Ralph Gerbig
Messages: 697
Registered: November 2009
Senior Member
Hi Ganesh,

this is a bit off topic. However this is not that complicated. You need to use the org.eclipse.ui.menus extension point. Here you can use the dynamic thing for your menu. This you need to connect with a contribution item which looks like this:

public class xxxxContributionItem extends CompoundContributionItem {
	
 @Override
 protected IContributionItem[] getContributionItems() {
   //define an array
   CommandContributionItemParameter param = new CommandContributionItemParameter(PlatformUI.getWorkbench().getActiveWorkbenchWindow(), XYCommand.ID + ".menuEntry", XYCommand.ID, CommandContributionItem.STYLE_PUSH);
   param.label = "XY";
			
   commandParamametersMap = new HashMap<String, Object>();
			
   commandParamametersMap.put("x",  x);
		
   param.parameters = commandParamametersMap;
   
   //Add contribution item to list
   CommandContributionItem cItem = new CommandContributionItem(param)  
 }
}


If you want to use parameters you need to look into the org.eclipse.ui extension point exspecially into the commandParameterType element.

Ralph
Previous Topic:Options in GMF Wizard
Next Topic:class containing attributes on the diagram as in UML
Goto Forum:
  


Current Time: Thu Jul 24 11:38:04 EDT 2014

Powered by FUDForum. Page generated in 0.01563 seconds