@Override public String getActionDefinitionId() { return command.getId(); }
private void setImages(IServiceLocator locator, String iconStyle) { if (icon == null) { ICommandImageService service = locator .getService(ICommandImageService.class); icon = service.getImageDescriptor(command.getId(), ICommandImageService.TYPE_DEFAULT, iconStyle); disabledIcon = service.getImageDescriptor(command.getId(), ICommandImageService.TYPE_DISABLED, iconStyle); hoverIcon = service.getImageDescriptor(command.getId(), ICommandImageService.TYPE_HOVER, iconStyle); if (contributedIcon == null) contributedIcon = icon; if (contributedDisabledIcon == null) contributedDisabledIcon = disabledIcon; if (contributedHoverIcon == null) contributedHoverIcon = hoverIcon; } }
public String getBindCommand(KeySequence keySequence) { Map<?, ?> map = bindingManager.getActiveBindingsDisregardingContext(); List<?> bindings = (List<?>) map.get(keySequence); if (bindings != null) { for (Object obj : bindings) { Binding binding = (Binding) obj; if (GLANCE_CTX.equals(binding.getContextId())) { return binding.getParameterizedCommand().getId(); } } } return null; }
public static MCommand getMCommand(MApplication application, CommandContributionItem contribution) { ParameterizedCommand command = contribution.getCommand(); if (command != null) { for (MCommand mcommand : application.getCommands()) { if (mcommand.getElementId().equals(command.getId())) { return mcommand; } } } return null; }
@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$ } }
@Override public 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$ } }
@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$ } }
warningsToLog, "Cannot create modified sequence for key binding", //$NON-NLS-1$ sequenceModifier, parameterizedCommand.getId(), ATT_REPLACE, replaceSequence);
@Override public void runWithEvent(Event event) { if (handlerService == null) { String commandId = (parameterizedCommand == null ? "unknownCommand" //$NON-NLS-1$ : parameterizedCommand.getId()); WorkbenchPlugin.log("Cannot run " + commandId //$NON-NLS-1$ + " before command action has been initialized"); //$NON-NLS-1$ return; } try { if (parameterizedCommand != null) { handlerService.executeCommand(parameterizedCommand, event); } } catch (Exception e) { WorkbenchPlugin.log(e); } }
@Override public String getPerfectMatch(KeySequence keySequence) { try { final org.eclipse.jface.bindings.keys.KeySequence sequence = org.eclipse.jface.bindings.keys.KeySequence .getInstance(keySequence.toString()); final Binding binding = bindingManager.getPerfectMatch(sequence); if (binding == null) { return null; } return binding.getParameterizedCommand().getId(); } catch (final ParseException e) { return null; } }
String commandId = binding.getParameterizedCommand().getId();
ParameterizedCommand pCommand = b.getParameterizedCommand(); if (null != pCommand) { String commandId = pCommand.getId(); if (ObjectUtils.equals(commandId, MaximizeActiveViewHandler.COMMAND_ID)) { activeBinding = b.getTriggerSequence();
.getParameterizedCommand(); final String commandId = (parameterizedCommand == null) ? null : parameterizedCommand.getId(); element.putString(ATT_COMMAND_ID, commandId); element.putString(ATT_KEY_CONFIGURATION_ID, binding.getSchemeId());
@Override protected void executeItem(Event trigger) { ParameterizedCommand cmd = getModel().getWbCommand(); if (cmd == null) { return; } final IEclipseContext lclContext = getContext(getModel()); EHandlerService service = lclContext.get(EHandlerService.class); final IEclipseContext staticContext = getStaticContext(trigger); service.executeHandler(cmd, staticContext); Object object = staticContext.get(HandlerServiceImpl.HANDLER_EXCEPTION); if (object instanceof ExecutionException) { if (logger != null) { logger.error((Throwable) object, "Command '" + cmd.getId() + "' failed"); //$NON-NLS-1$ //$NON-NLS-2$ } } }
@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; }
ImageDescriptor descriptor = images.getImageDescriptor(pc.getId()); if (descriptor != null) { String iconUrl = MenuHelper.getImageUrl(descriptor);
/** * @param bindingCommand */ private void setCommandInfo(ParameterizedCommand bindingCommand) { setId(bindingCommand.getId()); try { setName(bindingCommand.getName()); } catch (NotDefinedException e) { setName(NewKeysPreferenceMessages.Undefined_Command); } try { setDescription(bindingCommand.getCommand().getDescription()); } catch (NotDefinedException e) { setDescription(Util.ZERO_LENGTH_STRING); } try { setCategory(bindingCommand.getCommand().getCategory().getName()); } catch (NotDefinedException e) { setCategory(NewKeysPreferenceMessages.Unavailable_Category); } setConflict(Boolean.FALSE); }