From cc4604ea517028478bed18cdcf3cdbeadd33c1bc Mon Sep 17 00:00:00 2001 From: Martin Fick Date: Wed, 29 Jun 2011 11:38:01 -0600 Subject: [PATCH] Add user pref to retain PatchScreen Header when changing files Change-Id: I199f79e9723a2296986fb0c042627c944dcb9288 --- .../com/google/gerrit/client/Dispatcher.java | 23 +++++++++++++---- .../java/com/google/gerrit/client/Gerrit.java | 9 ++++++- .../gerrit/client/patches/PatchScreen.java | 23 +++++++++++++---- .../patches/PatchScriptSettingsPanel.java | 4 +++ .../patches/PatchScriptSettingsPanel.ui.xml | 17 +++++++++---- .../google/gerrit/client/ui/PatchLink.java | 17 ++++++++----- .../reviewdb/AccountDiffPreference.java | 12 +++++++++ .../gerrit/server/schema/SchemaVersion.java | 2 +- .../gerrit/server/schema/Schema_58.java | 25 +++++++++++++++++++ 9 files changed, 109 insertions(+), 23 deletions(-) create mode 100644 gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_58.java diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/Dispatcher.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/Dispatcher.java index e4a9156d61..b439e6c9c3 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/Dispatcher.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/Dispatcher.java @@ -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 // ); } } diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/Gerrit.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/Gerrit.java index 4eab73d764..f77553489b 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/Gerrit.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/Gerrit.java @@ -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(); diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/PatchScreen.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/PatchScreen.java index dcfb34aea3..70df33e997 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/PatchScreen.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/PatchScreen.java @@ -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); diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/PatchScriptSettingsPanel.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/PatchScriptSettingsPanel.java index bce7f553c1..395ccdb296 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/PatchScriptSettingsPanel.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/PatchScriptSettingsPanel.java @@ -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); diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/PatchScriptSettingsPanel.ui.xml b/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/PatchScriptSettingsPanel.ui.xml index 8bda032f53..3ec546707d 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/PatchScriptSettingsPanel.ui.xml +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/PatchScriptSettingsPanel.ui.xml @@ -115,27 +115,34 @@ limitations under the License. - + +
+ + + + tabIndex='11'>
+ tabIndex='12'> @@ -145,7 +152,7 @@ limitations under the License. ui:field='update' text='Update' styleName='{style.updateButton}' - tabIndex='12'> + tabIndex='13'> @@ -154,7 +161,7 @@ limitations under the License. + tabIndex='14'> diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/PatchLink.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/PatchLink.java index 7f6de05ccf..502854089d 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/PatchLink.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/PatchLink.java @@ -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); } } } diff --git a/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/AccountDiffPreference.java b/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/AccountDiffPreference.java index ccfdbd5f2a..c362f2668c 100644 --- a/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/AccountDiffPreference.java +++ b/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/AccountDiffPreference.java @@ -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; + } } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/SchemaVersion.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/SchemaVersion.java index 480d719fae..c830b79fd4 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/SchemaVersion.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/schema/SchemaVersion.java @@ -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 C = Schema_57.class; + private static final Class C = Schema_58.class; public static class Module extends AbstractModule { @Override diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_58.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_58.java new file mode 100644 index 0000000000..72b0c8b448 --- /dev/null +++ b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_58.java @@ -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 prior) { + super(prior); + } +}