Search in sources :

Example 66 with PromiseError

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

the class BranchPresenter method onCheckoutClicked.

/** {@inheritDoc} */
@Override
public void onCheckoutClicked() {
    final CheckoutRequest checkoutRequest = dtoFactory.createDto(CheckoutRequest.class);
    if (selectedBranch.isRemote()) {
        checkoutRequest.setTrackBranch(selectedBranch.getDisplayName());
    } else {
        checkoutRequest.setName(selectedBranch.getDisplayName());
    }
    service.checkout(appContext.getDevMachine(), project.getLocation(), checkoutRequest).then(new Operation<Void>() {

        @Override
        public void apply(Void ignored) throws OperationException {
            getBranches();
            project.synchronize();
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            handleError(error.getCause(), BRANCH_CHECKOUT_COMMAND_NAME);
        }
    });
}
Also used : PromiseError(org.eclipse.che.api.promises.client.PromiseError) CheckoutRequest(org.eclipse.che.api.git.shared.CheckoutRequest) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 67 with PromiseError

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

the class CommitPresenter method setAmendCommitMessage.

/** {@inheritDoc} */
@Override
public void setAmendCommitMessage() {
    service.log(appContext.getDevMachine(), project.getLocation(), null, false).then(new Operation<LogResponse>() {

        @Override
        public void apply(LogResponse log) throws OperationException {
            final List<Revision> commits = log.getCommits();
            String message = "";
            if (commits != null && (!commits.isEmpty())) {
                final Revision tip = commits.get(0);
                if (tip != null) {
                    message = tip.getMessage();
                }
            }
            CommitPresenter.this.view.setMessage(message);
            CommitPresenter.this.view.setEnableCommitButton(!message.isEmpty());
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            if (getErrorCode(error.getCause()) == ErrorCodes.INIT_COMMIT_WAS_NOT_PERFORMED) {
                dialogFactory.createMessageDialog(constant.commitTitle(), constant.initCommitWasNotPerformed(), null).show();
            } else {
                CommitPresenter.this.view.setMessage("");
                notificationManager.notify(constant.logFailed(), FAIL, NOT_EMERGE_MODE);
            }
        }
    });
}
Also used : LogResponse(org.eclipse.che.api.git.shared.LogResponse) Revision(org.eclipse.che.api.git.shared.Revision) 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 68 with PromiseError

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

the class ComparePresenter method showCompareBetweenRevisions.

/**
     *
     * @param file
     *         path of the file
     * @param status
     *         status of the file
     * @param revisionA
     *         hash of the first revision or branch.
     *         If it is set to {@code null}, compare with empty repository state will be performed
     * @param revisionB
     *         hash of the second revision or branch.
     *         If it is set to {@code null}, compare with latest repository state will be performed
     */
