/** Shows the guide of creating a command of the specified {@code goal}. */ public void guide(CommandGoal goal) { workspaceAgentProvider.get().setActivePart(commandsExplorerPresenterProvider.get()); commandManager .createCommand(goal.getId(), "custom") .then( command -> { editorAgentProvider.get().openEditor(nodeFactory.newCommandFileNode(command)); }); } }
@Override public void onCommandDuplicate(CommandImpl command) { commandManager .createCommand(command) .then(this::refreshViewAndSelectCommand) .catchError(showErrorNotification(messages.unableDuplicate())); }
/** Returns an operation which creates a command with the given context. */ private Operation<CommandType> createCommand(ApplicableContext context) { return selectedCommandType -> { final CommandGoal selectedGoal = view.getSelectedGoal(); if (selectedGoal == null) { return; } commandManager .createCommand(selectedGoal.getId(), selectedCommandType.getId(), context) .then( command -> { refreshViewAndSelectCommand(command); editorAgentProvider.get().openEditor(nodeFactory.newCommandFileNode(command)); }) .catchError(showErrorNotification(messages.unableCreate())); }; }
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); }