Search in sources :

Example 21 with PromiseError

use of org.eclipse.che.api.promises.client.PromiseError in project che by eclipse.

the class SshCategoryPresenter method updateTargetRecipe.

/**
     * Updates as existent target recipe and save it.
     */
private void updateTargetRecipe() {
    RecipeUpdate recipeUpdate = dtoFactory.createDto(RecipeUpdate.class).withId(selectedTarget.getRecipe().getId()).withName(sshView.getTargetName()).withType(selectedTarget.getRecipe().getType()).withTags(selectedTarget.getRecipe().getTags()).withDescription(selectedTarget.getRecipe().getDescription()).withScript("{" + "\"host\": \"" + selectedTarget.getHost() + "\", " + "\"port\": \"" + selectedTarget.getPort() + "\", " + "\"username\": \"" + selectedTarget.getUserName() + "\", " + "\"password\": \"" + selectedTarget.getPassword() + "\"" + "}");
    Promise<RecipeDescriptor> updateRecipe = recipeServiceClient.updateRecipe(recipeUpdate);
    updateRecipe.then(new Operation<RecipeDescriptor>() {

        @Override
        public void apply(RecipeDescriptor recipe) throws OperationException {
            onTargetSaved(recipe);
        }
    });
    updateRecipe.catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError arg) throws OperationException {
            dialogFactory.createMessageDialog("Error", machineLocale.targetsViewSaveError(), null).show();
        }
    });
}
Also used : RecipeUpdate(org.eclipse.che.api.machine.shared.dto.recipe.RecipeUpdate) PromiseError(org.eclipse.che.api.promises.client.PromiseError) RecipeDescriptor(org.eclipse.che.api.machine.shared.dto.recipe.RecipeDescriptor) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 22 with PromiseError

use of org.eclipse.che.api.promises.client.PromiseError in project che by eclipse.

the class SshCategoryPresenter method createTargetRecipe.

/**
     * Create a new target recipe and save it.
     */
private void createTargetRecipe() {
    List<String> tags = new ArrayList<>();
    tags.add(this.getCategory());
    NewRecipe newRecipe = dtoFactory.createDto(NewRecipe.class).withName(selectedTarget.getName()).withType(getCategory()).withScript("{" + "\"host\": \"" + selectedTarget.getHost() + "\", " + "\"port\": \"" + selectedTarget.getPort() + "\", " + "\"username\": \"" + selectedTarget.getUserName() + "\", " + "\"password\": \"" + selectedTarget.getPassword() + "\"" + "}").withTags(tags);
    Promise<RecipeDescriptor> createRecipe = recipeServiceClient.createRecipe(newRecipe);
    createRecipe.then(new Operation<RecipeDescriptor>() {

        @Override
        public void apply(RecipeDescriptor recipe) throws OperationException {
            onTargetSaved(recipe);
        }
    });
    createRecipe.catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError arg) throws OperationException {
            dialogFactory.createMessageDialog("Error", machineLocale.targetsViewSaveError(), null).show();
        }
    });
}
Also used : PromiseError(org.eclipse.che.api.promises.client.PromiseError) ArrayList(java.util.ArrayList) RecipeDescriptor(org.eclipse.che.api.machine.shared.dto.recipe.RecipeDescriptor) OperationException(org.eclipse.che.api.promises.client.OperationException) NewRecipe(org.eclipse.che.api.machine.shared.dto.recipe.NewRecipe)

Example 23 with PromiseError

use of org.eclipse.che.api.promises.client.PromiseError 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 24 with PromiseError

use of org.eclipse.che.api.promises.client.PromiseError 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 PromiseError

use of org.eclipse.che.api.promises.client.PromiseError in project che by eclipse.

the class TestResultViewImpl method gotoClass.

@Override
public void gotoClass(String packagePath, int line) {
    lastWentLine = line;
    final Project project = appContext.getRootProject();
    String testSrcPath = project.getPath() + "/" + DEFAULT_TEST_SOURCE_FOLDER;
    appContext.getWorkspaceRoot().getFile(testSrcPath + packagePath).then(new Operation<Optional<File>>() {

        @Override
        public void apply(Optional<File> file) throws OperationException {
            if (file.isPresent()) {
                eventBus.fireEvent(FileEvent.createOpenFileEvent(file.get()));
                Timer t = new Timer() {

                    @Override
                    public void run() {
                        EditorPartPresenter editorPart = editorAgent.getActiveEditor();
                        Document doc = ((TextEditor) editorPart).getDocument();
                        doc.setCursorPosition(new TextPosition(lastWentLine - 1, 0));
                    }
                };
                t.schedule(500);
            }
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            Log.info(TestResultViewImpl.class, error);
        }
    });
}
Also used : Optional(com.google.common.base.Optional) Operation(org.eclipse.che.api.promises.client.Operation) Document(org.eclipse.che.ide.api.editor.document.Document) Project(org.eclipse.che.ide.api.resources.Project) TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor) Timer(com.google.gwt.user.client.Timer) PromiseError(org.eclipse.che.api.promises.client.PromiseError) TextPosition(org.eclipse.che.ide.api.editor.text.TextPosition) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) File(org.eclipse.che.ide.api.resources.File) OperationException(org.eclipse.che.api.promises.client.OperationException)

Aggregations

PromiseError (org.eclipse.che.api.promises.client.PromiseError)137 OperationException (org.eclipse.che.api.promises.client.OperationException)123 Operation (org.eclipse.che.api.promises.client.Operation)109 Project (org.eclipse.che.ide.api.resources.Project)48 Resource (org.eclipse.che.ide.api.resources.Resource)40 CLIOutputResponse (org.eclipse.che.plugin.svn.shared.CLIOutputResponse)21 StatusNotification (org.eclipse.che.ide.api.notification.StatusNotification)20 Promise (org.eclipse.che.api.promises.client.Promise)19 List (java.util.List)15 JsPromiseError (org.eclipse.che.api.promises.client.js.JsPromiseError)13 GitOutputConsole (org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole)13 Path (org.eclipse.che.ide.resource.Path)13 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)11 DebuggerObserver (org.eclipse.che.ide.debug.DebuggerObserver)11 VirtualFile (org.eclipse.che.ide.api.resources.VirtualFile)10 Credentials (org.eclipse.che.ide.api.subversion.Credentials)10 HashMap (java.util.HashMap)9 Function (org.eclipse.che.api.promises.client.Function)8 FunctionException (org.eclipse.che.api.promises.client.FunctionException)8