use of org.eclipse.che.api.promises.client.OperationException 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.api.promises.client.OperationException in project che by eclipse.
the class RecipePartPresenter method onDeleteButtonClicked.
/** {@inheritDoc} */
@Override
public void onDeleteButtonClicked() {
final RecipeDescriptor selectedRecipeDescriptor = recipes.get(selectedRecipe);
Promise<Void> recipeRemoved = service.removeRecipe(selectedRecipeDescriptor.getId());
recipeRemoved.then(new Operation<Void>() {
@Override
public void apply(Void arg) throws OperationException {
notificationManager.notify("Recipe \"" + selectedRecipeDescriptor.getName() + "\" was deleted.");
recipes.remove(selectedRecipe);
view.removeRecipe(selectedRecipe);
recipesContainerPresenter.removeRecipePanel(selectedRecipe);
selectedRecipe = null;
if (recipes.isEmpty()) {
showEditorStubPanel();
} else {
selectRecipe();
}
}
});
}
use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.
the class RecipePartPresenter method onSaveButtonClicked.
/** {@inheritDoc} */
@Override
public void onSaveButtonClicked() {
RecipeEditorPanel editorPanel = recipesContainerPresenter.getEditorPanel(selectedRecipe);
RecipeDescriptor recipeDescriptor = selectedRecipe.getDescriptor();
final RecipeUpdate recipeUpdate = dtoFactory.createDto(RecipeUpdate.class).withId(recipeDescriptor.getId()).withType(recipeDescriptor.getType()).withScript(editorPanel.getScript()).withName(editorPanel.getName()).withTags(editorPanel.getTags());
Promise<RecipeDescriptor> updateRecipe = service.updateRecipe(recipeUpdate);
updateRecipe.then(new Operation<RecipeDescriptor>() {
@Override
public void apply(RecipeDescriptor recipeDescriptor) throws OperationException {
RecipeDescriptor selectedRecipeDescriptor = recipes.get(selectedRecipe);
selectedRecipeDescriptor.setScript(recipeDescriptor.getScript());
selectedRecipeDescriptor.setTags(recipeDescriptor.getTags());
selectedRecipeDescriptor.setName(recipeDescriptor.getName());
selectedRecipe.setName(recipeDescriptor.getName());
notificationManager.notify("Recipe \"" + recipeDescriptor.getName() + "\" was saved.");
}
});
updateRecipe.catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
if (arg.getMessage() != null) {
notificationManager.notify(locale.failedToSaveRecipe(), arg.getMessage(), FAIL, FLOAT_MODE);
}
}
});
}
use of org.eclipse.che.api.promises.client.OperationException 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();
}
});
}
use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.
the class EditCommandsPresenter method createNewCommand.
private void createNewCommand(final String type, final String commandLine, final String name, final Map<String, String> attributes) {
if (!isViewModified()) {
createCommand(type, commandLine, name, attributes);
return;
}
final ConfirmCallback saveCallback = new ConfirmCallback() {
@Override
public void accepted() {
updateCommand(editedCommand).then(new Operation<CommandImpl>() {
@Override
public void apply(CommandImpl arg) throws OperationException {
createCommand(type, commandLine, name, attributes);
}
});
}
};
final ConfirmCallback discardCallback = new ConfirmCallback() {
@Override
public void accepted() {
refreshView();
createCommand(type, commandLine, name, attributes);
}
};
ChoiceDialog dialog = dialogFactory.createChoiceDialog(machineLocale.editCommandsSaveChangesTitle(), machineLocale.editCommandsSaveChangesConfirmation(editedCommand.getName()), coreLocale.save(), machineLocale.editCommandsSaveChangesDiscard(), saveCallback, discardCallback);
dialog.show();
}
Aggregations