use of com.google.gerrit.client.info.ChangeInfo.RevisionInfo 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.info.ChangeInfo.RevisionInfo 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();
}
use of com.google.gerrit.client.info.ChangeInfo.RevisionInfo in project gerrit by GerritCodeReview.
the class CommitBox method set.
void set(CommentLinkProcessor commentLinkProcessor, ChangeInfo change, String revision) {
RevisionInfo revInfo = change.revision(revision);
CommitInfo commit = revInfo.commit();
commitName.setText(revision);
idText.setText("Change-Id: " + change.changeId());
idText.setPreviewText(change.changeId());
formatLink(commit.author(), authorPanel, authorNameEmail, authorDate, change);
formatLink(commit.committer(), committerPanel, committerNameEmail, committerDate, change);
text.setHTML(commentLinkProcessor.apply(new SafeHtmlBuilder().append(commit.message()).linkify()));
setWebLinks(webLinkPanel, revInfo.commit());
if (revInfo.commit().parents().length() > 1) {
mergeCommit.setVisible(true);
}
setParents(revInfo.commit().parents());
}
use of com.google.gerrit.client.info.ChangeInfo.RevisionInfo in project gerrit by GerritCodeReview.
the class ChangeScreen method initRevisionsAction.
private void initRevisionsAction(ChangeInfo info, String revision, NativeMap<ActionInfo> actions) {
int currentPatchSet;
if (info.currentRevision() != null && info.revisions().containsKey(info.currentRevision())) {
currentPatchSet = info.revision(info.currentRevision())._number();
} else {
JsArray<RevisionInfo> revList = info.revisions().values();
RevisionInfo.sortRevisionInfoByNumber(revList);
currentPatchSet = revList.get(revList.length() - 1)._number();
}
String currentlyViewedPatchSet;
boolean isPatchSetCurrent = true;
String revisionId = info.revision(revision).id();
if (revisionId.equals("edit")) {
currentlyViewedPatchSet = Resources.M.editPatchSet(RevisionInfo.findEditParent(info.revisions().values()));
currentPatchSet = info.revisions().values().length() - 1;
} else {
currentlyViewedPatchSet = revisionId;
if (!currentlyViewedPatchSet.equals(Integer.toString(currentPatchSet))) {
isPatchSetCurrent = false;
}
}
patchSetsText.setInnerText(Resources.M.patchSets(currentlyViewedPatchSet, currentPatchSet));
updatePatchSetsTextStyle(isPatchSetCurrent);
patchSetsAction = new PatchSetsAction(info.legacyId(), revision, edit, style, headerLine, patchSets);
RevisionInfo revInfo = info.revision(revision);
if (revInfo.draft()) {
if (actions.containsKey("publish")) {
publish.setVisible(true);
publish.setTitle(actions.get("publish").title());
}
if (actions.containsKey("/")) {
deleteRevision.setVisible(true);
deleteRevision.setTitle(actions.get("/").title());
}
}
}
Aggregations