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());
}
}
});
}
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();
}
}
Aggregations