Bug 261852 [context] Separate code into API / SPI / internal
bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/workbench/ui/renderers/swt/SWTPartFactory.java
createMenu(newMenuItem, handledItem.getMenu());
		}
		if (handledItem.getCommand() != null) {
			final ISelectionService selectionService = (ISelectionService) context
					.get(ISelectionService.class.getName());
			newMenuItem.addListener(SWT.Selection, new Listener() {
				public void handleEvent(Event event) {
					Object result = canExecuteItem(context, newMenuItem
							.getDisplay(), handledItem, selectionService);
					if (Boolean.TRUE.equals(result)) {
						executeItem(context, newMenuItem.getDisplay(),
								handledItem, selectionService);
					}
				}
			});
			parentMenu.addListener(SWT.Show, new Listener() {
				public void handleEvent(Event event) {
					if (newMenuItem.isDisposed()) {
						return;
					}
					Object result = canExecuteItem(context, newMenuItem
							.getDisplay(), handledItem, selectionService);
					((MenuItem) newMenuItem).setEnabled(Boolean.TRUE
							.equals(result));
				}
			});
		}
	}
}