ChangeScreen2: Add preference to open side-by-side or unified diff view
A new user preference is added by which the user can decide which diff screen (CodeMirror Side-by-Side or Unified Diff) is opened when clicking on a file in ChangeScreen2. This preference doesn't apply to the old change screen. Bug: issue 2071 Change-Id: Ia1c7762c5559e383ad91ff0b8888c782b8134ef0 Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
@@ -80,6 +80,7 @@ import com.google.gerrit.client.ui.Screen;
|
|||||||
import com.google.gerrit.common.PageLinks;
|
import com.google.gerrit.common.PageLinks;
|
||||||
import com.google.gerrit.common.data.PatchSetDetail;
|
import com.google.gerrit.common.data.PatchSetDetail;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DiffView;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.Patch;
|
import com.google.gerrit.reviewdb.client.Patch;
|
||||||
@@ -603,6 +604,18 @@ public class Dispatcher {
|
|||||||
baseId //
|
baseId //
|
||||||
);
|
);
|
||||||
} else if ("cm".equals(panel)) {
|
} else if ("cm".equals(panel)) {
|
||||||
|
if (Gerrit.isSignedIn()
|
||||||
|
&& DiffView.UNIFIED_DIFF.equals(Gerrit.getUserAccount()
|
||||||
|
.getGeneralPreferences().getDiffView())) {
|
||||||
|
return new PatchScreen.Unified( //
|
||||||
|
id, //
|
||||||
|
patchIndex, //
|
||||||
|
patchSetDetail, //
|
||||||
|
patchTable, //
|
||||||
|
top, //
|
||||||
|
baseId //
|
||||||
|
);
|
||||||
|
}
|
||||||
return new SideBySide2(baseId, id.getParentKey(), id.get());
|
return new SideBySide2(baseId, id.getParentKey(), id.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -26,6 +26,7 @@ public interface AccountConstants extends Constants {
|
|||||||
String accountId();
|
String accountId();
|
||||||
|
|
||||||
String commentVisibilityLabel();
|
String commentVisibilityLabel();
|
||||||
|
String diffViewLabel();
|
||||||
String maximumPageSizeFieldLabel();
|
String maximumPageSizeFieldLabel();
|
||||||
String dateFormatLabel();
|
String dateFormatLabel();
|
||||||
String contextWholeFile();
|
String contextWholeFile();
|
||||||
|
@@ -12,6 +12,7 @@ reversePatchSetOrder = Display Patch Sets In Reverse Order
|
|||||||
showUsernameInReviewCategory = Display Person Name In Review Category
|
showUsernameInReviewCategory = Display Person Name In Review Category
|
||||||
maximumPageSizeFieldLabel = Maximum Page Size:
|
maximumPageSizeFieldLabel = Maximum Page Size:
|
||||||
commentVisibilityLabel = Comment Visibility:
|
commentVisibilityLabel = Comment Visibility:
|
||||||
|
diffViewLabel = Diff View (ChangeScreen2 only):
|
||||||
dateFormatLabel = Date/Time Format:
|
dateFormatLabel = Date/Time Format:
|
||||||
contextWholeFile = Whole File
|
contextWholeFile = Whole File
|
||||||
buttonSaveChanges = Save Changes
|
buttonSaveChanges = Save Changes
|
||||||
|
@@ -48,6 +48,7 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
private ListBox dateFormat;
|
private ListBox dateFormat;
|
||||||
private ListBox timeFormat;
|
private ListBox timeFormat;
|
||||||
private ListBox commentVisibilityStrategy;
|
private ListBox commentVisibilityStrategy;
|
||||||
|
private ListBox diffView;
|
||||||
private Button save;
|
private Button save;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -82,6 +83,16 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
AccountGeneralPreferences.CommentVisibilityStrategy.EXPAND_ALL.name()
|
AccountGeneralPreferences.CommentVisibilityStrategy.EXPAND_ALL.name()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
diffView = new ListBox();
|
||||||
|
diffView.addItem(
|
||||||
|
com.google.gerrit.client.changes.Util.C.sideBySide(),
|
||||||
|
AccountGeneralPreferences.DiffView.SIDE_BY_SIDE.name()
|
||||||
|
);
|
||||||
|
diffView.addItem(
|
||||||
|
com.google.gerrit.client.changes.Util.C.unifiedDiff(),
|
||||||
|
AccountGeneralPreferences.DiffView.UNIFIED_DIFF.name()
|
||||||
|
);
|
||||||
|
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
dateFormat = new ListBox();
|
dateFormat = new ListBox();
|
||||||
for (AccountGeneralPreferences.DateFormat fmt : AccountGeneralPreferences.DateFormat
|
for (AccountGeneralPreferences.DateFormat fmt : AccountGeneralPreferences.DateFormat
|
||||||
@@ -118,7 +129,7 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
|
|
||||||
relativeDateInChangeTable = new CheckBox(Util.C.showRelativeDateInChangeTable());
|
relativeDateInChangeTable = new CheckBox(Util.C.showRelativeDateInChangeTable());
|
||||||
|
|
||||||
final Grid formGrid = new Grid(9, 2);
|
final Grid formGrid = new Grid(10, 2);
|
||||||
|
|
||||||
int row = 0;
|
int row = 0;
|
||||||
formGrid.setText(row, labelIdx, "");
|
formGrid.setText(row, labelIdx, "");
|
||||||
@@ -157,6 +168,10 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
formGrid.setWidget(row, fieldIdx, commentVisibilityStrategy);
|
formGrid.setWidget(row, fieldIdx, commentVisibilityStrategy);
|
||||||
row++;
|
row++;
|
||||||
|
|
||||||
|
formGrid.setText(row, labelIdx, Util.C.diffViewLabel());
|
||||||
|
formGrid.setWidget(row, fieldIdx, diffView);
|
||||||
|
row++;
|
||||||
|
|
||||||
add(formGrid);
|
add(formGrid);
|
||||||
|
|
||||||
save = new Button(Util.C.buttonSaveChanges());
|
save = new Button(Util.C.buttonSaveChanges());
|
||||||
@@ -180,6 +195,7 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
e.listenTo(timeFormat);
|
e.listenTo(timeFormat);
|
||||||
e.listenTo(relativeDateInChangeTable);
|
e.listenTo(relativeDateInChangeTable);
|
||||||
e.listenTo(commentVisibilityStrategy);
|
e.listenTo(commentVisibilityStrategy);
|
||||||
|
e.listenTo(diffView);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -203,6 +219,7 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
timeFormat.setEnabled(on);
|
timeFormat.setEnabled(on);
|
||||||
relativeDateInChangeTable.setEnabled(on);
|
relativeDateInChangeTable.setEnabled(on);
|
||||||
commentVisibilityStrategy.setEnabled(on);
|
commentVisibilityStrategy.setEnabled(on);
|
||||||
|
diffView.setEnabled(on);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void display(final AccountGeneralPreferences p) {
|
private void display(final AccountGeneralPreferences p) {
|
||||||
@@ -220,6 +237,9 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
setListBox(commentVisibilityStrategy,
|
setListBox(commentVisibilityStrategy,
|
||||||
AccountGeneralPreferences.CommentVisibilityStrategy.EXPAND_RECENT,
|
AccountGeneralPreferences.CommentVisibilityStrategy.EXPAND_RECENT,
|
||||||
p.getCommentVisibilityStrategy());
|
p.getCommentVisibilityStrategy());
|
||||||
|
setListBox(diffView,
|
||||||
|
AccountGeneralPreferences.DiffView.SIDE_BY_SIDE,
|
||||||
|
p.getDiffView());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setListBox(final ListBox f, final short defaultValue,
|
private void setListBox(final ListBox f, final short defaultValue,
|
||||||
@@ -287,6 +307,9 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
p.setCommentVisibilityStrategy(getListBox(commentVisibilityStrategy,
|
p.setCommentVisibilityStrategy(getListBox(commentVisibilityStrategy,
|
||||||
CommentVisibilityStrategy.EXPAND_RECENT,
|
CommentVisibilityStrategy.EXPAND_RECENT,
|
||||||
CommentVisibilityStrategy.values()));
|
CommentVisibilityStrategy.values()));
|
||||||
|
p.setDiffView(getListBox(diffView,
|
||||||
|
AccountGeneralPreferences.DiffView.SIDE_BY_SIDE,
|
||||||
|
AccountGeneralPreferences.DiffView.values()));
|
||||||
|
|
||||||
enable(false);
|
enable(false);
|
||||||
save.setEnabled(false);
|
save.setEnabled(false);
|
||||||
|
@@ -126,6 +126,9 @@ public interface ChangeConstants extends Constants {
|
|||||||
String messageCollapseAll();
|
String messageCollapseAll();
|
||||||
String messageNeedsRebaseOrHasDependency();
|
String messageNeedsRebaseOrHasDependency();
|
||||||
|
|
||||||
|
String sideBySide();
|
||||||
|
String unifiedDiff();
|
||||||
|
|
||||||
String patchSetInfoAuthor();
|
String patchSetInfoAuthor();
|
||||||
String patchSetInfoCommitter();
|
String patchSetInfoCommitter();
|
||||||
String patchSetInfoDownload();
|
String patchSetInfoDownload();
|
||||||
|
@@ -104,6 +104,9 @@ messageExpandAll = Expand All
|
|||||||
messageCollapseAll = Collapse All
|
messageCollapseAll = Collapse All
|
||||||
messageNeedsRebaseOrHasDependency = Need Rebase or Has Dependency
|
messageNeedsRebaseOrHasDependency = Need Rebase or Has Dependency
|
||||||
|
|
||||||
|
sideBySide = Side by Side
|
||||||
|
unifiedDiff = Unified Diff
|
||||||
|
|
||||||
patchSetInfoAuthor = Author
|
patchSetInfoAuthor = Author
|
||||||
patchSetInfoCommitter = Committer
|
patchSetInfoCommitter = Committer
|
||||||
patchSetInfoDownload = Download
|
patchSetInfoDownload = Download
|
||||||
|
@@ -72,6 +72,11 @@ public final class AccountGeneralPreferences {
|
|||||||
EXPAND_ALL;
|
EXPAND_ALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static enum DiffView {
|
||||||
|
SIDE_BY_SIDE,
|
||||||
|
UNIFIED_DIFF
|
||||||
|
}
|
||||||
|
|
||||||
public static enum TimeFormat {
|
public static enum TimeFormat {
|
||||||
/** 12-hour clock: 1:15 am, 2:13 pm */
|
/** 12-hour clock: 1:15 am, 2:13 pm */
|
||||||
HHMM_12("h:mm a"),
|
HHMM_12("h:mm a"),
|
||||||
@@ -136,6 +141,9 @@ public final class AccountGeneralPreferences {
|
|||||||
@Column(id = 13, length = 20, notNull = false)
|
@Column(id = 13, length = 20, notNull = false)
|
||||||
protected String commentVisibilityStrategy;
|
protected String commentVisibilityStrategy;
|
||||||
|
|
||||||
|
@Column(id = 14, length = 20, notNull = false)
|
||||||
|
protected String diffView;
|
||||||
|
|
||||||
public AccountGeneralPreferences() {
|
public AccountGeneralPreferences() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,6 +267,17 @@ public final class AccountGeneralPreferences {
|
|||||||
commentVisibilityStrategy = strategy.name();
|
commentVisibilityStrategy = strategy.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DiffView getDiffView() {
|
||||||
|
if (diffView == null) {
|
||||||
|
return DiffView.SIDE_BY_SIDE;
|
||||||
|
}
|
||||||
|
return DiffView.valueOf(diffView);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDiffView(DiffView diffView) {
|
||||||
|
this.diffView = diffView.name();
|
||||||
|
}
|
||||||
|
|
||||||
public void resetToDefaults() {
|
public void resetToDefaults() {
|
||||||
maximumPageSize = DEFAULT_PAGESIZE;
|
maximumPageSize = DEFAULT_PAGESIZE;
|
||||||
showSiteHeader = true;
|
showSiteHeader = true;
|
||||||
@@ -271,5 +290,6 @@ public final class AccountGeneralPreferences {
|
|||||||
dateFormat = null;
|
dateFormat = null;
|
||||||
timeFormat = null;
|
timeFormat = null;
|
||||||
relativeDateInChangeTable = false;
|
relativeDateInChangeTable = false;
|
||||||
|
diffView = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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. */
|
||||||
public static final Class<Schema_82> C = Schema_82.class;
|
public static final Class<Schema_83> C = Schema_83.class;
|
||||||
|
|
||||||
public static class Module extends AbstractModule {
|
public static class Module extends AbstractModule {
|
||||||
@Override
|
@Override
|
||||||
|
@@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (C) 2013 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_83 extends SchemaVersion {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
Schema_83(Provider<Schema_82> prior) {
|
||||||
|
super(prior);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user