Search in sources :

Example 1 with NotSignedInDialog

use of com.google.gerrit.client.NotSignedInDialog in project gerrit by GerritCodeReview.

the class Reviewers method addReviewer.

private void addReviewer(final String reviewer, boolean confirmed) {
    if (reviewer.isEmpty()) {
        return;
    }
    ChangeApi.reviewers(changeId.get()).post(PostInput.create(reviewer, confirmed), new GerritCallback<PostResult>() {

        @Override
        public void onSuccess(PostResult result) {
            if (result.confirm()) {
                askForConfirmation(result.error());
            } else if (result.error() != null) {
                UIObject.setVisible(error, true);
                error.setInnerText(result.error());
            } else {
                UIObject.setVisible(error, false);
                error.setInnerText("");
                suggestBox.setText("");
                if (result.reviewers() != null && result.reviewers().length() > 0) {
                    updateReviewerList();
                }
            }
        }

        private void askForConfirmation(String text) {
            new ConfirmationDialog(Util.C.approvalTableAddManyReviewersConfirmationDialogTitle(), new SafeHtmlBuilder().append(text), new ConfirmationCallback() {

                @Override
                public void onOk() {
                    addReviewer(reviewer, true);
                }
            }).center();
        }

        @Override
        public void onFailure(Throwable err) {
            if (isSigninFailure(err)) {
                new NotSignedInDialog().center();
            } else {
                UIObject.setVisible(error, true);
                error.setInnerText(err instanceof StatusCodeException ? ((StatusCodeException) err).getEncodedResponse() : err.getMessage());
            }
        }
    });
}
Also used : ConfirmationCallback(com.google.gerrit.client.ConfirmationCallback) NotSignedInDialog(com.google.gerrit.client.NotSignedInDialog) StatusCodeException(com.google.gwt.user.client.rpc.StatusCodeException) NativeString(com.google.gerrit.client.rpc.NativeString) SafeHtmlBuilder(com.google.gwtexpui.safehtml.client.SafeHtmlBuilder) ConfirmationDialog(com.google.gerrit.client.ConfirmationDialog)

Example 2 with NotSignedInDialog

use of com.google.gerrit.client.NotSignedInDialog in project gerrit by GerritCodeReview.

the class GerritCallback method showFailure.

public static void showFailure(Throwable caught) {
    if (isSigninFailure(caught)) {
        new NotSignedInDialog().center();
    } else if (isNoSuchEntity(caught)) {
        new ErrorDialog(Gerrit.C.notFoundBody()).center();
    } else if (isNoSuchAccount(caught)) {
        final String msg = caught.getMessage();
        final String who = msg.substring(NoSuchAccountException.MESSAGE.length());
        final ErrorDialog d = new ErrorDialog(Gerrit.M.noSuchAccountMessage(who));
        d.setText(Gerrit.C.noSuchAccountTitle());
        d.center();
    } else if (isNameAlreadyUsed(caught)) {
        final String msg = caught.getMessage();
        final String alreadyUsedName = msg.substring(NameAlreadyUsedException.MESSAGE.length());
        new ErrorDialog(Gerrit.M.nameAlreadyUsedBody(alreadyUsedName)).center();
    } else if (isNoSuchGroup(caught)) {
        final String msg = caught.getMessage();
        final String group = msg.substring(NoSuchGroupException.MESSAGE.length());
        final ErrorDialog d = new ErrorDialog(Gerrit.M.noSuchGroupMessage(group));
        d.setText(Gerrit.C.noSuchGroupTitle());
        d.center();
    } else if (caught instanceof ServerUnavailableException) {
        new ErrorDialog(RpcConstants.C.errorServerUnavailable()).center();
    } else {
        new ErrorDialog(caught).center();
    }
}
Also used : NotSignedInDialog(com.google.gerrit.client.NotSignedInDialog) ServerUnavailableException(com.google.gwtjsonrpc.client.ServerUnavailableException) ErrorDialog(com.google.gerrit.client.ErrorDialog)

Aggregations

NotSignedInDialog (com.google.gerrit.client.NotSignedInDialog)2 ConfirmationCallback (com.google.gerrit.client.ConfirmationCallback)1 ConfirmationDialog (com.google.gerrit.client.ConfirmationDialog)1 ErrorDialog (com.google.gerrit.client.ErrorDialog)1 NativeString (com.google.gerrit.client.rpc.NativeString)1 StatusCodeException (com.google.gwt.user.client.rpc.StatusCodeException)1 SafeHtmlBuilder (com.google.gwtexpui.safehtml.client.SafeHtmlBuilder)1 ServerUnavailableException (com.google.gwtjsonrpc.client.ServerUnavailableException)1