Command parameters in context menu [message #1008159] |
Mon, 11 February 2013 07:35 |
Jan Kubovy Messages: 1 Registered: February 2013 |
Junior Member |
|
|
Hi,
I have a tree view and I defined a popup menu for the part the treeview is in. Some of the HandledMenuItems are connected to Commands with parameters. I would like to fill such parameters with a value before the command gets executed depending on the selection of the tree. For example with a resource path stored in the selected item of the tree:
TreeItem selected = tree.getSelection()[0];
IResource resource = (IResource) selected.getData();
String resourcePath = resource.getFullPath().toString();
for (MMenuElement element : contextMenu.getChildren()) {
if (!(element instanceof MHandledMenuItem))
continue;
MHandledMenuItem item = (MHandledMenuItem) element;
for (MParameter param : item.getParameters()) {
if (!param.getName().equals("com.example.commandparameter.resource_path"))
continue;
param.setValue(resourcePath);
}
}
The popup menu is defined under the correct part and is poping up. Just the parameter value is always NULL when it gets executed.
Is there a way how to do that?
I searched but I didn't found how to use parametrized commands with popupmenu.
Thanks for any help!
Jan
|
|
|
Powered by
FUDForum. Page generated in 5.03594 seconds