Fix: Two UI update issues in change screen.

Select the last patch set in the
"Old Version History" drop-down list, then
the buttons disappear together with the diff,
but selecting a different patch doesn't make
the buttons reappear.

Expand a collapsed patch set panel and re-close
it. Change the base item to another one, then
open it again and find the patch list can not
update automatically according to the new
selected base item.

This patchset fixed them.

Change-Id: Ibef98e9ffa3659a9ab6137d08f3e9d4e43df5c4a
Signed-off-by: Bruce Zu <bruce.zu@sonymobile.com>
This commit is contained in:
Bruce Zu
2012-05-21 17:27:26 +08:00
committed by Gustaf Lundh
parent fafa4f54a9
commit 739f28aa00
3 changed files with 66 additions and 41 deletions

View File

@@ -128,6 +128,12 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel
* followed by the action buttons.
*/
public void ensureLoaded(final PatchSetDetail detail) {
loadInfoTable(detail);
loadActionPanel(detail);
loadPatchTable(detail);
}
public void loadInfoTable(final PatchSetDetail detail) {
infoTable = new Grid(R_CNT, 2);
infoTable.setStyleName(Gerrit.RESOURCES.css().infoBlock());
infoTable.addStyleName(Gerrit.RESOURCES.css().patchSetInfoBlock());
@@ -153,15 +159,13 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel
displayDownload();
body.add(infoTable);
}
public void loadActionPanel(final PatchSetDetail detail) {
if (!patchSet.getId().equals(diffBaseId)) {
patchTable = new PatchTable();
patchTable.setSavePointerId("PatchTable " + patchSet.getId());
patchTable.display(diffBaseId, detail);
actionsPanel = new FlowPanel();
actionsPanel.setStyleName(Gerrit.RESOURCES.css().patchSetActions());
body.add(actionsPanel);
actionsPanel.setVisible(true);
if (Gerrit.isSignedIn()) {
if (changeDetail.canEdit()) {
populateReviewAction();
@@ -173,18 +177,28 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel
if (changeDetail.canPublish()) {
populatePublishAction();
}
if (changeDetail.canDeleteDraft() &&
changeDetail.getPatchSets().size() > 1) {
if (changeDetail.canDeleteDraft()
&& changeDetail.getPatchSets().size() > 1) {
populateDeleteDraftPatchSetAction();
}
}
}
populateDiffAllActions(detail);
body.add(patchTable);
body.add(actionsPanel);
}
}
for(ClickHandler clickHandler : registeredClickHandler) {
public void loadPatchTable(final PatchSetDetail detail) {
if (!patchSet.getId().equals(diffBaseId)) {
patchTable = new PatchTable();
patchTable.setSavePointerId("PatchTable " + patchSet.getId());
patchTable.display(diffBaseId, detail);
for (ClickHandler clickHandler : registeredClickHandler) {
patchTable.addClickHandler(clickHandler);
}
patchTable.setRegisterKeys(true);
setActive(true);
body.add(patchTable);
}
}
@@ -644,34 +658,45 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel
}
public void refresh() {
AccountDiffPreference diffPrefs;
if (patchTable == null) {
diffPrefs = new ListenableAccountDiffPreference().get();
if (patchSet.getId().equals(diffBaseId)) {
if (patchTable != null) {
patchTable.setVisible(false);
}
if (actionsPanel != null) {
actionsPanel.setVisible(false);
}
} else {
diffPrefs = patchTable.getPreferences().get();
}
if (patchTable != null) {
if (patchTable.getBase() == null && diffBaseId == null
|| patchTable.getBase() != null
&& patchTable.getBase().equals(diffBaseId)) {
actionsPanel.setVisible(true);
patchTable.setVisible(true);
return;
}
}
Util.DETAIL_SVC.patchSetDetail2(diffBaseId, patchSet.getId(), diffPrefs,
new GerritCallback<PatchSetDetail>() {
@Override
public void onSuccess(PatchSetDetail result) {
if (patchSet.getId().equals(diffBaseId)) {
patchTable.setVisible(false);
actionsPanel.setVisible(false);
} else {
if (patchTable != null) {
patchTable.removeFromParent();
}
patchTable = new PatchTable();
patchTable.display(diffBaseId, result);
body.add(patchTable);
AccountDiffPreference diffPrefs;
if (patchTable == null) {
diffPrefs = new ListenableAccountDiffPreference().get();
} else {
diffPrefs = patchTable.getPreferences().get();
patchTable.setVisible(false);
}
for (ClickHandler clickHandler : registeredClickHandler) {
patchTable.addClickHandler(clickHandler);
Util.DETAIL_SVC.patchSetDetail2(diffBaseId, patchSet.getId(), diffPrefs,
new GerritCallback<PatchSetDetail>() {
@Override
public void onSuccess(PatchSetDetail result) {
if (actionsPanel != null) {
actionsPanel.setVisible(true);
} else {
loadActionPanel(result);
}
loadPatchTable(result);
}
}
});
});
}
}
@Override
@@ -687,8 +712,8 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel
Util.DETAIL_SVC.patchSetDetail2(diffBaseId, patchSet.getId(), diffPrefs,
new GerritCallback<PatchSetDetail>() {
public void onSuccess(final PatchSetDetail result) {
ensureLoaded(result);
patchTable.setRegisterKeys(true);
loadInfoTable(result);
loadActionPanel(result);
}
});
}

View File

@@ -89,12 +89,6 @@ public class PatchSetsBlock extends Composite {
for (final PatchSet ps : patchSets) {
final PatchSetComplexDisclosurePanel p =
new PatchSetComplexDisclosurePanel(ps, ps == currps);
if (diffBaseId != null) {
p.setDiffBaseId(diffBaseId);
if (ps == currps) {
p.refresh();
}
}
add(p);
patchSetPanelsList.add(p);
}
@@ -175,7 +169,6 @@ public class PatchSetsBlock extends Composite {
deactivate();
PatchSetComplexDisclosurePanel patchSetPanel =
patchSetPanels.get(patchSetId);
patchSetPanel.setOpen(true);
patchSetPanel.setActive(true);
activePatchSetId = patchSetId;
}
@@ -226,6 +219,9 @@ public class PatchSetsBlock extends Composite {
public void onOpen(OpenEvent<DisclosurePanel> event) {
// when a patch set panel is opened by the user
// it should automatically become active
PatchSetComplexDisclosurePanel patchSetPanel =
patchSetPanels.get(patchSetId);
patchSetPanel.refresh();
activate(patchSetId);
}

View File

@@ -119,6 +119,10 @@ public class PatchTable extends Composite {
}
}
public PatchSet.Id getBase() {
return base;
}
public void setSavePointerId(final String id) {
savePointerId = id;
}