Add user preference to disable showing size bars in change tables

Some users dislike the rainbow colored bars in the change tables that
indicate the change sizes. Add a preference setting to allow users to
switch between colored bars and text representation of the change
size.

Bug: issue 2299
Change-Id: I689c3cebf21252d7f70a5df1d312c179189d10fc
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin
2013-12-06 08:43:22 +01:00
parent 6c0cae6972
commit 13e03a7631
9 changed files with 83 additions and 6 deletions

View File

@@ -38,6 +38,7 @@ public interface AccountConstants extends Constants {
String showUsernameInReviewCategory(); String showUsernameInReviewCategory();
String buttonSaveChanges(); String buttonSaveChanges();
String showRelativeDateInChangeTable(); String showRelativeDateInChangeTable();
String showSizeBarInChangeTable();
String changeScreenOldUi(); String changeScreenOldUi();
String changeScreenNewUi(); String changeScreenNewUi();

View File

@@ -17,7 +17,8 @@ diffViewLabel = Diff View (New Change Screen):
dateFormatLabel = Date/Time Format: dateFormatLabel = Date/Time Format:
contextWholeFile = Whole File contextWholeFile = Whole File
buttonSaveChanges = Save Changes buttonSaveChanges = Save Changes
showRelativeDateInChangeTable = Show Relative Dates in Changes Table showRelativeDateInChangeTable = Show Relative Dates In Changes Table
showSizeBarInChangeTable = Show Change Sizes As Colored Bars In Changes Table
changeScreenOldUi = Old Screen changeScreenOldUi = Old Screen
changeScreenNewUi = New Screen changeScreenNewUi = New Screen

View File

@@ -45,6 +45,7 @@ public class MyPreferencesScreen extends SettingsScreen {
private CheckBox reversePatchSetOrder; private CheckBox reversePatchSetOrder;
private CheckBox showUsernameInReviewCategory; private CheckBox showUsernameInReviewCategory;
private CheckBox relativeDateInChangeTable; private CheckBox relativeDateInChangeTable;
private CheckBox sizeBarInChangeTable;
private ListBox maximumPageSize; private ListBox maximumPageSize;
private ListBox dateFormat; private ListBox dateFormat;
private ListBox timeFormat; private ListBox timeFormat;
@@ -136,8 +137,9 @@ public class MyPreferencesScreen extends SettingsScreen {
} }
relativeDateInChangeTable = new CheckBox(Util.C.showRelativeDateInChangeTable()); relativeDateInChangeTable = new CheckBox(Util.C.showRelativeDateInChangeTable());
sizeBarInChangeTable = new CheckBox(Util.C.showSizeBarInChangeTable());
final Grid formGrid = new Grid(11, 2); final Grid formGrid = new Grid(12, 2);
int row = 0; int row = 0;
formGrid.setText(row, labelIdx, ""); formGrid.setText(row, labelIdx, "");
@@ -172,6 +174,10 @@ public class MyPreferencesScreen extends SettingsScreen {
formGrid.setText(row, labelIdx, ""); formGrid.setText(row, labelIdx, "");
formGrid.setWidget(row, fieldIdx, relativeDateInChangeTable); formGrid.setWidget(row, fieldIdx, relativeDateInChangeTable);
row++; row++;
formGrid.setText(row, labelIdx, "");
formGrid.setWidget(row, fieldIdx, sizeBarInChangeTable);
row++;
} }
formGrid.setText(row, labelIdx, Util.C.commentVisibilityLabel()); formGrid.setText(row, labelIdx, Util.C.commentVisibilityLabel());
@@ -208,6 +214,7 @@ public class MyPreferencesScreen extends SettingsScreen {
e.listenTo(dateFormat); e.listenTo(dateFormat);
e.listenTo(timeFormat); e.listenTo(timeFormat);
e.listenTo(relativeDateInChangeTable); e.listenTo(relativeDateInChangeTable);
e.listenTo(sizeBarInChangeTable);
e.listenTo(commentVisibilityStrategy); e.listenTo(commentVisibilityStrategy);
e.listenTo(changeScreen); e.listenTo(changeScreen);
e.listenTo(diffView); e.listenTo(diffView);
@@ -233,6 +240,7 @@ public class MyPreferencesScreen extends SettingsScreen {
dateFormat.setEnabled(on); dateFormat.setEnabled(on);
timeFormat.setEnabled(on); timeFormat.setEnabled(on);
relativeDateInChangeTable.setEnabled(on); relativeDateInChangeTable.setEnabled(on);
sizeBarInChangeTable.setEnabled(on);
commentVisibilityStrategy.setEnabled(on); commentVisibilityStrategy.setEnabled(on);
changeScreen.setEnabled(on); changeScreen.setEnabled(on);
diffView.setEnabled(on); diffView.setEnabled(on);
@@ -250,6 +258,7 @@ public class MyPreferencesScreen extends SettingsScreen {
setListBox(timeFormat, AccountGeneralPreferences.TimeFormat.HHMM_12, // setListBox(timeFormat, AccountGeneralPreferences.TimeFormat.HHMM_12, //
p.getTimeFormat()); p.getTimeFormat());
relativeDateInChangeTable.setValue(p.isRelativeDateInChangeTable()); relativeDateInChangeTable.setValue(p.isRelativeDateInChangeTable());
sizeBarInChangeTable.setValue(p.isSizeBarInChangeTable());
setListBox(commentVisibilityStrategy, setListBox(commentVisibilityStrategy,
AccountGeneralPreferences.CommentVisibilityStrategy.EXPAND_RECENT, AccountGeneralPreferences.CommentVisibilityStrategy.EXPAND_RECENT,
p.getCommentVisibilityStrategy()); p.getCommentVisibilityStrategy());
@@ -327,6 +336,7 @@ public class MyPreferencesScreen extends SettingsScreen {
AccountGeneralPreferences.TimeFormat.HHMM_12, AccountGeneralPreferences.TimeFormat.HHMM_12,
AccountGeneralPreferences.TimeFormat.values())); AccountGeneralPreferences.TimeFormat.values()));
p.setRelativeDateInChangeTable(relativeDateInChangeTable.getValue()); p.setRelativeDateInChangeTable(relativeDateInChangeTable.getValue());
p.setSizeBarInChangeTable(sizeBarInChangeTable.getValue());
p.setCommentVisibilityStrategy(getListBox(commentVisibilityStrategy, p.setCommentVisibilityStrategy(getListBox(commentVisibilityStrategy,
CommentVisibilityStrategy.EXPAND_RECENT, CommentVisibilityStrategy.EXPAND_RECENT,
CommentVisibilityStrategy.values())); CommentVisibilityStrategy.values()));

