Add user pref to retain PatchScreen Header when changing files

Change-Id: I199f79e9723a2296986fb0c042627c944dcb9288
This commit is contained in:
Martin Fick
2011-06-29 11:38:01 -06:00
parent f815eab1b6
commit cc4604ea51
9 changed files with 109 additions and 23 deletions

View File

@@ -416,14 +416,25 @@ public class Dispatcher {
public static void patch(String token, final Patch.Key id, public static void patch(String token, final Patch.Key id,
final int patchIndex, final PatchSetDetail patchSetDetail, final int patchIndex, final PatchSetDetail patchSetDetail,
final PatchTable patchTable) { final PatchTable patchTable, final PatchScreen.TopView topView) {
patch(token, id, patchIndex, patchSetDetail, patchTable, null); patch(token, id, patchIndex, patchSetDetail, patchTable, topView, null);
} }
public static void patch(String token, final Patch.Key id, public static void patch(String token, final Patch.Key id,
final int patchIndex, final PatchSetDetail patchSetDetail, final int patchIndex, final PatchSetDetail patchSetDetail,
final PatchTable patchTable, final PatchTable patchTable, final String panelType) {
patch(token, id, patchIndex, patchSetDetail, patchTable,
null, panelType);
}
public static void patch(String token, final Patch.Key id,
final int patchIndex, final PatchSetDetail patchSetDetail,
final PatchTable patchTable, final PatchScreen.TopView topView,
final String panelType) { final String panelType) {
final PatchScreen.TopView top = topView == null ?
Gerrit.getPatchScreenTopView() : topView;
GWT.runAsync(new AsyncSplit(token) { GWT.runAsync(new AsyncSplit(token) {
public void onSuccess() { public void onSuccess() {
Gerrit.display(token, select()); Gerrit.display(token, select());
@@ -442,14 +453,16 @@ public class Dispatcher {
id, // id, //
patchIndex, // patchIndex, //
patchSetDetail, // patchSetDetail, //
patchTable // patchTable, //
top //
); );
} else if ("unified".equals(panel)) { } else if ("unified".equals(panel)) {
return new PatchScreen.Unified( // return new PatchScreen.Unified( //
id, // id, //
patchIndex, // patchIndex, //
patchSetDetail, // patchSetDetail, //
patchTable // patchTable, //
top //
); );
} }
} }

View File

@@ -102,6 +102,13 @@ public class Gerrit implements EntryPoint {
Window.Location.reload(); Window.Location.reload();
} }
public static PatchScreen.TopView getPatchScreenTopView() {
if (patchScreen == null) {
return null;
}
return patchScreen.getTopView();
}
public static void displayLastChangeList() { public static void displayLastChangeList() {
if (lastChangeListToken != null) { if (lastChangeListToken != null) {
display(lastChangeListToken); display(lastChangeListToken);
@@ -615,8 +622,8 @@ public class Gerrit implements EntryPoint {
@Override @Override
public void go() { public void go() {
if (patchScreen != null) { if (patchScreen != null) {
patchScreen.setTopView(PatchScreen.TopView.MAIN);
if (type == patchScreen.getPatchScreenType()) { if (type == patchScreen.getPatchScreenType()) {
patchScreen.setTopView(PatchScreen.TopView.MAIN);
AnchorElement.as(getElement()).blur(); AnchorElement.as(getElement()).blur();
} else { } else {
new PatchLink("", type, patchScreen).go(); new PatchLink("", type, patchScreen).go();

View File

@@ -52,8 +52,9 @@ public abstract class PatchScreen extends Screen implements
public static class SideBySide extends PatchScreen { public static class SideBySide extends PatchScreen {
public SideBySide(final Patch.Key id, final int patchIndex, public SideBySide(final Patch.Key id, final int patchIndex,
final PatchSetDetail patchSetDetail, final PatchTable patchTable) { final PatchSetDetail patchSetDetail, final PatchTable patchTable,
super(id, patchIndex, patchSetDetail, patchTable); final TopView topView) {
super(id, patchIndex, patchSetDetail, patchTable, topView);
} }
@Override @Override
@@ -69,8 +70,9 @@ public abstract class PatchScreen extends Screen implements
public static class Unified extends PatchScreen { public static class Unified extends PatchScreen {
public Unified(final Patch.Key id, final int patchIndex, public Unified(final Patch.Key id, final int patchIndex,
final PatchSetDetail patchSetDetail, final PatchTable patchTable) { final PatchSetDetail patchSetDetail, final PatchTable patchTable,
super(id, patchIndex, patchSetDetail, patchTable); final TopView topView) {
super(id, patchIndex, patchSetDetail, patchTable, topView);
} }
@Override @Override
@@ -101,6 +103,7 @@ public abstract class PatchScreen extends Screen implements
protected PatchSet.Id idSideA; protected PatchSet.Id idSideA;
protected PatchSet.Id idSideB; protected PatchSet.Id idSideB;
protected PatchScriptSettingsPanel settingsPanel; protected PatchScriptSettingsPanel settingsPanel;
protected TopView topView;
private HistoryTable historyTable; private HistoryTable historyTable;
private FlowPanel topPanel; private FlowPanel topPanel;
@@ -131,10 +134,12 @@ public abstract class PatchScreen extends Screen implements
} }
protected PatchScreen(final Patch.Key id, final int patchIndex, protected PatchScreen(final Patch.Key id, final int patchIndex,
final PatchSetDetail detail, final PatchTable patchTable) { final PatchSetDetail detail, final PatchTable patchTable,
final TopView top) {
patchKey = id; patchKey = id;
patchSetDetail = detail; patchSetDetail = detail;
fileList = patchTable; fileList = patchTable;
topView = top;
if (patchTable != null) { if (patchTable != null) {
diffSideA = patchTable.getPatchSetIdToCompareWith(); diffSideA = patchTable.getPatchSetIdToCompareWith();
@@ -343,6 +348,10 @@ public abstract class PatchScreen extends Screen implements
return fileList; return fileList;
} }
public TopView getTopView() {
return topView;
}
protected void refresh(final boolean isFirst) { protected void refresh(final boolean isFirst) {
final int rpcseq = ++rpcSequence; final int rpcseq = ++rpcSequence;
lastScript = null; lastScript = null;
@@ -446,6 +455,9 @@ public abstract class PatchScreen extends Screen implements
intralineFailure = false; intralineFailure = false;
new ErrorDialog(PatchUtil.C.intralineFailure()).show(); new ErrorDialog(PatchUtil.C.intralineFailure()).show();
} }
if (topView != null && prefs.get().isRetainHeader()) {
setTopView(topView);
}
} }
private void showPatch(final boolean showPatch) { private void showPatch(final boolean showPatch) {
@@ -468,6 +480,7 @@ public abstract class PatchScreen extends Screen implements
} }
public void setTopView(TopView tv) { public void setTopView(TopView tv) {
topView = tv;
topPanel.clear(); topPanel.clear();
switch(tv) { switch(tv) {
case COMMIT: topPanel.add(commitMessageBlock); case COMMIT: topPanel.add(commitMessageBlock);

View File

@@ -90,6 +90,8 @@ public class PatchScriptSettingsPanel extends Composite implements
@UiField @UiField
CheckBox expandAllComments; CheckBox expandAllComments;
@UiField
CheckBox retainHeader;
@UiField @UiField
Button update; Button update;
@@ -213,6 +215,7 @@ public class PatchScriptSettingsPanel extends Composite implements
skipDeleted.setValue(dp.isSkipDeleted()); skipDeleted.setValue(dp.isSkipDeleted());
skipUncommented.setValue(dp.isSkipUncommented()); skipUncommented.setValue(dp.isSkipUncommented());
expandAllComments.setValue(dp.isExpandAllComments()); expandAllComments.setValue(dp.isExpandAllComments());
retainHeader.setValue(dp.isRetainHeader());
} }
@UiHandler("update") @UiHandler("update")
@@ -238,6 +241,7 @@ public class PatchScriptSettingsPanel extends Composite implements
dp.setSkipDeleted(skipDeleted.getValue()); dp.setSkipDeleted(skipDeleted.getValue());
dp.setSkipUncommented(skipUncommented.getValue()); dp.setSkipUncommented(skipUncommented.getValue());
dp.setExpandAllComments(expandAllComments.getValue()); dp.setExpandAllComments(expandAllComments.getValue());
dp.setRetainHeader(retainHeader.getValue());
listenablePrefs.set(dp); listenablePrefs.set(dp);

View File

@@ -115,27 +115,34 @@ limitations under the License.
</g:CheckBox> </g:CheckBox>
</td> </td>
<td> <td rowspan='2'>
<g:CheckBox <g:CheckBox
ui:field='expandAllComments' ui:field='expandAllComments'
text='Expand All Comments' text='Expand All Comments'
tabIndex='9'> tabIndex='9'>
<ui:attribute name='text'/> <ui:attribute name='text'/>
</g:CheckBox> </g:CheckBox>
<br/>
<g:CheckBox
ui:field='retainHeader'
text='Retain Header On File Switch'
tabIndex='10'>
<ui:attribute name='text'/>
</g:CheckBox>
</td> </td>
<td rowspan='2'> <td rowspan='2'>
<g:CheckBox <g:CheckBox
ui:field='skipUncommented' ui:field='skipUncommented'
text='Skip Uncommented Files' text='Skip Uncommented Files'
tabIndex='10'> tabIndex='11'>
<ui:attribute name='text'/> <ui:attribute name='text'/>
</g:CheckBox> </g:CheckBox>
<br/> <br/>
<g:CheckBox <g:CheckBox
ui:field='skipDeleted' ui:field='skipDeleted'
text='Skip Deleted Files' text='Skip Deleted Files'
tabIndex='11'> tabIndex='12'>
<ui:attribute name='text'/> <ui:attribute name='text'/>
</g:CheckBox> </g:CheckBox>
</td> </td>
@@ -145,7 +152,7 @@ limitations under the License.
ui:field='update' ui:field='update'
text='Update' text='Update'
styleName='{style.updateButton}' styleName='{style.updateButton}'
tabIndex='12'> tabIndex='13'>
<ui:attribute name='text'/> <ui:attribute name='text'/>
</g:Button> </g:Button>
</td> </td>
@@ -154,7 +161,7 @@ limitations under the License.
<g:CheckBox <g:CheckBox
ui:field='reviewed' ui:field='reviewed'
text='Reviewed' text='Reviewed'
tabIndex='13'> tabIndex='14'>
<ui:attribute name='text'/> <ui:attribute name='text'/>
</g:CheckBox> </g:CheckBox>
</td> </td>

View File

@@ -25,6 +25,7 @@ public class PatchLink extends InlineHyperlink {
protected int patchIndex; protected int patchIndex;
protected PatchSetDetail patchSetDetail; protected PatchSetDetail patchSetDetail;
protected PatchTable parentPatchTable; protected PatchTable parentPatchTable;
protected PatchScreen.TopView topView;
/** /**
* @param text The text of this link * @param text The text of this link
@@ -36,13 +37,15 @@ public class PatchLink extends InlineHyperlink {
*/ */
protected PatchLink(final String text, final Patch.Key patchKey, protected PatchLink(final String text, final Patch.Key patchKey,
final int patchIndex, final String historyToken, final int patchIndex, final String historyToken,
final PatchSetDetail patchSetDetail, final PatchSetDetail patchSetDetail, final PatchTable parentPatchTable,
final PatchTable parentPatchTable) { final PatchScreen.TopView topView) {
super(text, historyToken); super(text, historyToken);
this.patchKey = patchKey; this.patchKey = patchKey;
this.patchIndex = patchIndex; this.patchIndex = patchIndex;
this.patchSetDetail = patchSetDetail; this.patchSetDetail = patchSetDetail;
this.parentPatchTable = parentPatchTable; this.parentPatchTable = parentPatchTable;
this.parentPatchTable = parentPatchTable;
this.topView = topView;
} }
/** /**
@@ -57,7 +60,8 @@ public class PatchLink extends InlineHyperlink {
patchScreen.getPatchIndex(), // patchScreen.getPatchIndex(), //
Dispatcher.toPatch(type, patchScreen.getPatchKey()), // Dispatcher.toPatch(type, patchScreen.getPatchKey()), //
patchScreen.getPatchSetDetail(), // patchScreen.getPatchSetDetail(), //
patchScreen.getFileList() // patchScreen.getFileList(), //
patchScreen.getTopView() //
); );
} }
@@ -68,7 +72,8 @@ public class PatchLink extends InlineHyperlink {
patchKey, // patchKey, //
patchIndex, // patchIndex, //
patchSetDetail, // patchSetDetail, //
parentPatchTable // parentPatchTable,
topView //
); );
} }
@@ -77,7 +82,7 @@ public class PatchLink extends InlineHyperlink {
final int patchIndex, PatchSetDetail patchSetDetail, final int patchIndex, PatchSetDetail patchSetDetail,
PatchTable parentPatchTable) { PatchTable parentPatchTable) {
super(text, patchKey, patchIndex, Dispatcher.toPatchSideBySide(patchKey), super(text, patchKey, patchIndex, Dispatcher.toPatchSideBySide(patchKey),
patchSetDetail, parentPatchTable); patchSetDetail, parentPatchTable, null);
} }
} }
@@ -86,7 +91,7 @@ public class PatchLink extends InlineHyperlink {
final int patchIndex, PatchSetDetail patchSetDetail, final int patchIndex, PatchSetDetail patchSetDetail,
PatchTable parentPatchTable) { PatchTable parentPatchTable) {
super(text, patchKey, patchIndex, Dispatcher.toPatchUnified(patchKey), super(text, patchKey, patchIndex, Dispatcher.toPatchUnified(patchKey),
patchSetDetail, parentPatchTable); patchSetDetail, parentPatchTable, null);
} }
} }
} }

View File

@@ -105,6 +105,9 @@ public class AccountDiffPreference {
@Column(id = 12) @Column(id = 12)
protected boolean expandAllComments; protected boolean expandAllComments;
@Column(id = 13)
protected boolean retainHeader;
protected AccountDiffPreference() { protected AccountDiffPreference() {
} }
@@ -125,6 +128,7 @@ public class AccountDiffPreference {
this.skipUncommented = p.skipUncommented; this.skipUncommented = p.skipUncommented;
this.expandAllComments = p.expandAllComments; this.expandAllComments = p.expandAllComments;
this.context = p.context; this.context = p.context;
this.retainHeader = p.retainHeader;
} }
public Account.Id getAccountId() { public Account.Id getAccountId() {
@@ -221,4 +225,12 @@ public class AccountDiffPreference {
public void setExpandAllComments(boolean expand) { public void setExpandAllComments(boolean expand) {
expandAllComments = expand; expandAllComments = expand;
} }
public boolean isRetainHeader() {
return retainHeader;
}
public void setRetainHeader(boolean retain) {
retainHeader = retain;
}
} }

View File

@@ -32,7 +32,7 @@ import java.util.List;
/** A version of the database schema. */ /** A version of the database schema. */
public abstract class SchemaVersion { public abstract class SchemaVersion {
/** The current schema version. */ /** The current schema version. */
private static final Class<? extends SchemaVersion> C = Schema_57.class; private static final Class<? extends SchemaVersion> C = Schema_58.class;
public static class Module extends AbstractModule { public static class Module extends AbstractModule {
@Override @Override

View File

@@ -0,0 +1,25 @@
// Copyright (C) 2011 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.server.schema;
import com.google.inject.Inject;
import com.google.inject.Provider;
public class Schema_58 extends SchemaVersion {
@Inject
Schema_58(Provider<Schema_57> prior) {
super(prior);
}
}