Step 1) Create a Menu as a child of the Part with the Model Editor
Step 2) Edit the e4xmi directly and change the xsi:txpe from "menu:Menu" to "menu:PopupMenu"
Step 3) Hook the Menu to the control with EMenuService.registerContextMenu
That works great.
At the moment I am also using a MenuDetectListener on an SWT-Tree to switch the popup menu depending on the current selection. That works too, but raised the issue in question "re-using menu definitions".
Thanks for your reply on "Snippets". Is the usage of Menu, Toolbar and Trim Contributions similar to this approach? => Use a processor to copy the MMenuElements in a MenuContribution into all the places the menu should be available (i.e. as a View-Menu and as a Popup-Menu)?
Paul Webster Messages: 6833 Registered: July 2009 Location: Ottawa
Each MMenu or MMenuItem can only have one parent, so there must be a separate instance in each menu that you need.
MMenuContributions contain menu templates that can be added to regular menus and popup menus. They follow the same convention for specifying where to apply the template as the org.eclipse.ui.menus/menuContribution does.