show up dynamic (part) menu [message #635367] |
Tue, 26 October 2010 11:05  |
Eclipse User |
|
|
|
Hello,
I want to implement a popup menu for a JFace TreeViewer that is
contained in a view part represented in the model.
The popup menu should (as usual) be different depending on the
selection. I found a snippet where that is implementetdoing in this way:
MenuManager manager = new MenuManager();
manager.setRemoveAllWhenShown(true);
manager.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(final IMenuManager currentManager) {
IStructuredSelection selection =
(IStructuredSelection) treeViewer.getSelection();
if (!selection.isEmpty())
currentManager.add(someAction);
...
}
}
});
treeViewer.getControl().setMenu(manager.createContextMenu(tr eeViewer.getControl()));
---
Now I thought about introducing the menu to the workbench model.
It is possible to add menus to parts or create menu contributions via
the model editor.
So what is the proper way to (combine and) show them up in this case?
Thanks,
Jens
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.14415 seconds