/** Creates copy of the given {@code command}. */ public CommandImpl(CommandImpl command) { this( command.getName(), command.getCommandLine(), command.getType(), new HashMap<>(command.getAttributes()), new ApplicableContext(command.getApplicableContext())); }
@Override protected void updateCommandPropertyValue(String content) { editedCommand.setCommandLine(content); }
@Override public int hashCode() { return Objects.hash(name, typeId, commandLine, getAttributes(), getApplicableContext()); }
/** * {@inheritDoc} * * @see #equalsIgnoreContext(CommandImpl) */ @Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof CommandImpl)) { return false; } CommandImpl other = (CommandImpl) o; return Objects.equals(getName(), other.getName()) && Objects.equals(typeId, other.typeId) && Objects.equals(commandLine, other.commandLine) && Objects.equals(getAttributes(), other.getAttributes()) && Objects.equals(getApplicableContext(), other.getApplicableContext()); }
@Override public void resetFrom(CommandImpl command) { editedCommand = command; commandLineInitial = command.getCommandLine(); }
@Override public String getTitle() { return command.getName(); }
final ApplicableContext context = command.getApplicableContext(); if (!context.isWorkspaceApplicable() && context.getApplicableProjects().isEmpty()) { return promiseProvider.reject( final CommandImpl newCommand = new CommandImpl(command); newCommand.setName(commandNameGenerator.generate(command.getType(), command.getName())); (Function<Void, CommandImpl>) aVoid -> { newCommand.getApplicableContext().setWorkspaceApplicable(true); return newCommand; }); (Function<CommandImpl, CommandImpl>) arg -> { newCommand.getApplicableContext().addProject(projectPath); return newCommand; }); (Function<ArrayOf<?>, CommandImpl>) ignore -> { commands.put(newCommand.getName(), newCommand); return newCommand; });
final String previewUrl = command.getAttributes().get(COMMAND_PREVIEW_URL_ATTRIBUTE_NAME); if (!isNullOrEmpty(previewUrl)) { macroProcessor view.showCommandLine(command.getCommandLine());
workspaceCommand -> commands.put( workspaceCommand.getName(), new CommandImpl(workspaceCommand, new ApplicableContext()))); projectCommand -> { final CommandImpl existedCommand = this.commands.get(projectCommand.getName()); projectCommand.getName(), new CommandImpl( projectCommand, new ApplicableContext(project.getPath()))); } else { if (projectCommand.equalsIgnoreContext(existedCommand)) { existedCommand .getApplicableContext() .addProject(project.getPath()); } else {
final CommandImpl command = new CommandImpl(processName, commandLine, type); final CommandOutputConsole console = commandConsoleFactory.create(command, machineName); macroProcessorProvider .get() .expandMacros(commandByName.getCommandLine()) .then( new Operation<String>() { throws OperationException { final CommandImpl command = new CommandImpl( commandByName.getName(), expandedCommandLine,
/** * Compares this {@link CommandImpl} to another {@link CommandImpl}, ignoring applicable context * considerations. * * @param anotherCommand the {@link CommandImpl} to compare this {@link CommandImpl} against * @return {@code true} if the argument represents an equivalent {@link CommandImpl} ignoring * applicable context; {@code false} otherwise */ public boolean equalsIgnoreContext(CommandImpl anotherCommand) { if (this == anotherCommand) { return true; } return Objects.equals(getName(), anotherCommand.getName()) && Objects.equals(typeId, anotherCommand.typeId) && Objects.equals(commandLine, anotherCommand.commandLine) && Objects.equals(getAttributes(), anotherCommand.getAttributes()); }
@Override protected String getCommandPropertyValue() { final String previewUrl = editedCommand.getAttributes().get(COMMAND_PREVIEW_URL_ATTRIBUTE_NAME); return previewUrl != null ? previewUrl : ""; }
@Override public boolean isDirty() { if (editedCommand == null) { return false; } ApplicableContext context = editedCommand.getApplicableContext(); return !(applicableProjectsInitial.equals(context.getApplicableProjects())); }
/** Removes the command without notifying listeners. */ private Promise<Void> doRemoveCommand(String name) { final CommandImpl command = commands.get(name); if (command == null) { return promiseProvider.reject(new Exception("Command '" + name + "' does not exist.")); } final ApplicableContext context = command.getApplicableContext(); final ArrayOf<Promise<?>> commandPromises = Collections.arrayOf(); if (context.isWorkspaceApplicable()) { commandPromises.push(workspaceCommandManager.removeCommand(name)); } for (final String projectPath : context.getApplicableProjects()) { final Project project = getProjectByPath(projectPath); if (project == null) { continue; } commandPromises.push(projectCommandManager.removeCommand(project, name)); } return promiseProvider .all2(commandPromises) .then( (Function<ArrayOf<?>, Void>) arg -> { commands.remove(command.getName()); return null; }); }
/** * Removes action for executing the given command and removes the appropriate action group in case * it's empty. */ private void removeAction(CommandImpl command) { Action commandAction = commandActions.remove(command.getName()); if (commandAction != null) { removeAction(commandAction); // remove action from it's action group String goalId = command.getGoal(); if (isNullOrEmpty(goalId)) { goalId = goalRegistry.getDefaultGoal().getId(); } DefaultActionGroup goalPopUpGroup = goalPopUpGroups.get(goalId); if (goalPopUpGroup != null) { goalPopUpGroup.remove(commandAction); } } } }
@Override public void updatePresentation(NodePresentation presentation) { presentation.setPresentableText(getName()); final SVGResource commandTypeIcon = commandUtils.getCommandTypeIcon(getData().getType()); if (commandTypeIcon != null) { presentation.setPresentableIcon(commandTypeIcon); } }
@Override protected String getCommandPropertyValue() { return editedCommand.getCommandLine(); }
@Override public boolean isDirty() { if (editedCommand == null) { return false; } return !(commandNameInitial.equals(editedCommand.getName())); }