Skip to main content



      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
Eclipse UserFriend
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
Eclipse UserFriend
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: Mon Jul 14 21:43:25 EDT 2025

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

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

Back to the top