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$ }
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$ }
/** * Return the debug context for the given executionEvent. * * @param event The execution event that contains the application context * @return the debug context. Will not return <code>null</code>. * @throws ExecutionException If the current selection variable is not found. * * @since 3.5 */ public static ISelection getDebugContextForEventChecked(ExecutionEvent event) throws ExecutionException { Object o = HandlerUtil.getVariableChecked(event, IConfigurationElementConstants.DEBUG_CONTEXT); if (!(o instanceof ISelection)) { throw new ExecutionException("Incorrect type for " //$NON-NLS-1$ + IConfigurationElementConstants.DEBUG_CONTEXT + " found while executing " //$NON-NLS-1$ + event.getCommand().getId() + ", expected " + ISelection.class.getName() //$NON-NLS-1$ + " found " + o.getClass().getName()); //$NON-NLS-1$ } return (ISelection) o; }
@Override public Object execute(ExecutionEvent event) throws ExecutionException { if (event.getCommand().getId().equals(IWorkbenchCommandConstants.NAVIGATE_NEXT_PAGE)) { gotoDirection = true; } else { gotoDirection = false; } super.execute(event); if (lrm != null) { lrm.dispose(); lrm = null; } return null; }
public Object execute(ExecutionEvent event) throws ExecutionException { HandlerUtil.toggleCommandState(event.getCommand()); IWorkbenchPart part = HandlerUtil.getActivePartChecked(event); if (part instanceof RepositoriesView) { CommonViewer viewer = ((RepositoriesView) part).getCommonViewer(); viewer.refresh(); } return null; } }
/** * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) */ public Object execute(ExecutionEvent event) throws ExecutionException { HandlerUtil.toggleCommandState(event.getCommand()); IWorkbenchPart part = HandlerUtil.getActivePartChecked(event); if (part instanceof RepositoriesView) (((RepositoriesView) part).getCommonViewer()).refresh(); return null; }
public Object execute(final ExecutionEvent event) throws ExecutionException { Command command = event.getCommand(); HandlerUtil.toggleCommandState(command); @SuppressWarnings("boxing") boolean test = (Boolean) command.getState(RegistryToggleState.STATE_ID).getValue(); getView(event).setReactOnSelection(test); return null; } }
String logMsgPrefix; try { logMsgPrefix = event.getCommand().getName() + ": "; //$NON-NLS-1$ } catch (NotDefinedException e1) { logMsgPrefix = event.getCommand().getId() + ": "; //$NON-NLS-1$
if (coolBarManager != null) { boolean lock = !HandlerUtil.toggleCommandState(event.getCommand()); final List<MToolBar> children = modelService.findElements(winModel, null, MToolBar.class); for (MToolBar el : children) {
/** * {@inheritDoc} */ @Override public Object execute(ExecutionEvent event) throws ExecutionException { IEditorPart editorPart = HandlerUtil.getActiveEditor(event); if (editorPart instanceof AbstractRootEditor) { AbstractRootEditor abstractRootEditor = (AbstractRootEditor) editorPart; if (abstractRootEditor.canMaximizeActiveSubView()) { abstractRootEditor.maximizeActiveSubView(); } else if (abstractRootEditor.canMinimizeActiveSubView()) { abstractRootEditor.minimizeActiveSubView(); } } // after the maximized/minimized is executed we need to refresh the UI elements bounded to // the command, so that checked state of that elements is updated ICommandService commandService = (ICommandService) HandlerUtil.getActiveWorkbenchWindow(event).getService(ICommandService.class); Map<Object, Object> filter = new HashMap<>(); filter.put(IServiceScopes.WINDOW_SCOPE, HandlerUtil.getActiveWorkbenchWindow(event)); commandService.refreshElements(event.getCommand().getId(), filter); return null; }
/** * 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()); }
HandlerUtil.updateRadioState(event.getCommand(), Boolean.toString(newNest));
@Override public Object execute(ExecutionEvent event) { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event); if (window == null) { return null; } IEditorPart editor = HandlerUtil.getActiveEditor(event); if (editor == null) { return null; } IWorkbenchPartReference ref = window.getActivePage().getReference( editor); if (ref instanceof WorkbenchPartReference) { WorkbenchPartReference concreteRef = (WorkbenchPartReference) ref; concreteRef.setPinned(!concreteRef.isPinned()); ICommandService commandService = window .getService(ICommandService.class); commandService.refreshElements(event.getCommand().getId(), null); } return null; }
@Override public Object execute(ExecutionEvent executionEvent) { final IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(executionEvent); if (window == null) { return null; } MWindow mWindow = ((WorkbenchWindow) window).getModel(); EModelService modelService = mWindow.getContext().get(EModelService.class); MToolControl searchField = (MToolControl) modelService.find("SearchField", mWindow); //$NON-NLS-1$ if (searchField != null && searchField.isVisible()) { Control control = (Control) searchField.getWidget(); // the workbench configurer may override visibility; if so, // focus should not change if (control != null && control.isVisible()) { Control previousFocusControl = control.getDisplay().getFocusControl(); control.setFocus(); SearchField field = (SearchField) searchField.getObject(); field.activate(previousFocusControl); return null; } } // open the original/legacy QuickAccess Dialog if the toolbars are // hidden or if the search field isn't available (maybe because the // dialog is explicitly wanted) displayQuickAccessDialog(window, executionEvent.getCommand()); return null; }
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; } }