Add top level menus for a new PatchScreen header

Modify the PatchScreen so that the header contents is selectable
using the top level menus. Allow the header to display either
nothing, the commit message, the preferences, the Patch Sets,
or the File List. Make the top level menus disappear when not
on the PatchScreen.

Change-Id: I4dd0014989f4e59643ff1d0c06637db08dc95505
This commit is contained in:
Martin Fick
2011-06-09 18:24:35 -06:00
parent f13b8ab3ff
commit 91784eb5db
6 changed files with 190 additions and 24 deletions

View File

@@ -112,6 +112,13 @@ public abstract class PatchScreen extends Screen implements
}
};
/**
* What should be displayed in the top of the screen
*/
public static enum TopView {
MAIN, COMMIT, PREFERENCES, PATCH_SETS, FILES
}
protected final Patch.Key patchKey;
protected PatchSetDetail patchSetDetail;
protected PatchTable fileList;
@@ -119,8 +126,8 @@ public abstract class PatchScreen extends Screen implements
protected PatchSet.Id idSideB;
protected PatchScriptSettingsPanel settingsPanel;
private DisclosurePanel historyPanel;
private HistoryTable historyTable;
private FlowPanel topPanel;
private FlowPanel contentPanel;
private Label noDifference;
private AbstractPatchContentTable contentTable;
@@ -251,26 +258,11 @@ public abstract class PatchScreen extends Screen implements
keysNavigation.add(new FileListCmd(0, 'f', PatchUtil.C.fileList()));
historyTable = new HistoryTable(this);
historyPanel = new DisclosurePanel(PatchUtil.C.patchHistoryTitle());
historyPanel.setContent(historyTable);
historyPanel.setVisible(false);
// If the user selected a different patch set than the default for either
// side, expand the history panel
historyPanel.setOpen(diffSideA != null || diffSideB != null
|| (historyOpen != null && historyOpen));
historyPanel.addOpenHandler(cacheOpenState);
historyPanel.addCloseHandler(cacheCloseState);
VerticalPanel vp = new VerticalPanel();
vp.add(historyPanel);
vp.add(settingsPanel);
commitMessageBlock = new CommitMessageBlock("6em");
HorizontalPanel hp = new HorizontalPanel();
hp.setWidth("100%");
hp.add(vp);
hp.add(commitMessageBlock);
add(hp);
topPanel = new FlowPanel();
add(topPanel);
noDifference = new Label(PatchUtil.C.noDifference());
noDifference.setStyleName(Gerrit.RESOURCES.css().patchNoDifference());
@@ -414,7 +406,6 @@ public abstract class PatchScreen extends Screen implements
}
historyTable.display(script.getHistory());
historyPanel.setVisible(true);
// True if there are differences between the two patch sets
boolean hasEdits = !script.getEdits().isEmpty();
@@ -489,6 +480,20 @@ public abstract class PatchScreen extends Screen implements
diffSideB = patchSetId;
}
public void setTopView(TopView tv) {
topPanel.clear();
switch(tv) {
case COMMIT: topPanel.add(commitMessageBlock);
break;
case PREFERENCES: topPanel.add(settingsPanel);
break;
case PATCH_SETS: topPanel.add(historyTable);
break;
case FILES: topPanel.add(fileList);
break;
}
}
public class FileListCmd extends KeyCommand {
public FileListCmd(int mask, int key, String help) {
super(mask, key, help);