@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 ParameterizedCommand readParameterizedCommand( final List warningsToLog, final IConfigurationElement configurationElement, String viewParameter, final Command command) { final ParameterizedCommand parameterizedCommand; if (command == null) { parameterizedCommand = null; } else if (viewParameter != null) { HashMap parms = new HashMap(); parms.put(ShowViewMenu.VIEW_ID_PARM, viewParameter); parameterizedCommand = ParameterizedCommand.generateCommand(command, parms); } else { parameterizedCommand = readParameters(configurationElement, warningsToLog, command); } return parameterizedCommand; }
@Override public Object executeCommand(String commandId, Event event) throws ExecutionException, NotDefinedException, NotEnabledException, NotHandledException { ECommandService cs = eclipseContext.get(ECommandService.class); final Command command = cs.getCommand(commandId); return executeCommand(ParameterizedCommand.generateCommand(command, null), event); }
ParameterizedCommand pC = ParameterizedCommand.generateCommand(cmd, params);
/** * 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); }
@Override public EvaluationResult evaluate(IEvaluationContext context) { EHandlerService service = getFromContext(context, EHandlerService.class); ICommandService commandService = getFromContext(context, ICommandService.class); if (service == null || commandService == null) { WorkbenchPlugin .log("Could not retrieve EHandlerService or ICommandService from context evaluation context for" //$NON-NLS-1$ + commandId); return EvaluationResult.FALSE; } Command c = commandService.getCommand(commandId); ParameterizedCommand generateCommand = ParameterizedCommand .generateCommand(c, Collections.EMPTY_MAP); return EvaluationResult .valueOf(service.canExecute(generateCommand)); } };
Command command = commandService.getCommand("com.packtpub.e4.clock.ui.command.hello"); if (command != null) { job.setProperty(IProgressConstants2.COMMAND_PROPERTY, ParameterizedCommand.generateCommand(command, null)); job.setProperty(IProgressConstants2.ICON_PROPERTY, ImageDescriptor.createFromURL(HelloHandler.class.getResource("/icons/sample.gif")));
ParameterizedCommand pCommand = ParameterizedCommand.generateCommand( command, parameters); try {
.generateCommand(command, parameters); highlight = pc; } else {
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); } } }
void createCommand(String commandId, Map parameters) { if (commandId == null) { StatusManager.getManager().handle( StatusUtil.newStatus(IStatus.ERROR, "Unable to create menu item \"" + getId() //$NON-NLS-1$ + "\", no command id", null)); //$NON-NLS-1$ return; } Command cmd = commandService.getCommand(commandId); if (!cmd.isDefined()) { StatusManager .getManager() .handle( StatusUtil .newStatus( IStatus.ERROR, "Unable to create menu item \"" + getId() //$NON-NLS-1$ + "\", command \"" + commandId + "\" not defined", null)); //$NON-NLS-1$ //$NON-NLS-2$ return; } command = ParameterizedCommand.generateCommand(cmd, parameters); }