use of org.eclipse.che.ide.api.command.CommandImpl in project che by eclipse.
the class EditCommandsPresenter method onRemoveClicked.
@Override
public void onRemoveClicked() {
final CommandImpl selectedCommand = view.getSelectedCommand();
if (selectedCommand == null) {
return;
}
final ConfirmCallback confirmCallback = new ConfirmCallback() {
@Override
public void accepted() {
commandManager.remove(selectedCommand.getName()).then(new Operation<Void>() {
@Override
public void apply(Void arg) throws OperationException {
view.selectNeighborCommand(selectedCommand);
commandProcessingCallback = getCommandProcessingCallback();
refreshView();
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
dialogFactory.createMessageDialog("Error", arg.getMessage(), null).show();
}
});
}
};
ConfirmDialog confirmDialog = dialogFactory.createConfirmDialog(machineLocale.editCommandsViewRemoveTitle(), machineLocale.editCommandsRemoveConfirmation(selectedCommand.getName()), confirmCallback, null);
confirmDialog.show();
}
use of org.eclipse.che.ide.api.command.CommandImpl in project che by eclipse.
the class EditCommandsPresenter method onNameChanged.
@Override
public void onNameChanged() {
final CommandImpl selectedCommand = view.getSelectedCommand();
if (selectedCommand == null || !selectedCommand.equals(editedCommand)) {
return;
}
selectedCommand.setName(view.getCommandName());
view.setCancelButtonState(isViewModified());
view.setSaveButtonState(isViewModified());
}
use of org.eclipse.che.ide.api.command.CommandImpl in project che by eclipse.
the class EditCommandsViewImpl method renderCategoriesList.
/**
* Render the commands list.
* It also takes into account the name filter and restores the selected command.
*/
private void renderCategoriesList(Map<CommandType, List<CommandImpl>> categories) {
final List<Category<?>> categoriesToRender = new ArrayList<>();
for (CommandType type : categories.keySet()) {
List<CommandImpl> commands = new ArrayList<>();
if (filterTextValue.isEmpty()) {
commands = categories.get(type);
} else {
// filtering List
for (final CommandImpl command : categories.get(type)) {
if (command.getName().contains(filterTextValue)) {
commands.add(command);
}
}
}
Category<CommandImpl> category = new Category<>(type.getId(), commandRenderer, commands, commandEventDelegate);
categoriesToRender.add(category);
}
categoriesList.clear();
categoriesList.render(categoriesToRender, true);
if (selectedCommand != null) {
categoriesList.selectElement(selectedCommand);
if (filterTextValue.isEmpty()) {
selectText(commandName.getElement());
}
} else {
resetView();
}
}
use of org.eclipse.che.ide.api.command.CommandImpl in project che by eclipse.
the class EditCommandsViewImpl method selectNeighborCommand.
@Override
public void selectNeighborCommand(CommandImpl command) {
final CommandImpl commandToSelect;
final List<CommandImpl> commandsOfType = categories.get(getTypeById(command.getType()));
int selectedCommandIndex = commandsOfType.indexOf(command);
if (commandsOfType.size() < 2 || selectedCommandIndex == -1) {
commandToSelect = null;
} else {
if (selectedCommandIndex > 0) {
selectedCommandIndex--;
} else {
selectedCommandIndex++;
}
commandToSelect = commandsOfType.get(selectedCommandIndex);
}
if (commandToSelect != null) {
selectCommand(commandToSelect);
} else {
resetView();
}
}
use of org.eclipse.che.ide.api.command.CommandImpl in project che by eclipse.
the class ExecuteSelectedCommandAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
CommandImpl command = selectCommandAction.getSelectedCommand();
Machine machine = selectCommandAction.getSelectedMachine();
if (command != null && machine != null) {
commandManager.executeCommand(command, machine);
}
}
Aggregations