/** * Returns the command's base identifier. It is possible for more than one * parameterized command to have the same identifier. * * @return The command id; never <code>null</code>. */ public final String getId() { return command.getId(); }
@Override public String getId() { return command.getId(); }
/** * Returns the command's base identifier. It is possible for more than one * parameterized command to have the same identifier. * * @return The command id; never <code>null</code>. */ public String getId() { return command.getId(); }
/** * Returns the command's base identifier. It is possible for more than one * parameterized command to have the same identifier. * * @return The command id; never <code>null</code>. */ public final String getId() { return command.getId(); }
/** * Creates a preference key for the given piece of state on the given * command. * * @param command * The command for which the preference key should be created; * must not be <code>null</code>. * @param stateId * The identifier of the state for which the preference key * should be created; must not be <code>null</code>. * @return A suitable preference key; never <code>null</code>. */ static String createPreferenceKey(final Command command, final String stateId) { return PREFERENCE_KEY_PREFIX + '/' + command.getId() + '/' + stateId; }
public String getCommandName() { if (fSelectedCommand != null) try { return fSelectedCommand.getName(); } catch (NotDefinedException e) { return fSelectedCommand.getId(); } return null; }
/** * @throws NotDefinedException * if the given command is not defined */ @Override public String getHelpContextId(final Command command) throws NotDefinedException { return commandHelpService.getHelpContextId(command.getId(), context); }
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$ }
/** * Checks whether the activity manager knows anything about this command * identifier. If the activity manager is currently filtering this command, * then it does not appear in the user interface. * * @param command * The command which should be checked against the activities; * must not be <code>null</code>. * @return <code>true</code> if the command identifier is not filtered; * <code>false</code> if it is */ private boolean isActive(final Command command) { return activityManager.getIdentifier(command.getId()).isEnabled(); }
@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; }
final protected TriggerSequence[] getInvokingCommandKeySequences() { if (invokingCommandKeySequences == null) { if (invokingCommand != null) { IBindingService bindingService = Adapters.adapt(window.getWorkbench(), IBindingService.class); invokingCommandKeySequences = bindingService.getActiveBindingsFor(invokingCommand.getId()); } } return invokingCommandKeySequences; }
/** * Returns <code>true</code> if the command is defined and is enabled. * * @param command * the command to check. Not <code>null</code>. */ private boolean isCommandEnabled(final Command command) { return command.isDefined() && activityManager.getIdentifier(command.getId()).isEnabled(); } }
protected static String getText(Object obj) { if (obj instanceof Command) { Command com = (Command) obj; try { return com.getName(); } catch (NotDefinedException e) { return com.getId(); } } else if (obj instanceof Category) { Category cat = (Category) obj; try { return cat.getName(); } catch (NotDefinedException e) { return cat.getId(); } } return ""; //$NON-NLS-1$ }
@Override public final void commandChanged(final CommandEvent commandEvent) { if (commandEvent.isDefinedChanged()) { final Command command = commandEvent.getCommand(); final String commandId = command.getId(); final boolean commandIdAdded = command.isDefined(); if (commandIdAdded) { definedHandleObjects.add(command); } else { definedHandleObjects.remove(command); } if (isListenerAttached()) { fireCommandManagerChanged(new CommandManagerEvent(this, commandId, commandIdAdded, true, null, false, false)); } } }
@Override public void commandChanged(final CommandEvent commandEvent) { if (commandEvent.isDefinedChanged()) { final Command command = commandEvent.getCommand(); final String commandId = command.getId(); final boolean commandIdAdded = command.isDefined(); if (commandIdAdded) { definedHandleObjects.add(command); } else { definedHandleObjects.remove(command); } if (isListenerAttached()) { fireCommandManagerChanged(new CommandManagerEvent(this, commandId, commandIdAdded, true, null, false, false)); } } }
@Override public final void commandChanged(final CommandEvent commandEvent) { if (commandEvent.isDefinedChanged()) { final Command command = commandEvent.getCommand(); final String commandId = command.getId(); final boolean commandIdAdded = command.isDefined(); if (commandIdAdded) { definedHandleObjects.add(command); } else { definedHandleObjects.remove(command); } if (isListenerAttached()) { fireCommandManagerChanged(new CommandManagerEvent(this, commandId, commandIdAdded, true, null, false, false)); } } }
@Override public void handlerChanged(HandlerEvent handlerEvent) { IHandler handler = command.getHandler(); if (handler instanceof HandlerServiceHandler) { IEclipseContext appContext = ((Workbench) PlatformUI.getWorkbench()).getApplication() .getContext(); if (HandlerServiceImpl.lookUpHandler(appContext, command.getId()) == this) { ((HandlerServiceHandler) handler).fireHandlerChanged(handlerEvent); } } }
@Override public IElementReference registerElementForCommand( ParameterizedCommand command, UIElement element) throws NotDefinedException { if (!command.getCommand().isDefined()) { throw new NotDefinedException( "Cannot define a callback for undefined command " //$NON-NLS-1$ + command.getCommand().getId()); } if (element == null) { throw new NotDefinedException("No callback defined for command " //$NON-NLS-1$ + command.getCommand().getId()); } ElementReference ref = new ElementReference(command.getId(), element, command.getParameterMap()); registerElement(ref); return ref; }
private void addSave(IMenuManager menu) { ICommandService commandService = fContainer.getWorkbenchPart().getSite().getService(ICommandService.class); final Command command= commandService.getCommand(IWorkbenchCommandConstants.FILE_SAVE); final IHandler handler = command.getHandler(); if (handler != null) { if (fSaveContributionItem == null) { fSaveContributionItem = new CommandContributionItem( new CommandContributionItemParameter(fContainer .getWorkbenchPart().getSite(), null, command .getId(), CommandContributionItem.STYLE_PUSH)); } // save is an editable dependent action, ie add only when edit // is possible if (handler.isHandled() && getSourceViewer().isEditable()) menu.add(fSaveContributionItem); } }