Contextual Menu visibility [message #516943] |
Thu, 25 February 2010 15:03 |
Juan Lagostena Messages: 4 Registered: November 2009 |
Junior Member |
|
|
Hi everyone,
I have some problems with a contextual menu, maybe you can help me. I have a tree view where the context menu is hooked. This context menu is a kind of hybrid, because some contributions are made by "old school" actions , and the others are commands defined in the plugin.xml. I have a method to fill the context menu, and there, depending on the selection, the menu has to be shown or not. Let's see a piece of code:
@Override
public void createPartControl(Composite parent) {
(...)
this.hookContextMenu();
(...)
}
private void hookContextMenu() {
MenuManager menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
TreeNavigator.this.fillContextMenu(manager);
}
});
Menu menu = menuMgr.createContextMenu(viewer.getControl());
viewer.getControl().setMenu(menu);
getSite().registerContextMenu(menuMgr, viewer);
}
@SuppressWarnings("unchecked")
private void fillContextMenu(IMenuManager manager) {
(contribute with the "old school" actions")
}
I'm trying with a hack in the fill context menu, checking the decision there, and calling setVisible(false) to the manager, but the result is avoiding contribute the "actions" , but the commands are still there, and the menu is shown.
This kind of of hybrid is the result of an incomplete migration, I know that is not the ideal situation :S .
Any clue will be welcome.
Thanks on advance,
Juan
|
|
|
|
Powered by
FUDForum. Page generated in 0.03042 seconds