View File

@@ -237,9 +237,16 @@ public class ChangeTable2 extends NavigationTable<ChangeInfo> {
} }
int col = C_SIZE; int col = C_SIZE;
if (useNewFeatures) { if (useNewFeatures) {
table.setWidget(row, col, getSizeWidget(c)); if (Gerrit.isSignedIn()
fmt.getElement(row, col).setTitle( && !Gerrit.getUserAccount().getGeneralPreferences()
Util.M.insertionsAndDeletions(c.insertions(), c.deletions())); .isSizeBarInChangeTable()) {
table.setText(row, col,
Util.M.insertionsAndDeletions(c.insertions(), c.deletions()));
} else {
table.setWidget(row, col, getSizeWidget(c));
fmt.getElement(row, col).setTitle(
Util.M.insertionsAndDeletions(c.insertions(), c.deletions()));
}
col++; col++;
} }

View File

@@ -152,6 +152,9 @@ public final class AccountGeneralPreferences {
@Column(id = 15, length = 20, notNull = false) @Column(id = 15, length = 20, notNull = false)
protected String changeScreen; protected String changeScreen;
@Column(id = 16)
protected boolean sizeBarInChangeTable;
public AccountGeneralPreferences() { public AccountGeneralPreferences() {
} }
@@ -294,6 +297,14 @@ public final class AccountGeneralPreferences {
changeScreen = ui != null ? ui.name() : null; changeScreen = ui != null ? ui.name() : null;
} }
public boolean isSizeBarInChangeTable() {
return sizeBarInChangeTable;
}
public void setSizeBarInChangeTable(boolean sizeBarInChangeTable) {
this.sizeBarInChangeTable = sizeBarInChangeTable;
}
public void resetToDefaults() { public void resetToDefaults() {
maximumPageSize = DEFAULT_PAGESIZE; maximumPageSize = DEFAULT_PAGESIZE;
showSiteHeader = true; showSiteHeader = true;
@@ -309,5 +320,6 @@ public final class AccountGeneralPreferences {
commentVisibilityStrategy = null; commentVisibilityStrategy = null;
diffView = null; diffView = null;
changeScreen = null; changeScreen = null;
sizeBarInChangeTable = true;
} }
} }

