Search in sources :

Example 21 with OperationException

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);
        }
    });
}
Also used : PromiseError(org.eclipse.che.api.promises.client.PromiseError) MachineLimitsDto(org.eclipse.che.api.machine.shared.dto.MachineLimitsDto) MachineConfigDto(org.eclipse.che.api.machine.shared.dto.MachineConfigDto) MachineSourceDto(org.eclipse.che.api.machine.shared.dto.MachineSourceDto) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 22 with OperationException

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());
        }
    });
}
Also used : CommandImpl(org.eclipse.che.ide.api.command.CommandImpl) CommandOutputConsole(org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsole) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 23 with OperationException

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();
            }
        }
    });
}
Also used : RecipeDescriptor(org.eclipse.che.api.machine.shared.dto.recipe.RecipeDescriptor) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 24 with OperationException

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);
            }
        }
    });
}
Also used : RecipeUpdate(org.eclipse.che.api.machine.shared.dto.recipe.RecipeUpdate) PromiseError(org.eclipse.che.api.promises.client.PromiseError) RecipeEditorPanel(org.eclipse.che.ide.extension.machine.client.perspective.widgets.recipe.editor.RecipeEditorPanel) RecipeDescriptor(org.eclipse.che.api.machine.shared.dto.recipe.RecipeDescriptor) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 25 with OperationException

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();
        }
    });
}
Also used : CommandImpl(org.eclipse.che.ide.api.command.CommandImpl) OperationException(org.eclipse.che.api.promises.client.OperationException)

Aggregations

OperationException (org.eclipse.che.api.promises.client.OperationException)158 PromiseError (org.eclipse.che.api.promises.client.PromiseError)123 Operation (org.eclipse.che.api.promises.client.Operation)115 Project (org.eclipse.che.ide.api.resources.Project)53 Resource (org.eclipse.che.ide.api.resources.Resource)48 StatusNotification (org.eclipse.che.ide.api.notification.StatusNotification)21 CLIOutputResponse (org.eclipse.che.plugin.svn.shared.CLIOutputResponse)21 List (java.util.List)19 Promise (org.eclipse.che.api.promises.client.Promise)17 VirtualFile (org.eclipse.che.ide.api.resources.VirtualFile)15 Path (org.eclipse.che.ide.resource.Path)15 JsPromiseError (org.eclipse.che.api.promises.client.js.JsPromiseError)14 ArrayList (java.util.ArrayList)13 GitOutputConsole (org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole)13 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)12 DebuggerObserver (org.eclipse.che.ide.debug.DebuggerObserver)11 Optional (com.google.common.base.Optional)10 HashMap (java.util.HashMap)10 File (org.eclipse.che.ide.api.resources.File)10 Credentials (org.eclipse.che.ide.api.subversion.Credentials)10