Search in sources :

Example 91 with Operation

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

the class DebuggerPresenter method updateStackFrameDump.

private void updateStackFrameDump() {
    Debugger debugger = debuggerManager.getActiveDebugger();
    if (debugger != null && executionPoint != null) {
        Promise<StackFrameDump> promise = debugger.dumpStackFrame();
        promise.then(new Operation<StackFrameDump>() {

            @Override
            public void apply(StackFrameDump arg) throws OperationException {
                variables = new ArrayList<>();
                variables.addAll(arg.getFields());
                variables.addAll(arg.getVariables());
                view.setVariables(variables);
            }
        }).catchError(new Operation<PromiseError>() {

            @Override
            public void apply(PromiseError arg) throws OperationException {
                Log.error(DebuggerPresenter.class, arg.getCause());
            }
        });
    }
}
Also used : Debugger(org.eclipse.che.ide.debug.Debugger) PromiseError(org.eclipse.che.api.promises.client.PromiseError) StackFrameDump(org.eclipse.che.api.debug.shared.model.StackFrameDump) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 92 with Operation

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

the class DocumentStorageImpl method saveDocument.

@Override
public void saveDocument(final EditorInput editorInput, @NotNull final Document document, final boolean overwrite, @NotNull final AsyncCallback<EditorInput> callback) {
    final VirtualFile file = editorInput.getFile();
    file.updateContent(document.getContents()).then(new Operation<Void>() {

        @Override
        public void apply(Void arg) throws OperationException {
            Log.debug(DocumentStorageImpl.class, "Document saved (" + file.getLocation() + ").");
            DocumentStorageImpl.this.eventBus.fireEvent(FileEvent.createSaveFileEvent(file));
            try {
                callback.onSuccess(editorInput);
            } catch (final Exception e) {
                Log.warn(DocumentStorageImpl.class, "Exception during save success callback: ", e);
            }
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError arg) throws OperationException {
            Log.error(DocumentStorageImpl.class, "Document save failed (" + file.getLocation() + ").", arg.getCause());
            try {
                callback.onFailure(arg.getCause());
            } catch (final Exception e) {
                Log.warn(DocumentStorageImpl.class, "Exception during save failure callback: ", e);
            }
        }
    });
}
Also used : VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 93 with Operation

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

the class AddRemoteRepositoryPresenter method onOkClicked.

/** {@inheritDoc} */
@Override
public void onOkClicked() {
    final String name = view.getName();
    final String url = view.getUrl().trim();
    final Project project = appContext.getRootProject();
    service.remoteAdd(appContext.getDevMachine(), project.getLocation(), name, url).then(new Operation<Void>() {

        @Override
        public void apply(Void arg) throws OperationException {
            callback.onSuccess(null);
            view.close();
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            callback.onFailure(error.getCause());
        }
    });
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 94 with Operation

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

the class RemoveFromIndexPresenter method onRemoveClicked.

/** {@inheritDoc} */
@Override
public void onRemoveClicked() {
    final GitOutputConsole console = gitOutputConsoleFactory.create(REMOVE_FROM_INDEX_COMMAND_NAME);
    final Resource[] resources = appContext.getResources();
    checkState(!isNullOrEmpty(resources));
    service.remove(appContext.getDevMachine(), project.getLocation(), toRelativePaths(resources), view.isRemoved()).then(new Operation<Void>() {

        @Override
        public void apply(Void ignored) throws OperationException {
            console.print(constant.removeFilesSuccessfull());
            consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
            notificationManager.notify(constant.removeFilesSuccessfull());
            project.synchronize();
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            handleError(error.getCause(), console);
            consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
        }
    });
    view.close();
}
Also used : PromiseError(org.eclipse.che.api.promises.client.PromiseError) GitOutputConsole(org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole) Resource(org.eclipse.che.ide.api.resources.Resource) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 95 with Operation

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

the class ResetToCommitPresenter method reset.

/**
     * Reset current HEAD to the specified state and refresh project in the success case.
     */
private void reset() {
    ResetRequest.ResetType type = view.isMixMode() ? ResetRequest.ResetType.MIXED : null;
    type = (type == null && view.isSoftMode()) ? ResetRequest.ResetType.SOFT : type;
    type = (type == null && view.isHardMode()) ? ResetRequest.ResetType.HARD : type;
    final GitOutputConsole console = gitOutputConsoleFactory.create(RESET_COMMAND_NAME);
    service.reset(appContext.getDevMachine(), project.getLocation(), selectedRevision.getId(), type, null).then(new Operation<Void>() {

        @Override
        public void apply(Void ignored) throws OperationException {
            console.print(constant.resetSuccessfully());
            consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
            notificationManager.notify(constant.resetSuccessfully());
            project.synchronize();
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            String errorMessage = (error.getMessage() != null) ? error.getMessage() : constant.resetFail();
            console.printError(errorMessage);
            consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
            notificationManager.notify(constant.resetFail(), FAIL, FLOAT_MODE);
        }
    });
}
Also used : PromiseError(org.eclipse.che.api.promises.client.PromiseError) GitOutputConsole(org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole) Operation(org.eclipse.che.api.promises.client.Operation) ResetRequest(org.eclipse.che.api.git.shared.ResetRequest) OperationException(org.eclipse.che.api.promises.client.OperationException)

Aggregations

Operation (org.eclipse.che.api.promises.client.Operation)126 OperationException (org.eclipse.che.api.promises.client.OperationException)116 PromiseError (org.eclipse.che.api.promises.client.PromiseError)110 Project (org.eclipse.che.ide.api.resources.Project)51 Resource (org.eclipse.che.ide.api.resources.Resource)45 Promise (org.eclipse.che.api.promises.client.Promise)21 StatusNotification (org.eclipse.che.ide.api.notification.StatusNotification)21 CLIOutputResponse (org.eclipse.che.plugin.svn.shared.CLIOutputResponse)21 List (java.util.List)17 VirtualFile (org.eclipse.che.ide.api.resources.VirtualFile)16 Path (org.eclipse.che.ide.resource.Path)14 GitOutputConsole (org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole)13 Optional (com.google.common.base.Optional)11 ArrayList (java.util.ArrayList)11 HashMap (java.util.HashMap)10 File (org.eclipse.che.ide.api.resources.File)10 Credentials (org.eclipse.che.ide.api.subversion.Credentials)10 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)9 JsPromiseError (org.eclipse.che.api.promises.client.js.JsPromiseError)8 TestResult (org.eclipse.che.api.testing.shared.TestResult)7