/* * (non-Javadoc) * * @see * org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer#hookControllerLogic * (org.eclipse.e4.ui.model.application.MUIElement) */ @Override public void hookControllerLogic(MUIElement me) { // If the item is a CHECK or RADIO update the model's state to match super.hookControllerLogic(me); // 'Execute' the operation if possible if (me instanceof MHandledItem) { final MHandledItem item = (MHandledItem) me; final IEclipseContext lclContext = getContext(me); MenuItem mi = (MenuItem) me.getWidget(); mi.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { EHandlerService service = (EHandlerService) lclContext.get(EHandlerService.class.getName()); ParameterizedCommand cmd = item.getWbCommand(); if (cmd == null) { return; } final IEclipseContext staticContext = EclipseContextFactory.create(HMI_STATIC_CONTEXT); if (e != null) { staticContext.set(Event.class, e); } ContributionsAnalyzer.populateModelInterfaces( item, staticContext, item.getClass().getInterfaces()); try { service.executeHandler(cmd, staticContext); } finally { staticContext.dispose(); } } }); } }