private void executeSerializedCommand() { try { ICommandService commandService = getCommandService(); IHandlerService handlerService = getHandlerService(); ParameterizedCommand command = commandService.deserialize(serializedCommand); command.executeWithChecks(null, handlerService.getCurrentState()); } catch (CommandException ex) { HelpUIPlugin.logError("There was an error executing the command: " + serializedCommand, ex); //$NON-NLS-1$ } }
@Override public Object executeHandler(ParameterizedCommand command, IEclipseContext staticContext) { final IEclipseContext executionContext = getExecutionContext(); addParms(command, staticContext); // executionContext.set(STATIC_CONTEXT, staticContext); push(executionContext, staticContext); try { // Command cmd = command.getCommand(); return command.executeWithChecks(staticContext.get(SWT_TRIGGER), new ExpressionContext( peek().context)); } catch (ExecutionException e) { staticContext.set(HANDLER_EXCEPTION, e); } catch (NotDefinedException e) { staticContext.set(HANDLER_EXCEPTION, e); } catch (NotEnabledException e) { staticContext.set(HANDLER_EXCEPTION, e); } catch (NotHandledException e) { staticContext.set(HANDLER_EXCEPTION, e); } finally { pop(); // executionContext.remove(STATIC_CONTEXT); } return null; }
@Override public void runWithEvent(Event event) { if (partHandler != null && getParameterizedCommand() != null) { IHandler oldHandler = getParameterizedCommand().getCommand() .getHandler(); try { getParameterizedCommand().getCommand().setHandler(partHandler); getParameterizedCommand().executeWithChecks(event, appContext); } catch (ExecutionException e) { // TODO some logging, perhaps? } catch (NotDefinedException e) { // TODO some logging, perhaps? } catch (NotEnabledException e) { // TODO some logging, perhaps? } catch (NotHandledException e) { // TODO some logging, perhaps? } finally { getParameterizedCommand().getCommand().setHandler(oldHandler); } } else { super.runWithEvent(event); } }