Search in sources :

Example 11 with CallbackGroup

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);
        }
    });
}
Also used : GerritCallback(com.google.gerrit.client.rpc.GerritCallback) NativeString(com.google.gerrit.client.rpc.NativeString) CallbackGroup(com.google.gerrit.client.rpc.CallbackGroup) NativeString(com.google.gerrit.client.rpc.NativeString) AccountInfo(com.google.gerrit.client.info.AccountInfo)

Example 12 with CallbackGroup

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();
}
Also used : RestApi(com.google.gerrit.client.rpc.RestApi) CallbackGroup(com.google.gerrit.client.rpc.CallbackGroup)

Example 13 with CallbackGroup

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();
        }
    }));
}
Also used : GerritCallback(com.google.gerrit.client.rpc.GerritCallback) JsArray(com.google.gwt.core.client.JsArray) ChangeInfo(com.google.gerrit.client.info.ChangeInfo) RevisionInfo(com.google.gerrit.client.info.ChangeInfo.RevisionInfo) ChangeList(com.google.gerrit.client.changes.ChangeList) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) CallbackGroup(com.google.gerrit.client.rpc.CallbackGroup) EditInfo(com.google.gerrit.client.info.ChangeInfo.EditInfo)

Example 14 with CallbackGroup

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;
}
Also used : Project(com.google.gerrit.reviewdb.client.Project) GerritCallback(com.google.gerrit.client.rpc.GerritCallback) ProjectAccessInfo(com.google.gerrit.client.access.ProjectAccessInfo) CallbackGroup(com.google.gerrit.client.rpc.CallbackGroup) ScreenLoadCallback(com.google.gerrit.client.rpc.ScreenLoadCallback) ConfigInfo(com.google.gerrit.client.projects.ConfigInfo)

Example 15 with CallbackGroup

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();
}
Also used : RevisionInfo(com.google.gerrit.client.info.ChangeInfo.RevisionInfo) CallbackGroup(com.google.gerrit.client.rpc.CallbackGroup) CommentInfo(com.google.gerrit.client.changes.CommentInfo) NativeMap(com.google.gerrit.client.rpc.NativeMap) Timestamp(java.sql.Timestamp) NotFoundScreen(com.google.gerrit.client.NotFoundScreen)

Aggregations

CallbackGroup (com.google.gerrit.client.rpc.CallbackGroup)16 GerritCallback (com.google.gerrit.client.rpc.GerritCallback)8 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)5 ChangeInfo (com.google.gerrit.client.info.ChangeInfo)3 RevisionInfo (com.google.gerrit.client.info.ChangeInfo.RevisionInfo)3 UiHandler (com.google.gwt.uibinder.client.UiHandler)3 AccountInfo (com.google.gerrit.client.info.AccountInfo)2 EditInfo (com.google.gerrit.client.info.ChangeInfo.EditInfo)2 NativeMap (com.google.gerrit.client.rpc.NativeMap)2 NativeString (com.google.gerrit.client.rpc.NativeString)2 RestApi (com.google.gerrit.client.rpc.RestApi)2 ScreenLoadCallback (com.google.gerrit.client.rpc.ScreenLoadCallback)2 JsArray (com.google.gwt.core.client.JsArray)2 NotFoundScreen (com.google.gerrit.client.NotFoundScreen)1 ProjectAccessInfo (com.google.gerrit.client.access.ProjectAccessInfo)1 EditPreferences (com.google.gerrit.client.account.EditPreferences)1 ChangeScreen (com.google.gerrit.client.change.ChangeScreen)1 ChangeList (com.google.gerrit.client.changes.ChangeList)1 CommentInfo (com.google.gerrit.client.changes.CommentInfo)1 CapabilityInfo (com.google.gerrit.client.config.CapabilityInfo)1