View File

@@ -70,6 +70,7 @@ public class GetPreferences implements RestReadView<AccountResource> {
Boolean reversePatchSetOrder; Boolean reversePatchSetOrder;
Boolean showUsernameInReviewCategory; Boolean showUsernameInReviewCategory;
Boolean relativeDateInChangeTable; Boolean relativeDateInChangeTable;
Boolean sizeBarInChangeTable;
CommentVisibilityStrategy commentVisibilityStrategy; CommentVisibilityStrategy commentVisibilityStrategy;
DiffView diffView; DiffView diffView;
ChangeScreen changeScreen; ChangeScreen changeScreen;
@@ -86,6 +87,7 @@ public class GetPreferences implements RestReadView<AccountResource> {
reversePatchSetOrder = p.isReversePatchSetOrder() ? true : null; reversePatchSetOrder = p.isReversePatchSetOrder() ? true : null;
showUsernameInReviewCategory = p.isShowUsernameInReviewCategory() ? true : null; showUsernameInReviewCategory = p.isShowUsernameInReviewCategory() ? true : null;
relativeDateInChangeTable = p.isRelativeDateInChangeTable() ? true : null; relativeDateInChangeTable = p.isRelativeDateInChangeTable() ? true : null;
sizeBarInChangeTable = p.isSizeBarInChangeTable() ? true : null;
commentVisibilityStrategy = p.getCommentVisibilityStrategy(); commentVisibilityStrategy = p.getCommentVisibilityStrategy();
diffView = p.getDiffView(); diffView = p.getDiffView();
changeScreen = p.getChangeScreen(); changeScreen = p.getChangeScreen();

View File

@@ -47,6 +47,7 @@ public class SetPreferences implements RestModifyView<AccountResource, Input> {
Boolean reversePatchSetOrder; Boolean reversePatchSetOrder;
Boolean showUsernameInReviewCategory; Boolean showUsernameInReviewCategory;
Boolean relativeDateInChangeTable; Boolean relativeDateInChangeTable;
Boolean sizeBarInChangeTable;
CommentVisibilityStrategy commentVisibilityStrategy; CommentVisibilityStrategy commentVisibilityStrategy;
DiffView diffView; DiffView diffView;
} }
@@ -121,6 +122,9 @@ public class SetPreferences implements RestModifyView<AccountResource, Input> {
if (i.relativeDateInChangeTable != null) { if (i.relativeDateInChangeTable != null) {
p.setRelativeDateInChangeTable(i.relativeDateInChangeTable); p.setRelativeDateInChangeTable(i.relativeDateInChangeTable);
} }
if (i.sizeBarInChangeTable != null) {
p.setSizeBarInChangeTable(i.sizeBarInChangeTable);
}
if (i.commentVisibilityStrategy != null) { if (i.commentVisibilityStrategy != null) {
p.setCommentVisibilityStrategy(i.commentVisibilityStrategy); p.setCommentVisibilityStrategy(i.commentVisibilityStrategy);
} }

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. */
public static final Class<Schema_89> C = Schema_89.class; public static final Class<Schema_90> C = Schema_90.class;
public static class Module extends AbstractModule { public static class Module extends AbstractModule {
@Override @Override

View File

@@ -0,0 +1,40 @@
// 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.gerrit.reviewdb.server.ReviewDb;
import com.google.gwtorm.jdbc.JdbcSchema;
import com.google.inject.Inject;
import com.google.inject.Provider;
import java.sql.SQLException;
import java.sql.Statement;
public class Schema_90 extends SchemaVersion {
@Inject
Schema_90(Provider<Schema_89> prior) {
super(prior);
}
@Override
protected void migrateData(ReviewDb db, UpdateUI ui) throws SQLException {
Statement stmt = ((JdbcSchema) db).getConnection().createStatement();
try {
stmt.executeUpdate("UPDATE accounts set size_bar_in_change_table = 'Y'");
} finally {
stmt.close();
}
}
}