Command command = ((ICommandService)getSite().getService(ICommandService.class)).getCommand(commandId); ... final Event trigger = new Event(); ExecutionEvent executionEvent = ((IHandlerService)getSite().getService(IHandlerService.class)).createExecutionEvent(command, trigger); command.executeWithChecks(executionEvent);
IServiceLocator serviceLocator = PlatformUI.getWorkbench(); ICommandService commandService = (ICommandService) serviceLocator.getService(ICommandService.class); try { Command command = commandService.getCommand("my_command_id"); Map<String, String> map = new HashMap<String, String>(); map.put("param_name", "param_value"); /*more parameter's can be added to Map and passed*/ command.executeWithChecks(new ExecutionEvent(null, map, null, null)); } catch (ExecutionException e1) { } catch (NotDefinedException e2){ } catch(NotEnabledException e3){ } catch(NotHandledException e4){ }
IServiceLocator serviceLocator = PlatformUI.getWorkbench(); ICommandService commandService = (ICommandService) serviceLocator.getService(ICommandService.class); try { Command command = commandService.getCommand("de.xx.mycommand"); command.executeWithChecks(new ExecutionEvent()); } catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException e) { e.printStackTrace(); }
/** * Executes this command with its parameters. This does extra checking to * see if the command is enabled and defined. If it is not both enabled and * defined, then the execution listeners will be notified and an exception * thrown. * * @param trigger * The object that triggered the execution; may be * <code>null</code>. * @param applicationContext * The state of the application at the time the execution was * triggered; may be <code>null</code>. * @return The result of the execution; may be <code>null</code>. * @throws ExecutionException * If the handler has problems executing this command. * @throws NotDefinedException * If the command you are trying to execute is not defined. * @throws NotEnabledException * If the command you are trying to execute is not enabled. * @throws NotHandledException * If there is no handler. * @since 3.2 */ public final Object executeWithChecks(final Object trigger, final Object applicationContext) throws ExecutionException, NotDefinedException, NotEnabledException, NotHandledException { return command.executeWithChecks(new ExecutionEvent(command, getParameterMap(), trigger, applicationContext)); }
/** * Executes this command with its parameters. This does extra checking to * see if the command is enabled and defined. If it is not both enabled and * defined, then the execution listeners will be notified and an exception * thrown. * * @param trigger * The object that triggered the execution; may be * <code>null</code>. * @param applicationContext * The state of the application at the time the execution was * triggered; may be <code>null</code>. * @return The result of the execution; may be <code>null</code>. * @throws ExecutionException * If the handler has problems executing this command. * @throws NotDefinedException * If the command you are trying to execute is not defined. * @throws NotEnabledException * If the command you are trying to execute is not enabled. * @throws NotHandledException * If there is no handler. * @since 3.2 */ public Object executeWithChecks(final Object trigger, final Object applicationContext) throws ExecutionException, NotDefinedException, NotEnabledException, NotHandledException { return command.executeWithChecks(new ExecutionEvent(command, getParameterMap(), trigger, applicationContext)); }
/** * Executes this command with its parameters. This does extra checking to * see if the command is enabled and defined. If it is not both enabled and * defined, then the execution listeners will be notified and an exception * thrown. * * @param trigger * The object that triggered the execution; may be * <code>null</code>. * @param applicationContext * The state of the application at the time the execution was * triggered; may be <code>null</code>. * @return The result of the execution; may be <code>null</code>. * @throws ExecutionException * If the handler has problems executing this command. * @throws NotDefinedException * If the command you are trying to execute is not defined. * @throws NotEnabledException * If the command you are trying to execute is not enabled. * @throws NotHandledException * If there is no handler. * @since 3.2 */ public final Object executeWithChecks(final Object trigger, final Object applicationContext) throws ExecutionException, NotDefinedException, NotEnabledException, NotHandledException { return command.executeWithChecks(new ExecutionEvent(command, getParameterMap(), trigger, applicationContext)); }
/** * Executes the search. */ private void executeSearch() { String searchString = searchText.getText(); if (StringUtils.isNotBlank(searchString)) { ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class); IEvaluationService evaluationService = (IEvaluationService) PlatformUI.getWorkbench().getService(IEvaluationService.class); try { Command searchCommand = commandService.getCommand("rocks.inspectit.ui.rcp.commands.searchDocumentation"); Map<String, String> params = new HashMap<>(); params.put(SearchDocumentationHandler.SEARCH_DOCUMENTATION_PARAMETER, searchString); searchCommand.executeWithChecks(new ExecutionEvent(searchCommand, params, searchText, evaluationService.getCurrentState())); } catch (Exception e) { InspectIT.getDefault().createErrorDialog("There was an exception executing the wiki search.", e, -1); } } } }
/** * {@inheritDoc} */ @Override public void doubleClick(DoubleClickEvent event) { StructuredSelection selection = (StructuredSelection) event.getSelection(); if ((selection.size() == 1) && (selection.getFirstElement() instanceof ISpanIdentAware)) { // open trace details view IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class); ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class); Command command = commandService.getCommand(OpenTraceDetailsHandler.COMMAND); ExecutionEvent executionEvent = handlerService.createExecutionEvent(command, new Event()); try { command.executeWithChecks(executionEvent); } catch (Exception e) { throw new RuntimeException(e); } } }
context.addVariable(ExceptionSupportHandler.INPUT, throwable); command.executeWithChecks(executionEvent); } catch (Exception exception) { throw new RuntimeException(exception);
/** * {@inheritDoc} */ @Override public void doubleClick(DoubleClickEvent event) { StructuredSelection selection = (StructuredSelection) event.getSelection(); if (!selection.isEmpty()) { Object clickedObject = selection.getFirstElement(); if (clickedObject instanceof Span) { if (((Span) clickedObject).getPropagationType() == null) { // Span is SDK span return; } } else if (clickedObject instanceof SpanIdent) { return; } // open trace details view IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class); ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class); Command command = commandService.getCommand(LocateHandler.COMMAND); ExecutionEvent executionEvent = handlerService.createExecutionEvent(command, new Event()); try { command.executeWithChecks(executionEvent); } catch (Exception e) { throw new RuntimeException(e); } } }
@Override protected void handleDoubleClick(DoubleClickEvent anEvent) { ICommandService commandService = getViewSite().getService(ICommandService.class); Command openProjectCommand = commandService.getCommand(IWorkbenchCommandConstants.PROJECT_OPEN_PROJECT); if (openProjectCommand != null && openProjectCommand.isHandled() && openProjectCommand.isEnabled()) { IStructuredSelection selection = (IStructuredSelection) anEvent .getSelection(); Object element = selection.getFirstElement(); if (element instanceof IProject && !((IProject) element).isOpen()) { try { openProjectCommand.executeWithChecks(new ExecutionEvent()); } catch (CommandException ex) { IStatus status = WorkbenchNavigatorPlugin.createErrorStatus("'Open Project' failed", ex); //$NON-NLS-1$ WorkbenchNavigatorPlugin.getDefault().getLog().log(status); } return; } } super.handleDoubleClick(anEvent); }
public final Object execute(ExecutionEvent event) throws ExecutionException { if (!shouldRunAction()) return null; ICommandService srv = (ICommandService) getServiceLocator() .getService(ICommandService.class); Command command = srv.getCommand(commandId); try { return command.executeWithChecks(event); } catch (ExecutionException e) { Activator.handleError(e.getMessage(), e, true); } catch (NotDefinedException e) { Activator.handleError(e.getMessage(), e, true); } catch (NotEnabledException e) { Activator.handleError(e.getMessage(), e, true); } catch (NotHandledException e) { Activator.handleError(e.getMessage(), e, true); } return null; }
command.executeWithChecks(executionEvent); } catch (NotDefinedException | NotEnabledException | NotHandledException e) { throw new ExecutionException("Error opening the combined invocation data view.", e);
command.executeWithChecks(executionEvent); } catch (NotDefinedException | NotEnabledException | NotHandledException e) { throw new ExecutionException("Error opening the exception type view.", e);
command.executeWithChecks(executionEvent); } catch (Exception e) { throw new RuntimeException(e);
command.executeWithChecks(executionEvent); } catch (NotDefinedException | NotEnabledException | NotHandledException e) { throw new ExecutionException("Error opening the trace details view.", e);
command.executeWithChecks(executionEvent); } catch (Exception e) { InspectIT.getDefault().createErrorDialog(e.getMessage(), e, -1);
command.executeWithChecks(executionEvent); } catch (NotDefinedException | NotEnabledException | NotHandledException e) { throw new ExecutionException("Error opening the aggregated SQL data view.", e);
command.executeWithChecks(executionEvent); } catch (NotDefinedException | NotEnabledException | NotHandledException e) { throw new ExecutionException("Error opening the invocation data view.", e);
command.executeWithChecks(executionEvent); } catch (NotDefinedException | NotEnabledException | NotHandledException e) { throw new ExecutionException("Error opening the aggregated timer data view.", e);