Adding options to context menu dynamically [message #826713] |
Thu, 22 March 2012 08:11  |
Eclipse User |
|
|
|
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  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.06418 seconds