public Object execute(ExecutionEvent event) throws ExecutionException { System.out.println(event.getParameter("commandParameterID")); return null; }
@Override public final void run(final IAction action) { try { execute(new ExecutionEvent()); } catch (final ExecutionException e) { // TODO Do something meaningful and poignant. } }
@Override public Object execute(ExecutionEvent event) throws ExecutionException { IEvaluationContext context = (IEvaluationContext) event.getApplicationContext(); IWorkbench workbench = (IWorkbench) context.getVariable(IWorkbench.class.getName()); if (TRUE.equals(event.getParameter(COMMAND_PARAMETER_ID_MAY_PROMPT))) { workbench.getDisplay().close(); } else { workbench.close(); } return null; } }
@Override public Object execute(ExecutionEvent event) throws ExecutionException { String title = event.getParameter(PARAM_ID_TITLE); String message = event.getParameter(PARAM_ID_MESSAGE); if (event.getParameter(PARAM_ID_IMAGE_TYPE) != null) { Integer imageTypeInteger = (Integer) event .getObjectParameterForExecution(PARAM_ID_IMAGE_TYPE); imageType = imageTypeInteger.intValue(); if (event.getParameter(PARAM_ID_DEFAULT_INDEX) != null) { Integer defaultValueInteger = (Integer) event .getObjectParameterForExecution(PARAM_ID_DEFAULT_INDEX); defaultValue = defaultValueInteger.intValue(); String cancelReturns = event.getParameter(PARAM_ID_CANCEL_RETURNS); if (cancelReturns != null) return cancelReturns;
public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchPart activePart = HandlerUtil.getActivePart(event); if (activePart != null) { String commandID = event.getCommand().getId(); ResourceType resourceType = ResourceType.getFromEnum(event.getParameter("de.anbos.eclipse.easyshell.plugin.commands.parameter.resource")); CommandType commandType = CommandType.getFromAction(event.getParameter("de.anbos.eclipse.easyshell.plugin.commands.parameter.type")); String commandValue = event.getParameter("de.anbos.eclipse.easyshell.plugin.commands.parameter.value"); String commandWorkingDir = event.getParameter("de.anbos.eclipse.easyshell.plugin.commands.parameter.workingdir"); CommandTokenizer commandTokenizer = CommandTokenizer.getFromEnum(event.getParameter("de.anbos.eclipse.easyshell.plugin.commands.parameter.tokenizer")); ActionDelegate action = EditorPropertyTester.getActionExactResourceType(activePart, resourceType); if (action != null) { action.setResourceType(resourceType); action.setCommandType(commandType); action.setCommandValue(commandValue); action.setCommandWorkingDir(commandWorkingDir); action.setCommandTokenizer(commandTokenizer); Action act = new Action(commandID); action.run((IAction)act); } action = null; } else { Activator.logError("HandlerUtil.getActivePart() returns null: see Eclipse platform bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=242246", null); } return null; } }
/** * Extract the variable. * * @param event * The execution event that contains the application context * @param name * The variable name to extract. * @return The object from the application context, or <code>null</code> * if it could not be found. */ public static Object getVariable(ExecutionEvent event, String name) { if (event.getApplicationContext() instanceof IEvaluationContext) { Object var = ((IEvaluationContext) event.getApplicationContext()).getVariable(name); return var == IEvaluationContext.UNDEFINED_VARIABLE ? null : var; } return null; }
private static void incorrectTypeFound(ExecutionEvent event, String name, Class expectedType, Class wrongType) throws ExecutionException { throw new ExecutionException("Incorrect type for " //$NON-NLS-1$ + name + " found while executing " //$NON-NLS-1$ + event.getCommand().getId() + ", expected " + expectedType.getName() //$NON-NLS-1$ + " found " + wrongType.getName()); //$NON-NLS-1$ }
@Override public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window= JavaPlugin.getActiveWorkbenchWindow(); if (window == null) return null; IJavaElement javaElement= (IJavaElement) event.getObjectParameterForExecution(PARAM_ID_ELEMENT_REF); OpenTypeHierarchyUtil.open(javaElement, window); return null; } }
final IAction action = getAction(); if (loadDelegate() && (action != null)) { final Object trigger = event.getTrigger(); final Object applicationContext = event.getApplicationContext(); if (applicationContext instanceof IEvaluationContext) { final IEvaluationContext context = (IEvaluationContext) applicationContext;
/** * Check if an event is duplicate, by recording and comparing the time of * the trigger event. Returns true if an event is triggered twice with an * event with the same time */ boolean checkDuplicatedEvent(ExecutionEvent event) { if (event != null && event.getTrigger() != null && event.getTrigger() instanceof Event) { int time = ((Event) event.getTrigger()).time; if (time == timeLastEvent) { return true; } timeLastEvent = time; } return false; }
@Override public Object execute(ExecutionEvent event) throws ExecutionException { IEclipseContext executionContext = getExecutionContext(event.getApplicationContext()); if (executionContext == null) { throw new ExecutionException(FAILED_TO_FIND_HANDLER_DURING_EXECUTION, staticContext = localStaticContext = EclipseContextFactory .create(HandlerServiceImpl.TMP_STATIC_CONTEXT); staticContext.set(HandlerServiceImpl.PARM_MAP, event.getParameters());
/** * Checks whether the radio state of the command is same as the radio state * parameter's value * * @param event * The execution event that contains the application context * @return <code>true</code> whe the values are same, <code>false</code> * otherwise * * @throws ExecutionException * When the command doesn't have the radio state or the event * doesn't have the radio state parameter * @since 3.5 */ public static boolean matchesRadioState(ExecutionEvent event) throws ExecutionException { String parameter = event.getParameter(RadioState.PARAMETER_ID); if (parameter == null) throw new ExecutionException( "The event does not have the radio state parameter"); //$NON-NLS-1$ Command command = event.getCommand(); State state = command.getState(RadioState.STATE_ID); if (state == null) throw new ExecutionException("The command does not have a radio state"); //$NON-NLS-1$ if (!(state.getValue() instanceof String)) throw new ExecutionException("The command's radio state doesn't contain a String value"); //$NON-NLS-1$ return parameter.equals(state.getValue()); }
final List files = new ArrayList(); if (event.getParameter(PARAM_ID_FILE_PATH) == null) { .getObjectParameterForExecution(PARAM_ID_FILE_PATH); if (!(resource instanceof IFile)) { throw new ExecutionException(
/** * Creates {@link ExecutionEvent} based on current selection * * @return {@link ExecutionEvent} with current selection */ protected ExecutionEvent createExecutionEvent() { IServiceLocator locator = getServiceLocator(); ICommandService srv = (ICommandService) locator .getService(ICommandService.class); IHandlerService hsrv = (IHandlerService) locator .getService(IHandlerService.class); Command command = srv.getCommand(commandId); ExecutionEvent event = hsrv.createExecutionEvent(command, null); if (event.getApplicationContext() instanceof IEvaluationContext) ((IEvaluationContext) event.getApplicationContext()).addVariable( ISources.ACTIVE_CURRENT_SELECTION_NAME, mySelection); return event; }
private static void noVariableFound(ExecutionEvent event, String name) throws ExecutionException { throw new ExecutionException("No " + name //$NON-NLS-1$ + " found while executing " + event.getCommand().getId()); //$NON-NLS-1$ }
@Override public Object execute(ExecutionEvent event) throws ExecutionException { IJavaElement javaElement= (IJavaElement) event.getObjectParameterForExecution(PARAM_ID_ELEMENT_REF); PackageExplorerPart view= PackageExplorerPart.openInActivePerspective(); view.tryToReveal(javaElement); return null; }
public Object execute(ExecutionEvent event) throws ExecutionException { Event ev = (Event) event.getTrigger(); run(ev.display.getActiveShell()); return null; }
private String[] collectButtonLabels(ExecutionEvent event) { ArrayList<String> buttonLabelList = new ArrayList<>(); for (int i = 0; i < BUTTON_LABEL_COUNT; i++) { String buttonLabelParamId = PARAM_ID_BUTTON_LABEL_PREFIX + Integer.toString(i); String buttonLabel = event.getParameter(buttonLabelParamId); if (buttonLabel == null) { break; } buttonLabelList.add(buttonLabel); } return buttonLabelList.toArray(new String[buttonLabelList .size()]); }
/** * This simply calls execute with a <code>null</code> map of parameter * values. If an <code>ExecutionException</code> occurs, then this should * be handle somehow. It's not clear what we'll do yet. * * @param action * The action proxy that handles the presentation portion of the * action * @see org.eclipse.ui.IActionDelegate#run(IAction) */ @Override public void run(final IAction action) { try { execute(new ExecutionEvent()); } catch (final ExecutionException e) { // TODO Do something meaningful and poignant. } }
CommonNavigator navigator = (CommonNavigator)part; boolean previousNest = navigator.getNavigatorContentService().getActivationService().isNavigatorExtensionActive(NestedProjectsContentProvider.EXTENSION_ID); String newNestParam = event.getParameter(ProjectPresentationHandler.NEST_PARAMETER); boolean newNest = false; if (newNestParam != null) { HandlerUtil.updateRadioState(event.getCommand(), Boolean.toString(newNest));