Search in sources :

Example 46 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 47 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 48 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 49 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)

Example 50 with OperationException

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();
}
Also used : CommandImpl(org.eclipse.che.ide.api.command.CommandImpl) ChoiceDialog(org.eclipse.che.ide.api.dialogs.ChoiceDialog) ConfirmCallback(org.eclipse.che.ide.api.dialogs.ConfirmCallback) 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