public void showCompareBetweenRevisions(final Path file, final Status status, @Nullable final String revisionA, @Nullable final String revisionB) {
    this.compareWithLatest = false;
    final DevMachine devMachine = appContext.getDevMachine();
    final Path projectLocation = appContext.getRootProject().getLocation();
    view.setTitle(file.toString());
    if (status == Status.ADDED) {
        service.showFileContent(devMachine, projectLocation, file, revisionB).then(new Operation<ShowFileContentResponse>() {

            @Override
            public void apply(ShowFileContentResponse response) throws OperationException {
                view.setColumnTitles(revisionB + locale.compareReadOnlyTitle(), revisionA == null ? "" : revisionA + locale.compareReadOnlyTitle());
                view.show("", response.getContent(), file.toString(), true);
            }
        }).catchError(new Operation<PromiseError>() {

            @Override
            public void apply(PromiseError error) throws OperationException {
                notificationManager.notify(error.getMessage(), FAIL, NOT_EMERGE_MODE);
            }
        });
    } else if (status == Status.DELETED) {
        service.showFileContent(devMachine, projectLocation, file, revisionA).then(new Operation<ShowFileContentResponse>() {

            @Override
            public void apply(ShowFileContentResponse response) throws OperationException {
                view.setColumnTitles(revisionB + locale.compareReadOnlyTitle(), revisionA + locale.compareReadOnlyTitle());
                view.show(response.getContent(), "", file.toString(), true);
            }
        }).catchError(new Operation<PromiseError>() {

            @Override
            public void apply(PromiseError error) throws OperationException {
                notificationManager.notify(error.getMessage(), FAIL, NOT_EMERGE_MODE);
            }
        });
    } else {
        service.showFileContent(devMachine, projectLocation, file, revisionA).then(new Operation<ShowFileContentResponse>() {

            @Override
            public void apply(final ShowFileContentResponse contentAResponse) throws OperationException {
                service.showFileContent(devMachine, projectLocation, file, revisionB).then(new Operation<ShowFileContentResponse>() {

                    @Override
                    public void apply(ShowFileContentResponse contentBResponse) throws OperationException {
                        view.setColumnTitles(revisionB + locale.compareReadOnlyTitle(), revisionA + locale.compareReadOnlyTitle());
                        view.show(contentAResponse.getContent(), contentBResponse.getContent(), file.toString(), true);
                    }
                }).catchError(new Operation<PromiseError>() {

                    @Override
                    public void apply(PromiseError error) throws OperationException {
                        notificationManager.notify(error.getMessage(), FAIL, NOT_EMERGE_MODE);
                    }
                });
            }
        });
    }
}
Also used : Path(org.eclipse.che.ide.resource.Path) DevMachine(org.eclipse.che.ide.api.machine.DevMachine) PromiseError(org.eclipse.che.api.promises.client.PromiseError) ShowFileContentResponse(org.eclipse.che.api.git.shared.ShowFileContentResponse) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 69 with PromiseError

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

the class PullPresenter method updateBranches.

/**
     * Update the list of branches.
     *
     * @param remoteMode
     *         is a remote mode
     */
private void updateBranches(@NotNull final BranchListMode remoteMode) {
    service.branchList(appContext.getDevMachine(), project.getLocation(), remoteMode).then(new Operation<List<Branch>>() {

        @Override
        public void apply(List<Branch> branches) throws OperationException {
            if (LIST_REMOTE.equals(remoteMode)) {
                view.setRemoteBranches(branchSearcher.getRemoteBranchesToDisplay(view.getRepositoryName(), branches));
                updateBranches(LIST_LOCAL);
            } else {
                view.setLocalBranches(branchSearcher.getLocalBranchesToDisplay(branches));
                for (Branch branch : branches) {
                    if (branch.isActive()) {
                        view.selectRemoteBranch(branch.getDisplayName());
                        break;
                    }
                }
            }
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            handleError(error.getCause(), BRANCH_LIST_COMMAND_NAME);
            view.setEnablePullButton(false);
        }
    });
}
Also used : PromiseError(org.eclipse.che.api.promises.client.PromiseError) Branch(org.eclipse.che.api.git.shared.Branch) List(java.util.List) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 70 with PromiseError

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

the class PushToRemotePresenter method onPushClicked.

/** {@inheritDoc} */
@Override
public void onPushClicked() {
    final StatusNotification notification = notificationManager.notify(constant.pushProcess(), PROGRESS, FLOAT_MODE);
    final String repository = view.getRepository();
    final GitOutputConsole console = gitOutputConsoleFactory.create(PUSH_COMMAND_NAME);
    service.push(appContext.getDevMachine(), project.getLocation(), getRefs(), repository, false).then(new Operation<PushResponse>() {

        @Override
        public void apply(PushResponse response) throws OperationException {
            console.print(response.getCommandOutput());
            processesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
            notification.setStatus(SUCCESS);
            if (response.getCommandOutput().contains("Everything up-to-date")) {
                notification.setTitle(constant.pushUpToDate());
            } else {
                notification.setTitle(constant.pushSuccess(repository));
            }
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            handleError(error.getCause(), notification, console);
            processesPanelPresenter.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) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) Operation(org.eclipse.che.api.promises.client.Operation) PushResponse(org.eclipse.che.api.git.shared.PushResponse) 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