Search in sources :

Example 1 with EditInfo

use of com.google.gerrit.client.info.ChangeInfo.EditInfo in project gerrit by GerritCodeReview.

the class DiffScreen method onLoad.

@Override
protected void onLoad() {
    super.onLoad();
    CallbackGroup group1 = new CallbackGroup();
    final CallbackGroup group2 = new CallbackGroup();
    CodeMirror.initLibrary(group1.add(new AsyncCallback<Void>() {

        final AsyncCallback<Void> themeCallback = group2.addEmpty();

        @Override
        public void onSuccess(Void result) {
            // Load theme after CM library to ensure theme can override CSS.
            ThemeLoader.loadTheme(prefs.theme(), themeCallback);
        }

        @Override
        public void onFailure(Throwable caught) {
        }
    }));
    DiffApi.diff(revision, path).base(base.asPatchSetId()).wholeFile().intraline(prefs.intralineDifference()).ignoreWhitespace(prefs.ignoreWhitespace()).get(group1.addFinal(new GerritCallback<DiffInfo>() {

        final AsyncCallback<Void> modeInjectorCb = group2.addEmpty();

        @Override
        public void onSuccess(DiffInfo diffInfo) {
            diff = diffInfo;
            fileSize = bucketFileSize(diffInfo);
            if (prefs.syntaxHighlighting()) {
                if (fileSize.compareTo(FileSize.SMALL) > 0) {
                    modeInjectorCb.onSuccess(null);
                } else {
                    injectMode(diffInfo, modeInjectorCb);
                }
            } else {
                modeInjectorCb.onSuccess(null);
            }
        }
    }));
    if (Gerrit.isSignedIn()) {
        ChangeApi.edit(changeId.get(), group2.add(new AsyncCallback<EditInfo>() {

            @Override
            public void onSuccess(EditInfo result) {
                edit = result;
            }

            @Override
            public void onFailure(Throwable caught) {
            }
        }));
    }
    final CommentsCollections comments = new CommentsCollections(base, revision, path);
    comments.load(group2);
    countParents(group2);
    RestApi call = ChangeApi.detail(changeId.get());
    ChangeList.addOptions(call, EnumSet.of(ListChangesOption.ALL_REVISIONS));
    call.get(group2.add(new AsyncCallback<ChangeInfo>() {

        @Override
        public void onSuccess(ChangeInfo info) {
            changeStatus = info.status();
            info.revisions().copyKeysIntoChildren("name");
            if (edit != null) {
                edit.setName(edit.commit().commit());
                info.setEdit(edit);
                info.revisions().put(edit.name(), RevisionInfo.fromEdit(edit));
            }
            String currentRevision = info.currentRevision();
            boolean current = currentRevision != null && revision.get() == info.revision(currentRevision)._number();
            JsArray<RevisionInfo> list = info.revisions().values();
            RevisionInfo.sortRevisionInfoByNumber(list);
            getDiffTable().set(prefs, list, parents, diff, edit != null, current, changeStatus.isOpen(), diff.binary());
            header.setChangeInfo(info);
        }

        @Override
        public void onFailure(Throwable caught) {
        }
    }));
    ConfigInfoCache.get(changeId, group2.addFinal(getScreenLoadCallback(comments)));
}
Also used : RestApi(com.google.gerrit.client.rpc.RestApi) ChangeInfo(com.google.gerrit.client.info.ChangeInfo) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) CallbackGroup(com.google.gerrit.client.rpc.CallbackGroup) EditInfo(com.google.gerrit.client.info.ChangeInfo.EditInfo) GerritCallback(com.google.gerrit.client.rpc.GerritCallback) RevisionInfo(com.google.gerrit.client.info.ChangeInfo.RevisionInfo)

Example 2 with EditInfo

use of com.google.gerrit.client.info.ChangeInfo.EditInfo in project gerrit by GerritCodeReview.

the class DownloadBox method onLoad.

@Override
protected void onLoad() {
    if (fetch == null) {
        if (psId.get() == 0) {
            ChangeApi.editWithCommands(change.legacyId().get()).get(new AsyncCallback<EditInfo>() {

                @Override
                public void onSuccess(EditInfo result) {
                    fetch = result.fetch();
                    renderScheme();
                }

                @Override
                public void onFailure(Throwable caught) {
                }
            });
        } else {
            RestApi call = ChangeApi.detail(change.legacyId().get());
            ChangeList.addOptions(call, EnumSet.of(revision.equals(change.currentRevision()) ? ListChangesOption.CURRENT_REVISION : ListChangesOption.ALL_REVISIONS, ListChangesOption.DOWNLOAD_COMMANDS));
            call.get(new AsyncCallback<ChangeInfo>() {

                @Override
                public void onSuccess(ChangeInfo result) {
                    fetch = result.revision(revision).fetch();
                    renderScheme();
                }

                @Override
                public void onFailure(Throwable caught) {
                }
            });
        }
    }
}
Also used : RestApi(com.google.gerrit.client.rpc.RestApi) ChangeInfo(com.google.gerrit.client.info.ChangeInfo) EditInfo(com.google.gerrit.client.info.ChangeInfo.EditInfo)

Example 3 with EditInfo

use of com.google.gerrit.client.info.ChangeInfo.EditInfo 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)

Aggregations

ChangeInfo (com.google.gerrit.client.info.ChangeInfo)3 EditInfo (com.google.gerrit.client.info.ChangeInfo.EditInfo)3 RevisionInfo (com.google.gerrit.client.info.ChangeInfo.RevisionInfo)2 CallbackGroup (com.google.gerrit.client.rpc.CallbackGroup)2 GerritCallback (com.google.gerrit.client.rpc.GerritCallback)2 RestApi (com.google.gerrit.client.rpc.RestApi)2 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)2 ChangeList (com.google.gerrit.client.changes.ChangeList)1 JsArray (com.google.gwt.core.client.JsArray)1