Skip to main content


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 12:11 Go to next message
ganesh ram is currently offline ganesh ramFriend
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 14:16 Go to previous message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
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: Tue Apr 16 12:54:40 GMT 2024

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

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

Back to the top