use of com.google.gerrit.client.rpc.CallbackGroup in project gerrit by GerritCodeReview.
the class ContactPanelShort method doSave.
void doSave() {
final String newName;
String name = canEditFullName() ? nameTxt.getText() : null;
if (name != null && name.trim().isEmpty()) {
newName = null;
} else {
newName = name;
}
final String newEmail;
if (emailPick.isEnabled() && emailPick.getSelectedIndex() >= 0) {
final String v = emailPick.getValue(emailPick.getSelectedIndex());
if (Util.C.buttonOpenRegisterNewEmail().equals(v)) {
newEmail = currentEmail;
} else {
newEmail = v;
}
} else {
newEmail = currentEmail;
}
save.setEnabled(false);
registerNewEmail.setEnabled(false);
CallbackGroup group = new CallbackGroup();
if (currentEmail != null && !newEmail.equals(currentEmail)) {
AccountApi.setPreferredEmail("self", newEmail, group.add(new GerritCallback<NativeString>() {
@Override
public void onSuccess(NativeString result) {
}
}));
}
AccountApi.setName("self", newName, group.add(new GerritCallback<NativeString>() {
@Override
public void onSuccess(NativeString result) {
}
@Override
public void onFailure(Throwable caught) {
save.setEnabled(true);
registerNewEmail.setEnabled(true);
super.onFailure(caught);
}
}));
group.done();
group.addListener(new GerritCallback<Void>() {
@Override
public void onSuccess(Void result) {
currentEmail = newEmail;
AccountInfo me = Gerrit.getUserAccount();
me.email(currentEmail);
me.name(newName);
onSaveSuccess(me);
registerNewEmail.setEnabled(true);
}
});
}
use of com.google.gerrit.client.rpc.CallbackGroup in project gerrit by GerritCodeReview.
the class AccountApi method deleteSshKeys.
/**
* Delete SSH keys. For each key to be deleted a separate DELETE request is fired to the server.
* The {@code onSuccess} method of the provided callback is invoked once after all requests
* succeeded. If any request fails the callbacks' {@code onFailure} method is invoked. In a
* failure case it can be that still some of the keys were successfully deleted.
*/
public static void deleteSshKeys(String account, Set<Integer> sequenceNumbers, AsyncCallback<VoidResult> cb) {
CallbackGroup group = new CallbackGroup();
for (int seq : sequenceNumbers) {
new RestApi("/accounts/").id(account).view("sshkeys").id(seq).delete(group.add(cb));
cb = CallbackGroup.emptyCallback();
}
group.done();
}
use of com.google.gerrit.client.rpc.CallbackGroup in project gerrit by GerritCodeReview.
the class ChangeScreen method onLoad.
@Override
protected void onLoad() {
super.onLoad();
CallbackGroup group = new CallbackGroup();
if (Gerrit.isSignedIn()) {
ChangeList.query("change:" + changeId.get() + " has:draft", Collections.<ListChangesOption>emptySet(), group.add(new AsyncCallback<ChangeList>() {
@Override
public void onSuccess(ChangeList result) {
hasDraftComments = result.length() > 0;
}
@Override
public void onFailure(Throwable caught) {
}
}));
ChangeApi.editWithFiles(changeId.get(), group.add(new AsyncCallback<EditInfo>() {
@Override
public void onSuccess(EditInfo result) {
edit = result;
}
@Override
public void onFailure(Throwable caught) {
}
}));
}
loadChangeInfo(true, group.addFinal(new GerritCallback<ChangeInfo>() {
@Override
public void onSuccess(final ChangeInfo info) {
info.init();
initCurrentRevision(info);
final RevisionInfo rev = info.revision(revision);
CallbackGroup group = new CallbackGroup();
loadCommit(rev, group);
group.addListener(new GerritCallback<Void>() {
@Override
public void onSuccess(Void result) {
if (base.isBase() && rev.isMerge()) {
base = DiffObject.parse(info.legacyId(), Gerrit.getUserPreferences().defaultBaseForMerges().getBase());
}
loadConfigInfo(info, base);
JsArray<MessageInfo> mAr = info.messages();
for (int i = 0; i < mAr.length(); i++) {
if (mAr.get(i).tag() != null) {
hideTaggedComments.setVisible(true);
break;
}
}
}
});
group.done();
}
}));
}
use of com.google.gerrit.client.rpc.CallbackGroup in project gerrit by GerritCodeReview.
the class ProjectInfoScreen method onLoad.
@Override
protected void onLoad() {
super.onLoad();
Project.NameKey project = getProjectKey();
CallbackGroup cbg = new CallbackGroup();
AccessMap.get(project, cbg.add(new GerritCallback<ProjectAccessInfo>() {
@Override
public void onSuccess(ProjectAccessInfo result) {
isOwner = result.isOwner();
configVisible = result.configVisible();
enableForm();
saveProject.setVisible(isOwner);
}
}));
ProjectApi.getConfig(project, cbg.addFinal(new ScreenLoadCallback<ConfigInfo>(this) {
@Override
public void preDisplay(ConfigInfo result) {
display(result);
}
}));
savedPanel = INFO;
}
use of com.google.gerrit.client.rpc.CallbackGroup in project gerrit by GerritCodeReview.
the class ChangeScreen method loadConfigInfo.
private void loadConfigInfo(final ChangeInfo info, DiffObject base) {
final RevisionInfo rev = info.revision(revision);
if (base.isAutoMerge() && !initCurrentRevision(info).isMerge()) {
Gerrit.display(getToken(), new NotFoundScreen());
}
updateToken(info, base, rev);
RevisionInfo baseRev = resolveRevisionOrPatchSetId(info, base.asString(), null);
CallbackGroup group = new CallbackGroup();
Timestamp lastReply = myLastReply(info);
if (rev.isEdit()) {
// Comments are filtered for the current revision. Use parent
// patch set for edits, as edits themself can never have comments.
RevisionInfo p = RevisionInfo.findEditParentRevision(info.revisions().values());
List<NativeMap<JsArray<CommentInfo>>> comments = loadComments(p, group);
loadFileList(base, baseRev, rev, lastReply, group, comments, null);
} else {
loadDiff(base, baseRev, rev, lastReply, group);
}
group.addListener(new AsyncCallback<Void>() {
@Override
public void onSuccess(Void result) {
loadConfigInfo(info, rev);
}
@Override
public void onFailure(Throwable caught) {
logger.log(Level.SEVERE, "Loading file list and inline comments failed: " + caught.getMessage());
loadConfigInfo(info, rev);
}
});
group.done();
}
Aggregations