protected ParameterizedCommand buildParameterizedCommand() { ArrayList<Parameterization> list = new ArrayList<>(fParameterToValue.size()); for (Entry<IParameter, String> entry : fParameterToValue.entrySet()) { list.add(new Parameterization(entry.getKey(), entry.getValue())); } Parameterization[] parameterizations = list.toArray(new Parameterization[list.size()]); ParameterizedCommand pCommand = new ParameterizedCommand(fSelectedCommand, parameterizations); return pCommand; }
@Override public String getDescription() { try { return command.getCommand().getDescription(); } catch (final NotDefinedException e) { return null; } }
@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 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$ } }
/** * Returns a formatted string describes this command. * * @return a description of the command of this element * @since 3.6 */ public String getCommand() { final StringBuilder label = new StringBuilder(); try { Command nestedCommand = command.getCommand(); label.append(command.getName()); if (nestedCommand != null && nestedCommand.getDescription() != null && nestedCommand.getDescription().length() != 0) { label.append(separator).append(nestedCommand.getDescription()); } } catch (NotDefinedException e) { label.append(command.toString()); } return label.toString(); }
/** * @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); }
@Override public ExecutionEvent createExecutionEvent(ParameterizedCommand command, Event event) { EvaluationContext legacy = new EvaluationContext(evalContext, evalContext.getDefaultVariable()); ExecutionEvent e = new ExecutionEvent(command.getCommand(), command.getParameterMap(), event, legacy); return e; }
@Override public String getText() { try { return command.getName(); } catch (final NotDefinedException e) { return null; } }
continue; if (binding.getParameterizedCommand().getId() == null) { continue; if (binding.getParameterizedCommand().getId().equals(id)) { if (param == null) { } else { Map<?, ?> m = binding.getParameterizedCommand().getParameterMap(); String key = null; if (CustomizePerspectiveDialog.isNewWizard(item)) {
public TextParameterControl(IParameter parameter, Text parameterText) { fParameter = parameter; fParameterText = parameterText; fParameterText.addModifyListener(this); if (fPreSel != null) { Object obj = fPreSel.getParameterMap().get(parameter.getId()); if (obj != null) fParameterText.setText(obj.toString()); } }
@Override public String getActionDefinitionId() { return command.getId(); }
/** * Build a command from the executable extension information. * * @param commandService * to get the Command object * @param commandId * the command id for this action * @param parameterMap */ private void createCommand(ICommandService commandService, String commandId, Map parameterMap) { Command cmd = commandService.getCommand(commandId); if (!cmd.isDefined()) { WorkbenchPlugin.log("Command " + commandId + " is undefined"); //$NON-NLS-1$//$NON-NLS-2$ return; } if (parameterMap == null) { parameterizedCommand = new ParameterizedCommand(cmd, null); return; } parameterizedCommand = ParameterizedCommand.generateCommand(cmd, parameterMap); }
if (!pc.getCommand().isDefined()) { ql.label = pc.getCommand().getName(); ql.description = pc.getCommand().getDescription(); ImageDescriptor descriptor = images.getImageDescriptor(pc.getId()); if (descriptor != null) { String iconUrl = MenuHelper.getImageUrl(descriptor);
stringBuffer.newLine(); stringBuffer.write('\t'); stringBuffer.write(command==null?"":command.toString()); //$NON-NLS-1$ stringBuffer.write(','); stringBuffer.newLine();
@Override public ParameterizedCommand createCommand(String id, Map<String, Object> parameters) { Command command = getCommand(id); if (command == null) { return null; } return ParameterizedCommand.generateCommand(command, parameters); }
private static void executeCommand(IWorkbench workbench, String commandName, Map<String, Object> params) { if (workbench == null) { workbench = PlatformUI.getWorkbench(); } // get command ICommandService commandService = (ICommandService)workbench.getService(ICommandService.class); Command command = commandService != null ? commandService.getCommand(commandName) : null; // get handler service //IBindingService bindingService = (IBindingService)workbench.getService(IBindingService.class); //TriggerSequence[] triggerSequenceArray = bindingService.getActiveBindingsFor("de.anbos.eclipse.easyshell.plugin.commands.open"); IHandlerService handlerService = (IHandlerService)workbench.getService(IHandlerService.class); if (command != null && handlerService != null) { ParameterizedCommand paramCommand = ParameterizedCommand.generateCommand(command, params); try { handlerService.executeCommand(paramCommand, null); } catch (Exception e) { Activator.logError(Activator.getResourceString("easyshell.message.error.handlerservice.execution"), paramCommand.toString(), e, true); } } }
setId(parameterizedCommand.getId()); setActionDefinitionId(parameterizedCommand.getId()); try { setText(parameterizedCommand.getName()); } catch (NotDefinedException e) { parameterizedCommand.getCommand().addCommandListener( getCommandListener()); parameterizedCommand.getCommand().setEnabled( handlerService.getCurrentState()); setEnabled(parameterizedCommand.getCommand().isEnabled()); setImageDescriptor(commandImageService.getImageDescriptor( commandIdIn, ICommandImageService.TYPE_DEFAULT));
/** * Fill in a temporary static context for execution. * * @param command */ @SuppressWarnings("rawtypes") private void addParms(ParameterizedCommand command, IEclipseContext staticContext) { final Map parms = command.getParameterMap(); Iterator i = parms.entrySet().iterator(); while (i.hasNext()) { Map.Entry entry = (Map.Entry) i.next(); String parameterId = (String) entry.getKey(); staticContext.set( parameterId, convertParameterValue(command.getCommand(), parameterId, (String) entry.getValue())); } staticContext.set(PARM_MAP, parms); staticContext.set(ParameterizedCommand.class, command); }
@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$ } }