Merge "Fix browser NPE when ChangeCache is incomplete"

This commit is contained in:
Shawn Pearce
2013-08-13 17:29:06 +00:00
committed by Gerrit Code Review
4 changed files with 16 additions and 13 deletions

View File

@@ -16,8 +16,8 @@ package com.google.gerrit.client.changes;
import com.google.gerrit.client.ui.CommentLinkProcessor; import com.google.gerrit.client.ui.CommentLinkProcessor;
import com.google.gerrit.common.data.AccountInfoCache; import com.google.gerrit.common.data.AccountInfoCache;
import com.google.gerrit.common.data.ChangeDetail;
import com.google.gerrit.common.data.SubmitTypeRecord; import com.google.gerrit.common.data.SubmitTypeRecord;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSetInfo; import com.google.gerrit.reviewdb.client.PatchSetInfo;
import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.HorizontalPanel;
@@ -37,12 +37,12 @@ public class ChangeDescriptionBlock extends Composite {
initWidget(hp); initWidget(hp);
} }
public void display(Change chg, Boolean starred, Boolean canEditCommitMessage, public void display(ChangeDetail changeDetail, Boolean starred, Boolean canEditCommitMessage,
PatchSetInfo info, AccountInfoCache acc, PatchSetInfo info, AccountInfoCache acc,
SubmitTypeRecord submitTypeRecord, SubmitTypeRecord submitTypeRecord,
CommentLinkProcessor commentLinkProcessor) { CommentLinkProcessor commentLinkProcessor) {
infoBlock.display(chg, acc, submitTypeRecord); infoBlock.display(changeDetail, acc, submitTypeRecord);
messageBlock.display(chg.currentPatchSetId(), starred, messageBlock.display(changeDetail.getChange().currentPatchSetId(), starred,
canEditCommitMessage, info.getMessage(), commentLinkProcessor); canEditCommitMessage, info.getMessage(), commentLinkProcessor);
} }
} }

View File

@@ -95,8 +95,9 @@ public class ChangeInfoBlock extends Composite {
table.getCellFormatter().addStyleName(row, 0, Gerrit.RESOURCES.css().header()); table.getCellFormatter().addStyleName(row, 0, Gerrit.RESOURCES.css().header());
} }
public void display(final Change chg, final AccountInfoCache acc, public void display(final ChangeDetail changeDetail,
SubmitTypeRecord submitTypeRecord) { final AccountInfoCache acc, SubmitTypeRecord submitTypeRecord) {
final Change chg = changeDetail.getChange();
final Branch.NameKey dst = chg.getDest(); final Branch.NameKey dst = chg.getDest();
CopyableLabel changeIdLabel = CopyableLabel changeIdLabel =
@@ -114,7 +115,7 @@ public class ChangeInfoBlock extends Composite {
table.setWidget(R_BRANCH, 1, new BranchLink(dst.getShortName(), chg table.setWidget(R_BRANCH, 1, new BranchLink(dst.getShortName(), chg
.getProject(), chg.getStatus(), dst.get(), null)); .getProject(), chg.getStatus(), dst.get(), null));
table.setWidget(R_TOPIC, 1, topic(chg)); table.setWidget(R_TOPIC, 1, topic(changeDetail));
table.setText(R_UPLOADED, 1, mediumFormat(chg.getCreatedOn())); table.setText(R_UPLOADED, 1, mediumFormat(chg.getCreatedOn()));
table.setText(R_UPDATED, 1, mediumFormat(chg.getLastUpdatedOn())); table.setText(R_UPDATED, 1, mediumFormat(chg.getLastUpdatedOn()));
table.setText(R_STATUS, 1, Util.toLongString(chg.getStatus())); table.setText(R_STATUS, 1, Util.toLongString(chg.getStatus()));
@@ -146,7 +147,8 @@ public class ChangeInfoBlock extends Composite {
} }
} }
public Widget topic(final Change chg) { public Widget topic(final ChangeDetail changeDetail) {
final Change chg = changeDetail.getChange();
final Branch.NameKey dst = chg.getDest(); final Branch.NameKey dst = chg.getDest();
FlowPanel fp = new FlowPanel(); FlowPanel fp = new FlowPanel();
@@ -154,9 +156,6 @@ public class ChangeInfoBlock extends Composite {
fp.add(new BranchLink(chg.getTopic(), chg.getProject(), chg.getStatus(), fp.add(new BranchLink(chg.getTopic(), chg.getProject(), chg.getStatus(),
dst.get(), chg.getTopic())); dst.get(), chg.getTopic()));
ChangeDetailCache detailCache = ChangeCache.get(chg.getId()).getChangeDetailCache();
ChangeDetail changeDetail = detailCache.get();
if (changeDetail.canEditTopicName()) { if (changeDetail.canEditTopicName()) {
final Image edit = new Image(Gerrit.RESOURCES.edit()); final Image edit = new Image(Gerrit.RESOURCES.edit());
edit.addStyleName(Gerrit.RESOURCES.css().link()); edit.addStyleName(Gerrit.RESOURCES.css().link());

View File

@@ -322,7 +322,7 @@ public class ChangeScreen extends Screen
dependencies.setAccountInfoCache(detail.getAccounts()); dependencies.setAccountInfoCache(detail.getAccounts());
descriptionBlock.display(detail.getChange(), descriptionBlock.display(detail,
detail.isStarred(), detail.isStarred(),
detail.canEditCommitMessage(), detail.canEditCommitMessage(),
detail.getCurrentPatchSetDetail().getInfo(), detail.getCurrentPatchSetDetail().getInfo(),

View File

@@ -31,6 +31,7 @@ import com.google.gerrit.client.ui.CommentLinkProcessor;
import com.google.gerrit.client.ui.PatchLink; import com.google.gerrit.client.ui.PatchLink;
import com.google.gerrit.client.ui.SmallHeading; import com.google.gerrit.client.ui.SmallHeading;
import com.google.gerrit.common.PageLinks; import com.google.gerrit.common.PageLinks;
import com.google.gerrit.common.data.ChangeDetail;
import com.google.gerrit.common.data.PatchSetPublishDetail; import com.google.gerrit.common.data.PatchSetPublishDetail;
import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Patch; import com.google.gerrit.reviewdb.client.Patch;
@@ -317,9 +318,12 @@ public class PublishCommentScreen extends AccountScreen implements
} }
private void display(final PatchSetPublishDetail r) { private void display(final PatchSetPublishDetail r) {
ChangeDetail changeDetail = new ChangeDetail();
changeDetail.setChange(r.getChange());
setPageTitle(Util.M.publishComments(r.getChange().getKey().abbreviate(), setPageTitle(Util.M.publishComments(r.getChange().getKey().abbreviate(),
patchSetId.get())); patchSetId.get()));
descBlock.display(r.getChange(), null, false, r.getPatchSetInfo(), r.getAccounts(), descBlock.display(changeDetail, null, false, r.getPatchSetInfo(), r.getAccounts(),
r.getSubmitTypeRecord(), commentLinkProcessor); r.getSubmitTypeRecord(), commentLinkProcessor);
if (r.getChange().getStatus().isOpen()) { if (r.getChange().getStatus().isOpen()) {