Search in sources :

Example 41 with Operation

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

the class DiffPresenter method showDiff.

public void showDiff() {
    final Project project = appContext.getRootProject();
    checkState(project != null);
    final Resource[] resources = appContext.getResources();
    checkState(!Arrays.isNullOrEmpty(resources));
    performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<CLIOutputResponse>() {

        @Override
        public Promise<CLIOutputResponse> perform(Credentials credentials) {
            return service.showDiff(project.getLocation(), toRelative(project, resources), "HEAD", credentials);
        }
    }, null).then(new Operation<CLIOutputResponse>() {

        @Override
        public void apply(CLIOutputResponse response) throws OperationException {
            printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandDiff());
            ;
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE);
        }
    });
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) Promise(org.eclipse.che.api.promises.client.Promise) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Resource(org.eclipse.che.ide.api.resources.Resource) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) Operation(org.eclipse.che.api.promises.client.Operation) Credentials(org.eclipse.che.ide.api.subversion.Credentials) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 42 with Operation

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

the class ExportPresenter method onExportClicked.

/** {@inheritDoc} */
@Override
public void onExportClicked() {
    final Project project = appContext.getRootProject();
    checkState(project != null);
    final Resource[] resources = appContext.getResources();
    checkState(!Arrays.isNullOrEmpty(resources));
    checkState(resources.length == 1);
    final String givenRevision = view.isRevisionSpecified() ? view.getRevision() : null;
    final StatusNotification notification = new StatusNotification(constants.exportStarted(resources[0].getLocation().toString()), PROGRESS, FLOAT_MODE);
    notificationManager.notify(notification);
    view.onClose();
    if (!isNullOrEmpty(givenRevision)) {
        service.getRevisions(project.getLocation(), toRelative(project, resources[0]), "1:HEAD").then(new Operation<GetRevisionsResponse>() {

            @Override
            public void apply(GetRevisionsResponse response) throws OperationException {
                final List<String> pathRevisions = response.getRevisions();
                if (pathRevisions.size() > 0) {
                    final String pathFirstRevision = pathRevisions.get(0);
                    final String pathLastRevision = pathRevisions.get(pathRevisions.size() - 1);
                    final int givenRevisionNb = Integer.valueOf(givenRevision);
                    final int pathFirstRevisionNb = Integer.valueOf(pathFirstRevision.substring(1));
                    final int pathLastRevisionNb = Integer.valueOf(pathLastRevision.substring(1));
                    final List<String> errOutput = response.getErrOutput();
                    if (errOutput != null && !errOutput.isEmpty()) {
                        printErrors(errOutput, constants.commandInfo());
                        notification.setTitle(constants.exportCommandExecutionError());
                        notification.setStatus(FAIL);
                    } else if (givenRevisionNb < pathFirstRevisionNb || givenRevisionNb > pathLastRevisionNb) {
                        notification.setTitle(constants.exportRevisionDoNotExistForPath(givenRevision, toRelative(project, resources[0]).toString()));
                        notification.setStatus(FAIL);
                    } else {
                        openExportPopup(project.getLocation(), toRelative(project, resources[0]), givenRevision, notification);
                    }
                } else {
                    notification.setTitle(constants.exportNoRevisionForPath(toRelative(project, resources[0]).toString()));
                    notification.setStatus(FAIL);
                }
            }
        }).catchError(new Operation<PromiseError>() {

            @Override
            public void apply(PromiseError error) throws OperationException {
                notification.setTitle(constants.exportCommandExecutionError() + "\n" + error.getMessage());
                notification.setStatus(FAIL);
            }
        });
    } else {
        openExportPopup(project.getLocation(), toRelative(project, resources[0]), null, notification);
    }
}
Also used : GetRevisionsResponse(org.eclipse.che.plugin.svn.shared.GetRevisionsResponse) Resource(org.eclipse.che.ide.api.resources.Resource) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) Operation(org.eclipse.che.api.promises.client.Operation) Project(org.eclipse.che.ide.api.resources.Project) PromiseError(org.eclipse.che.api.promises.client.PromiseError) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 43 with Operation

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

the class LockUnlockPresenter method doUnlockAction.

private void doUnlockAction(final boolean force, final Path[] paths) {
    final Project project = appContext.getRootProject();
    checkState(project != null);
    performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<CLIOutputResponse>() {

        @Override
        public Promise<CLIOutputResponse> perform(Credentials credentials) {
            return service.unlock(project.getLocation(), paths, force, credentials);
        }
    }, null).then(new Operation<CLIOutputResponse>() {

        @Override
        public void apply(CLIOutputResponse response) throws OperationException {
            printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandUnlock());
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE);
        }
    });
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) Promise(org.eclipse.che.api.promises.client.Promise) PromiseError(org.eclipse.che.api.promises.client.PromiseError) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) Operation(org.eclipse.che.api.promises.client.Operation) Credentials(org.eclipse.che.ide.api.subversion.Credentials) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 44 with Operation

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

the class CleanupPresenter method cleanup.

public void cleanup() {
    final Project project = appContext.getRootProject();
    checkState(project != null);
    final Resource[] resources = appContext.getResources();
    checkState(!Arrays.isNullOrEmpty(resources));
    service.cleanup(project.getLocation(), toRelative(project, resources)).then(new Operation<CLIOutputResponse>() {

        @Override
        public void apply(CLIOutputResponse result) throws OperationException {
            printResponse(result.getCommand(), result.getOutput(), result.getErrOutput(), constants.commandCleanup());
            notificationManager.notify(constants.cleanupSuccessful());
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            notificationManager.notify(constants.cleanupFailed() + ": " + error.getMessage(), FAIL, FLOAT_MODE);
        }
    });
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Resource(org.eclipse.che.ide.api.resources.Resource) Operation(org.eclipse.che.api.promises.client.Operation) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 45 with Operation

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

the class CommitPresenter method loadAllChanges.

private void loadAllChanges() {
    final Project project = appContext.getRootProject();
    checkState(project != null);
    service.status(project.getLocation(), new Path[0], null, false, false, false, true, false, null).then(new Operation<CLIOutputResponse>() {

        @Override
        public void apply(CLIOutputResponse response) throws OperationException {
            List<StatusItem> statusItems = parseChangesList(response);
            view.setChangesList(statusItems);
            view.onShow();
            cache.put(Changes.ALL, statusItems);
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            Log.error(CommitPresenter.class, error.getMessage());
        }
    });
}
Also used : StatusItem(org.eclipse.che.plugin.svn.shared.StatusItem) Project(org.eclipse.che.ide.api.resources.Project) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Operation(org.eclipse.che.api.promises.client.Operation) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) 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