Bug 315907 Render menus on SWT.Show
bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/modeling/MenuService.java
public MPopupMenu registerContextMenu(Menu menu, String menuId) {
		for (MMenu mmenu : myPart.getMenus()) {
			if (menuId.equals(mmenu.getElementId())
					&& mmenu instanceof MPopupMenu) {
				if (registerMenu(menu, (MPopupMenu) mmenu)) {
					return (MPopupMenu) mmenu;
				} else {
					return null;
				}
			}
		}
		return null;
	}
	private boolean registerMenu(Menu menu, MPopupMenu mmenu) {
		if (mmenu.getWidget() != null) {
			return false;
		}
		mmenu.setWidget(menu);
		IEclipseContext popupContext = myPart.getContext().createChild(
				"popup:" + mmenu.getElementId());
		mmenu.setContext(popupContext);
		ContextMenuListener listener = new ContextMenuListener(renderer, mmenu,
				myPart, application);
		menu.addListener(SWT.Show, listener);
		menu.addListener(SWT.Hide, listener);
		menu.addListener(SWT.Dispose, listener);
		return true;
	}
}