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

View File

@@ -102,6 +102,13 @@ public class Gerrit implements EntryPoint {
Window.Location.reload();
}
public static PatchScreen.TopView getPatchScreenTopView() {
if (patchScreen == null) {
return null;
}
return patchScreen.getTopView();
}
public static void displayLastChangeList() {
if (lastChangeListToken != null) {
display(lastChangeListToken);
@@ -615,8 +622,8 @@ public class Gerrit implements EntryPoint {
@Override
public void go() {
if (patchScreen != null) {
patchScreen.setTopView(PatchScreen.TopView.MAIN);
if (type == patchScreen.getPatchScreenType()) {
patchScreen.setTopView(PatchScreen.TopView.MAIN);
AnchorElement.as(getElement()).blur();
} else {
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 SideBySide(final Patch.Key id, final int patchIndex,
final PatchSetDetail patchSetDetail, final PatchTable patchTable) {
super(id, patchIndex, patchSetDetail, patchTable);
final PatchSetDetail patchSetDetail, final PatchTable patchTable,
final TopView topView) {
super(id, patchIndex, patchSetDetail, patchTable, topView);
}
@Override
@@ -69,8 +70,9 @@ public abstract class PatchScreen extends Screen implements
public static class Unified extends PatchScreen {
public Unified(final Patch.Key id, final int patchIndex,
final PatchSetDetail patchSetDetail, final PatchTable patchTable) {
super(id, patchIndex, patchSetDetail, patchTable);
final PatchSetDetail patchSetDetail, final PatchTable patchTable,
final TopView topView) {
super(id, patchIndex, patchSetDetail, patchTable, topView);
}
@Override
@@ -101,6 +103,7 @@ public abstract class PatchScreen extends Screen implements
protected PatchSet.Id idSideA;
protected PatchSet.Id idSideB;
protected PatchScriptSettingsPanel settingsPanel;
protected TopView topView;
private HistoryTable historyTable;
private FlowPanel topPanel;
@@ -131,10 +134,12 @@ public abstract class PatchScreen extends Screen implements
}
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;
patchSetDetail = detail;
fileList = patchTable;
topView = top;
if (patchTable != null) {
diffSideA = patchTable.getPatchSetIdToCompareWith();
@@ -343,6 +348,10 @@ public abstract class PatchScreen extends Screen implements
return fileList;
}
public TopView getTopView() {
return topView;
}
protected void refresh(final boolean isFirst) {
final int rpcseq = ++rpcSequence;
lastScript = null;
@@ -446,6 +455,9 @@ public abstract class PatchScreen extends Screen implements
intralineFailure = false;
new ErrorDialog(PatchUtil.C.intralineFailure()).show();
}
if (topView != null && prefs.get().isRetainHeader()) {
setTopView(topView);
}
}
private void showPatch(final boolean showPatch) {
@@ -468,6 +480,7 @@ public abstract class PatchScreen extends Screen implements
}
public void setTopView(TopView tv) {
topView = tv;
topPanel.clear();
switch(tv) {
case COMMIT: topPanel.add(commitMessageBlock);

View File

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

View File

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

View File

@@ -25,6 +25,7 @@ public class PatchLink extends InlineHyperlink {
protected int patchIndex;
protected PatchSetDetail patchSetDetail;
protected PatchTable parentPatchTable;
protected PatchScreen.TopView topView;
/**
* @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,
final int patchIndex, final String historyToken,
final PatchSetDetail patchSetDetail,
final PatchTable parentPatchTable) {
final PatchSetDetail patchSetDetail, final PatchTable parentPatchTable,
final PatchScreen.TopView topView) {
super(text, historyToken);
this.patchKey = patchKey;
this.patchIndex = patchIndex;
this.patchSetDetail = patchSetDetail;
this.parentPatchTable = parentPatchTable;
this.parentPatchTable = parentPatchTable;
this.topView = topView;
}
/**
@@ -57,7 +60,8 @@ public class PatchLink extends InlineHyperlink {
patchScreen.getPatchIndex(), //
Dispatcher.toPatch(type, patchScreen.getPatchKey()), //
patchScreen.getPatchSetDetail(), //
patchScreen.getFileList() //
patchScreen.getFileList(), //
patchScreen.getTopView() //
);
}
@@ -68,7 +72,8 @@ public class PatchLink extends InlineHyperlink {
patchKey, //
patchIndex, //
patchSetDetail, //
parentPatchTable //
parentPatchTable,
topView //
);
}
@@ -77,7 +82,7 @@ public class PatchLink extends InlineHyperlink {
final int patchIndex, PatchSetDetail patchSetDetail,
PatchTable parentPatchTable) {
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,
PatchTable parentPatchTable) {
super(text, patchKey, patchIndex, Dispatcher.toPatchUnified(patchKey),
patchSetDetail, parentPatchTable);
patchSetDetail, parentPatchTable, null);
}
}
}

View File

@@ -105,6 +105,9 @@ public class AccountDiffPreference {
@Column(id = 12)
protected boolean expandAllComments;
@Column(id = 13)
protected boolean retainHeader;
protected AccountDiffPreference() {
}
@@ -125,6 +128,7 @@ public class AccountDiffPreference {
this.skipUncommented = p.skipUncommented;
this.expandAllComments = p.expandAllComments;
this.context = p.context;
this.retainHeader = p.retainHeader;
}
public Account.Id getAccountId() {
@@ -221,4 +225,12 @@ public class AccountDiffPreference {
public void setExpandAllComments(boolean 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. */
public abstract class SchemaVersion {
/** 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 {
@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);
}
}