use of org.eclipse.che.ide.api.command.CommandImpl in project che by eclipse.
the class SelectCommandComboBox method selectLastUsedCommand.
/** Selects last used command. */
private void selectLastUsedCommand() {
if (commands.isEmpty()) {
setEmptyCommand();
} else {
// for now, we always select first command
final CommandImpl command = commands.get(0);
commandsListWidget.selectElement(command.getName(), command.getName());
}
}
use of org.eclipse.che.ide.api.command.CommandImpl in project che by eclipse.
the class SelectCommandComboBox method setCommands.
/**
* Sets commands to the widget.
*
* @param commands
* commands to set
* @param commandToSelect
* command that should be selected or {@code null} if none
*/
private void setCommands(List<CommandImpl> commands, @Nullable CommandImpl commandToSelect) {
this.commands.clear();
commandActions.removeAll();
final DefaultActionGroup commandsList = (DefaultActionGroup) actionManager.getAction(GROUP_COMMANDS_LIST);
if (commandsList != null) {
commandActions.addAll(commandsList);
}
Collections.sort(commands, new Comparator<CommandImpl>() {
@Override
public int compare(CommandImpl o1, CommandImpl o2) {
return o1.getType().compareTo(o2.getType());
}
});
CommandImpl prevCommand = null;
for (CommandImpl command : commands) {
if (prevCommand == null || !command.getType().equals(prevCommand.getType())) {
CommandType commandType = commandTypeRegistry.getCommandTypeById(command.getType());
commandActions.addSeparator(commandType.getDisplayName());
}
commandActions.add(commandsListWidget.createAction(command.getName(), command.getName()));
prevCommand = command;
}
this.commands.addAll(commands);
if (commandToSelect != null) {
setSelectedCommand(commandToSelect);
} else {
selectLastUsedCommand();
}
}
use of org.eclipse.che.ide.api.command.CommandImpl in project che by eclipse.
the class CommandManagerImpl method executeCommand.
@Override
public void executeCommand(final CommandImpl command, final Machine machine) {
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(new Operation<String>() {
@Override
public void apply(String expandedCommandLine) throws OperationException {
CommandImpl expandedCommand = new CommandImpl(name, expandedCommandLine, type, attributes);
final CommandOutputConsole console = commandConsoleFactory.create(expandedCommand, machine);
final String machineId = machine.getId();
processesPanelPresenter.addCommandOutput(machineId, console);
execAgentCommandManager.startProcess(machineId, expandedCommand).thenIfProcessStartedEvent(console.getProcessStartedOperation()).thenIfProcessDiedEvent(console.getProcessDiedOperation()).thenIfProcessStdOutEvent(console.getStdOutOperation()).thenIfProcessStdErrEvent(console.getStdErrOperation());
}
});
}
use of org.eclipse.che.ide.api.command.CommandImpl in project che by eclipse.
the class CommandManagerImpl method update.
@Override
public Promise<CommandImpl> update(final String commandName, final CommandImpl command) {
final String name;
if (commandName.equals(command.getName())) {
name = commandName;
} else {
name = getUniqueCommandName(command.getType(), command.getName());
}
final CommandDto commandDto = dtoFactory.createDto(CommandDto.class).withName(name).withCommandLine(command.getCommandLine()).withType(command.getType()).withAttributes(command.getAttributes());
return workspaceServiceClient.updateCommand(appContext.getWorkspaceId(), commandName, commandDto).then(new Function<WorkspaceDto, CommandImpl>() {
@Override
public CommandImpl apply(WorkspaceDto arg) throws FunctionException {
final CommandImpl updatedCommand = new CommandImpl(commandDto.getName(), command.getCommandLine(), command.getType(), command.getAttributes());
commands.remove(commandName);
commands.put(updatedCommand.getName(), updatedCommand);
fireCommandUpdated(updatedCommand);
return updatedCommand;
}
});
}
use of org.eclipse.che.ide.api.command.CommandImpl in project che by eclipse.
the class EditCommandsPresenter method onSaveClicked.
@Override
public void onSaveClicked() {
final CommandImpl selectedCommand = view.getSelectedCommand();
if (selectedCommand == null) {
return;
}
updateCommand(selectedCommand).then(new Operation<CommandImpl>() {
@Override
public void apply(CommandImpl arg) throws OperationException {
commandProcessingCallback = getCommandProcessingCallback();
refreshView();
}
});
}
Aggregations