@Override public boolean isDefined() { return command.isDefined(); }
@Override public final void commandChanged( final CommandEvent commandEvent) { if (command.isDefined()) { command.removeCommandListener(this); loggedCommandIds.remove(commandId); } } });
public final void commandChanged( final CommandEvent commandEvent) { if (command.isDefined()) { command.removeCommandListener(this); loggedCommandIds.remove(commandId); } } });
@Override public final void commandChanged( final CommandEvent commandEvent) { if (command.isDefined()) { command.removeCommandListener(this); loggedCommandIds.remove(commandId); } } });
/** * Returns the category for this command. * * @return The category for this command; never <code>null</code>. * @throws NotDefinedException * If the handle is not currently defined. */ public Category getCategory() throws NotDefinedException { if (!isDefined()) { throw new NotDefinedException("Cannot get the category from an undefined command. " //$NON-NLS-1$ + id); } return category; }
/** * Returns the category for this command. * * @return The category for this command; never <code>null</code>. * @throws NotDefinedException * If the handle is not currently defined. */ public final Category getCategory() throws NotDefinedException { if (!isDefined()) { throw new NotDefinedException("Cannot get the category from an undefined command. " //$NON-NLS-1$ + id); } return category; }
/** * Returns the category for this command. * * @return The category for this command; never <code>null</code>. * @throws NotDefinedException * If the handle is not currently defined. */ public final Category getCategory() throws NotDefinedException { if (!isDefined()) { throw new NotDefinedException("Cannot get the category from an undefined command. " //$NON-NLS-1$ + id); } return category; }
@Override public final int compareTo(final Object object) { final ParameterizedCommand command = (ParameterizedCommand) object; final boolean thisDefined = this.command.isDefined(); final boolean otherDefined = command.command.isDefined(); if (!thisDefined || !otherDefined) { return Util.compare(thisDefined, otherDefined); } try { final int compareTo = getName().compareTo(command.getName()); if (compareTo == 0) { return getId().compareTo(command.getId()); } return compareTo; } catch (final NotDefinedException e) { throw new Error( "Concurrent modification of a command's defined state"); //$NON-NLS-1$ } }
public static boolean isUpdateManagerInstallerPresent() { ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class); Command command = commandService.getCommand(UPDATE_MANAGER_FIND_AND_INSTALL); return command.isDefined(); }
/** * 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(); } }
@Override public ICommand getCommand(String commandId) { final Command command = commandManager.getCommand(commandId); if (!command.isDefined()) { command.setHandler(HandlerServiceImpl.getHandler(commandId)); } return new CommandLegacyWrapper(command, bindingManager); }
@Override public Command defineCommand(String id, String name, String description, Category category, IParameter[] parameters, String helpContextId) { Command cmd = commandManager.getCommand(id); if (!cmd.isDefined()) { cmd.define(name, description, category, parameters, null, helpContextId); cmd.setHandler(HandlerServiceImpl.getHandler(id)); } return cmd; }
@Override public Command defineCommand(String id, String name, String description, Category category, IParameter[] parameters) { Command cmd = commandManager.getCommand(id); if (!cmd.isDefined()) { cmd.define(name, description, category, parameters); cmd.setHandler(HandlerServiceImpl.getHandler(id)); } return cmd; }
@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 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)); } } }
protected ICommandListener getCommandListener() { if (commandListener == null) { commandListener = commandEvent -> { if (commandEvent.isHandledChanged() || commandEvent.isEnabledChanged()) { if (commandEvent.getCommand().isDefined()) { setEnabled(commandEvent.getCommand().isEnabled()); } } }; } return commandListener; }
@SuppressWarnings("restriction") @Override public void widgetSelected(SelectionEvent e) { ECommandService commandService = PlatformUI.getWorkbench().getService(ECommandService.class); EHandlerService handlerService = PlatformUI.getWorkbench().getService(EHandlerService.class); Command command = commandService.getCommand(ShowInSystemExplorerHandler.ID); if (command.isDefined()) { ParameterizedCommand parameterizedCommand = commandService .createCommand(ShowInSystemExplorerHandler.ID, Collections.singletonMap( ShowInSystemExplorerHandler.RESOURCE_PATH_PARAMETER, locationStr)); if (handlerService.canExecute(parameterizedCommand)) { handlerService.executeHandler(parameterizedCommand); } } } });
@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; }
@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; }