[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.platform] JFace, MenuManager, submenu in a popup-menu

I've Googled for this and scoured the web, but either I'm using the wrong search terms or perhaps it's just something that makes me unable to comprehend this.

I'm trying to add a submenu to a popup menu in a TableViewer. The popup-menu works fine, but the submenu never shows. This is the code:

// Sub menu
final MenuManager subMenu = new MenuManager("Branch");
subMenu.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
manager.add(firstSubAction);
manager.add(secondSubAction);
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}
});


// Main Popup menu
final MenuManager popupMenu = new MenuManager("#PopupMenu");
popupMenu.setRemoveAllWhenShown(true);
popupMenu.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
manager.add(firstAction);
manager.add(secondAction);
manager.add(thirdAction);
manager.add(subMenu);
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}
});


     final Menu menu = popupMenu.createContextMenu(viewer.getControl());
     viewer.getControl().setMenu(menu);
     getSite().registerContextMenu(popupMenu, viewer);

I thought this would result in a popup menu with first-, second- and thirdAction and then "Branch" with a submenu containing firstSub- and secondSubAction.

Any help is greatly appreciated.

kind regards,
   martin