Merge "Use the new ChangeDetailCache in PatchSetDisclosurePanel"
This commit is contained in:
@@ -251,7 +251,7 @@ public class ChangeScreen extends Screen
|
|||||||
patchesGrid.setWidget(0, 1, patchesList);
|
patchesGrid.setWidget(0, 1, patchesList);
|
||||||
add(patchesGrid);
|
add(patchesGrid);
|
||||||
|
|
||||||
patchSetsBlock = new PatchSetsBlock(this);
|
patchSetsBlock = new PatchSetsBlock();
|
||||||
add(patchSetsBlock);
|
add(patchSetsBlock);
|
||||||
|
|
||||||
comments = new FlowPanel();
|
comments = new FlowPanel();
|
||||||
@@ -284,10 +284,6 @@ public class ChangeScreen extends Screen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void update(final ChangeDetail detail) {
|
|
||||||
detailCache.set(detail);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void display(final ChangeDetail detail) {
|
private void display(final ChangeDetail detail) {
|
||||||
displayTitle(detail.getChange().getKey(), detail.getChange().getSubject());
|
displayTitle(detail.getChange().getKey(), detail.getChange().getSubject());
|
||||||
|
|
||||||
|
@@ -70,7 +70,7 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel
|
|||||||
private static final int R_DOWNLOAD = 3;
|
private static final int R_DOWNLOAD = 3;
|
||||||
private static final int R_CNT = 4;
|
private static final int R_CNT = 4;
|
||||||
|
|
||||||
private final ChangeScreen changeScreen;
|
private final ChangeDetailCache detailCache;
|
||||||
private final ChangeDetail changeDetail;
|
private final ChangeDetail changeDetail;
|
||||||
private final PatchSet patchSet;
|
private final PatchSet patchSet;
|
||||||
private final FlowPanel body;
|
private final FlowPanel body;
|
||||||
@@ -86,27 +86,12 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel
|
|||||||
* Creates a closed complex disclosure panel for a patch set.
|
* Creates a closed complex disclosure panel for a patch set.
|
||||||
* The patch set details are loaded when the complex disclosure panel is opened.
|
* The patch set details are loaded when the complex disclosure panel is opened.
|
||||||
*/
|
*/
|
||||||
PatchSetComplexDisclosurePanel(final ChangeScreen parent, final ChangeDetail detail,
|
public PatchSetComplexDisclosurePanel(final PatchSet ps, boolean isOpen) {
|
||||||
final PatchSet ps) {
|
|
||||||
this(parent, detail, ps, false);
|
|
||||||
addOpenHandler(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an open complex disclosure panel for a patch set.
|
|
||||||
*/
|
|
||||||
PatchSetComplexDisclosurePanel(final ChangeScreen parent, final ChangeDetail detail,
|
|
||||||
final PatchSetDetail psd) {
|
|
||||||
this(parent, detail, psd.getPatchSet(), true);
|
|
||||||
ensureLoaded(psd);
|
|
||||||
}
|
|
||||||
|
|
||||||
private PatchSetComplexDisclosurePanel(final ChangeScreen parent, final ChangeDetail detail,
|
|
||||||
final PatchSet ps, boolean isOpen) {
|
|
||||||
super(Util.M.patchSetHeader(ps.getPatchSetId()), isOpen);
|
super(Util.M.patchSetHeader(ps.getPatchSetId()), isOpen);
|
||||||
changeScreen = parent;
|
detailCache = ChangeCache.get(ps.getId().getParentKey()).getChangeDetailCache();
|
||||||
changeDetail = detail;
|
changeDetail = detailCache.get();
|
||||||
patchSet = ps;
|
patchSet = ps;
|
||||||
|
|
||||||
body = new FlowPanel();
|
body = new FlowPanel();
|
||||||
setContent(body);
|
setContent(body);
|
||||||
|
|
||||||
@@ -117,7 +102,7 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel
|
|||||||
getHeader().add(revtxt);
|
getHeader().add(revtxt);
|
||||||
if (gw != null) {
|
if (gw != null) {
|
||||||
final Anchor revlink =
|
final Anchor revlink =
|
||||||
new Anchor(gw.getLinkName(), false, gw.toRevision(detail.getChange()
|
new Anchor(gw.getLinkName(), false, gw.toRevision(changeDetail.getChange()
|
||||||
.getProject(), ps));
|
.getProject(), ps));
|
||||||
revlink.addStyleName(Gerrit.RESOURCES.css().patchSetLink());
|
revlink.addStyleName(Gerrit.RESOURCES.css().patchSetLink());
|
||||||
getHeader().add(revlink);
|
getHeader().add(revlink);
|
||||||
@@ -128,6 +113,12 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel
|
|||||||
draftLabel.addStyleName(Gerrit.RESOURCES.css().patchSetRevision());
|
draftLabel.addStyleName(Gerrit.RESOURCES.css().patchSetRevision());
|
||||||
getHeader().add(draftLabel);
|
getHeader().add(draftLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isOpen) {
|
||||||
|
ensureLoaded(changeDetail.getCurrentPatchSetDetail());
|
||||||
|
} else {
|
||||||
|
addOpenHandler(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDiffBaseId(PatchSet.Id diffBaseId) {
|
public void setDiffBaseId(PatchSet.Id diffBaseId) {
|
||||||
@@ -611,7 +602,7 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel
|
|||||||
Util.MANAGE_SVC.publish(patchSet.getId(),
|
Util.MANAGE_SVC.publish(patchSet.getId(),
|
||||||
new GerritCallback<ChangeDetail>() {
|
new GerritCallback<ChangeDetail>() {
|
||||||
public void onSuccess(ChangeDetail result) {
|
public void onSuccess(ChangeDetail result) {
|
||||||
changeScreen.update(result);
|
detailCache.set(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -635,7 +626,7 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel
|
|||||||
new GerritCallback<ChangeDetail>() {
|
new GerritCallback<ChangeDetail>() {
|
||||||
public void onSuccess(final ChangeDetail result) {
|
public void onSuccess(final ChangeDetail result) {
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
changeScreen.update(result);
|
detailCache.set(result);
|
||||||
} else {
|
} else {
|
||||||
Gerrit.display(PageLinks.MINE);
|
Gerrit.display(PageLinks.MINE);
|
||||||
}
|
}
|
||||||
@@ -728,7 +719,7 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel
|
|||||||
new SubmitFailureDialog(result, msg).center();
|
new SubmitFailureDialog(result, msg).center();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
changeScreen.update(result);
|
detailCache.set(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PatchSet getPatchSet() {
|
public PatchSet getPatchSet() {
|
||||||
@@ -757,13 +748,13 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel
|
|||||||
private abstract class ActionDialog extends CommentedActionDialog<ChangeDetail> {
|
private abstract class ActionDialog extends CommentedActionDialog<ChangeDetail> {
|
||||||
public ActionDialog(final FocusWidget enableOnFailure, final boolean redirect,
|
public ActionDialog(final FocusWidget enableOnFailure, final boolean redirect,
|
||||||
String dialogTitle, String dialogHeading) {
|
String dialogTitle, String dialogHeading) {
|
||||||
super(dialogTitle, dialogHeading, new AsyncCallback<ChangeDetail>() {
|
super(dialogTitle, dialogHeading, new ChangeDetailCache.IgnoreErrorCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(ChangeDetail result) {
|
public void onSuccess(ChangeDetail result) {
|
||||||
if (redirect) {
|
if (redirect) {
|
||||||
Gerrit.display(PageLinks.toChange(result.getChange().getId()));
|
Gerrit.display(PageLinks.toChange(result.getChange().getId()));
|
||||||
} else {
|
} else {
|
||||||
changeScreen.update(result);
|
super.onSuccess(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -43,11 +43,9 @@ import java.util.Map;
|
|||||||
* that keyboard navigation to each changed file in all patch sets is possible.
|
* that keyboard navigation to each changed file in all patch sets is possible.
|
||||||
*/
|
*/
|
||||||
public class PatchSetsBlock extends Composite {
|
public class PatchSetsBlock extends Composite {
|
||||||
|
|
||||||
private final Map<PatchSet.Id, PatchSetComplexDisclosurePanel> patchSetPanels =
|
private final Map<PatchSet.Id, PatchSetComplexDisclosurePanel> patchSetPanels =
|
||||||
new HashMap<PatchSet.Id, PatchSetComplexDisclosurePanel>();
|
new HashMap<PatchSet.Id, PatchSetComplexDisclosurePanel>();
|
||||||
|
|
||||||
private final ChangeScreen parent;
|
|
||||||
private final FlowPanel body;
|
private final FlowPanel body;
|
||||||
private HandlerRegistration regNavigation;
|
private HandlerRegistration regNavigation;
|
||||||
|
|
||||||
@@ -65,8 +63,7 @@ public class PatchSetsBlock extends Composite {
|
|||||||
/** Patch sets on this change, in order. */
|
/** Patch sets on this change, in order. */
|
||||||
private List<PatchSet> patchSets;
|
private List<PatchSet> patchSets;
|
||||||
|
|
||||||
PatchSetsBlock(final ChangeScreen parent) {
|
PatchSetsBlock() {
|
||||||
this.parent = parent;
|
|
||||||
body = new FlowPanel();
|
body = new FlowPanel();
|
||||||
initWidget(body);
|
initWidget(body);
|
||||||
}
|
}
|
||||||
@@ -90,19 +87,13 @@ public class PatchSetsBlock extends Composite {
|
|||||||
patchSetPanelsList = new ArrayList<PatchSetComplexDisclosurePanel>();
|
patchSetPanelsList = new ArrayList<PatchSetComplexDisclosurePanel>();
|
||||||
|
|
||||||
for (final PatchSet ps : patchSets) {
|
for (final PatchSet ps : patchSets) {
|
||||||
final PatchSetComplexDisclosurePanel p;
|
final PatchSetComplexDisclosurePanel p =
|
||||||
if (ps == currps) {
|
new PatchSetComplexDisclosurePanel(ps, ps == currps);
|
||||||
p = new PatchSetComplexDisclosurePanel(parent, detail, detail
|
if (diffBaseId != null) {
|
||||||
.getCurrentPatchSetDetail());
|
p.setDiffBaseId(diffBaseId);
|
||||||
if (diffBaseId != null) {
|
if (ps == currps) {
|
||||||
p.setDiffBaseId(diffBaseId);
|
|
||||||
p.refresh();
|
p.refresh();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
p = new PatchSetComplexDisclosurePanel(parent, detail, ps);
|
|
||||||
if (diffBaseId != null) {
|
|
||||||
p.setDiffBaseId(diffBaseId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
add(p);
|
add(p);
|
||||||
patchSetPanelsList.add(p);
|
patchSetPanelsList.add(p);
|
||||||
|
Reference in New Issue
Block a user