use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.
the class SshCategoryPresenter method connect.
/**
* Opens a connection to the selected target.
* Starts a machine based on the selected recipe.
*/
private void connect() {
sshView.setConnectButtonText(null);
connectTargetName = selectedTarget.getName();
connectNotification = notificationManager.notify(machineLocale.targetsViewConnectProgress(selectedTarget.getName()), PROGRESS, FLOAT_MODE);
String recipeURL = selectedTarget.getRecipe().getLink("get recipe script").getHref();
MachineLimitsDto limitsDto = dtoFactory.createDto(MachineLimitsDto.class).withRam(1024);
MachineSourceDto sourceDto = dtoFactory.createDto(MachineSourceDto.class).withType("ssh-config").withLocation(recipeURL);
MachineConfigDto configDto = dtoFactory.createDto(MachineConfigDto.class).withDev(false).withName(selectedTarget.getName()).withSource(sourceDto).withLimits(limitsDto).withType(getCategory());
Promise<Void> machinePromise = workspaceServiceClient.createMachine(appContext.getWorkspaceId(), configDto);
machinePromise.then(new Operation<Void>() {
@Override
public void apply(Void arg) throws OperationException {
}
});
machinePromise.catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError promiseError) throws OperationException {
onConnectingFailed(null);
}
});
}
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();
}
});
}
Aggregations