private CommandImpl getWorkspaceCommandByName(String name) { for (Command command : appContext.getWorkspace().getConfig().getCommands()) { if (command.getName().equals(name)) { return new CommandImpl(command); // wrap model interface into implementation, workaround } } return null; }
@Override public Promise<CommandImpl> createCommand( String goalId, String typeId, @Nullable String name, @Nullable String commandLine, Map<String, String> attributes, ApplicableContext context) { final Map<String, String> attr = new HashMap<>(attributes); attr.put(COMMAND_GOAL_ATTRIBUTE_NAME, goalId); final Optional<CommandType> commandType = commandTypeRegistry.getCommandTypeById(typeId); commandType.ifPresent( type -> attr.put( COMMAND_PREVIEW_URL_ATTRIBUTE_NAME, commandType.get().getPreviewUrlTemplate())); final String commandLineTemplate = commandType.map(CommandType::getCommandLineTemplate).orElse(""); return createCommand( new CommandImpl( commandNameGenerator.generate(typeId, name), commandLine != null ? commandLine : commandLineTemplate, typeId, attr, context)); }
/** Returns commands for the specified {@code project}. */ List<CommandImpl> getCommands(Project project) { List<String> attrValues = project.getAttributes(COMMANDS_ATTRIBUTE_NAME); if (attrValues == null) { return new ArrayList<>(); } Map<String, CommandImpl> commands = new HashMap<>(attrValues.size()); for (String commandJson : attrValues) { try { CommandDto commandDto = dtoFactory.createDtoFromJson(commandJson, CommandDto.class); commands.put(commandDto.getName(), new CommandImpl(commandDto)); } catch (JSONException e) { Log.error( ProjectCommandManagerDelegate.class, "Unable to parse command of project '" + project.getPath() + "': " + commandJson + ". " + e.getMessage()); } } return new ArrayList<>(commands.values()); }
final CommandImpl command = new CommandImpl(processName, commandLine, type); final CommandOutputConsole console = commandConsoleFactory.create(command, machineName); throws OperationException { final CommandImpl command = new CommandImpl( commandByName.getName(), expandedCommandLine,
commands.put( workspaceCommand.getName(), new CommandImpl(workspaceCommand, new ApplicableContext()))); this.commands.put( projectCommand.getName(), new CommandImpl( projectCommand, new ApplicableContext(project.getPath())));
final CommandImpl command = new CommandImpl(processName, commandLine, type); final CommandOutputConsole console = commandConsoleFactory.create(command, machineName); throws OperationException { final CommandImpl command = new CommandImpl( commandByName.getName(), expandedCommandLine,
@Override protected void initializeEditor(EditorAgent.OpenEditorCallback callback) { commandRemovedHandlerRegistration = eventBus.addHandler(CommandRemovedEvent.getType(), this); final VirtualFile file = getEditorInput().getFile(); if (file instanceof CommandFileNode) { // make a copy of the given command to avoid modifying of the provided command editedCommand = new CommandImpl(((CommandFileNode) file).getData()); initializePages(); pages.forEach(page -> view.addPage(page.getView(), page.getTitle())); callback.onEditorOpened(this); } else { callback.onInitializationFailed(); } }
private Promise<CommandImpl> addCommand(Project project, CommandDto commandDto) { final String name = project.getName() + ": " + commandDto.getName(); final String absoluteProjectPath = appContext.getProjectsRoot().append(project.getPath()).toString(); final String commandLine = commandDto.getCommandLine().replaceAll(PROJECT_PATH_MACRO_REGEX, absoluteProjectPath); final CommandImpl command = new CommandImpl( name, commandLine, commandDto.getType(), commandDto.getAttributes(), new ApplicableContext(project.getPath())); return commandManager.createCommand(command); }
final CommandImpl newCommand = new CommandImpl(command); newCommand.setName(commandNameGenerator.generate(command.getType(), command.getName()));
@Override public void executeCommand(Command command, String machineName) { final String name = command.getName(); final String type = command.getType(); final String commandLine = command.getCommandLine(); final Map<String, String> attributes = command.getAttributes(); macroProcessor .expandMacros(commandLine) .then( expandedCommandLine -> { final CommandImpl expandedCommand = new CommandImpl(name, expandedCommandLine, type, attributes); final CommandOutputConsole console = commandConsoleFactory.create(expandedCommand, machineName); processesPanelPresenter.addCommandOutput(machineName, console, true); execAgentClient .startProcess(machineName, expandedCommand) .thenIfProcessStartedEvent(console.getProcessStartedConsumer()) .thenIfProcessDiedEvent(console.getProcessDiedConsumer()) .thenIfProcessStdOutEvent(console.getStdOutConsumer()) .thenIfProcessStdErrEvent(console.getStdErrConsumer()); }); }