Add settings screen for global diff preferences

The account preferences are available under the Settings menu, but not
the diff preferences. The diff preferences are only accessible from
the diff screen by clicking on the gear icon. It's confusing to users
that they cannot find all preferences under the Settings menu. This is
why it makes sense to make the diff preferences available in the
Settings menu too.

There are a few diff settings which are only applicable when looking
at a concrete file diff and which are not stored on server side
(show/hide left side, language). These settings are not available when
the diff preferences are accessed from the Settings menu.

The diff preferences in the Settings menu are rendered with the same
style as the diff preferences in the popup. This makes it easy for
users to see that these are actually the same settings, just accessed
through different paths.

Change-Id: I35f45a4784592b9ce2fe35d86fd6974acc14f5c6
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2015-10-07 14:40:10 +02:00
parent bd567a0d3b
commit 7b6af4ff35
8 changed files with 237 additions and 118 deletions

View File

@@ -25,6 +25,7 @@ import com.google.gwtorm.client.KeyUtil;
public class PageLinks { public class PageLinks {
public static final String SETTINGS = "/settings/"; public static final String SETTINGS = "/settings/";
public static final String SETTINGS_PREFERENCES = "/settings/preferences"; public static final String SETTINGS_PREFERENCES = "/settings/preferences";
public static final String SETTINGS_DIFF_PREFERENCES = "/settings/diff-preferences";
public static final String SETTINGS_SSHKEYS = "/settings/ssh-keys"; public static final String SETTINGS_SSHKEYS = "/settings/ssh-keys";
public static final String SETTINGS_GPGKEYS = "/settings/gpg-keys"; public static final String SETTINGS_GPGKEYS = "/settings/gpg-keys";
public static final String SETTINGS_HTTP_PASSWORD = "/settings/http-password"; public static final String SETTINGS_HTTP_PASSWORD = "/settings/http-password";

View File

@@ -28,6 +28,7 @@ import static com.google.gerrit.common.PageLinks.REGISTER;
import static com.google.gerrit.common.PageLinks.SETTINGS; import static com.google.gerrit.common.PageLinks.SETTINGS;
import static com.google.gerrit.common.PageLinks.SETTINGS_AGREEMENTS; import static com.google.gerrit.common.PageLinks.SETTINGS_AGREEMENTS;
import static com.google.gerrit.common.PageLinks.SETTINGS_CONTACT; import static com.google.gerrit.common.PageLinks.SETTINGS_CONTACT;
import static com.google.gerrit.common.PageLinks.SETTINGS_DIFF_PREFERENCES;
import static com.google.gerrit.common.PageLinks.SETTINGS_EXTENSION; import static com.google.gerrit.common.PageLinks.SETTINGS_EXTENSION;
import static com.google.gerrit.common.PageLinks.SETTINGS_GPGKEYS; import static com.google.gerrit.common.PageLinks.SETTINGS_GPGKEYS;
import static com.google.gerrit.common.PageLinks.SETTINGS_HTTP_PASSWORD; import static com.google.gerrit.common.PageLinks.SETTINGS_HTTP_PASSWORD;
@@ -41,6 +42,7 @@ import static com.google.gerrit.common.PageLinks.toChangeQuery;
import com.google.gerrit.client.account.MyAgreementsScreen; import com.google.gerrit.client.account.MyAgreementsScreen;
import com.google.gerrit.client.account.MyContactInformationScreen; import com.google.gerrit.client.account.MyContactInformationScreen;
import com.google.gerrit.client.account.MyDiffPreferencesScreen;
import com.google.gerrit.client.account.MyGpgKeysScreen; import com.google.gerrit.client.account.MyGpgKeysScreen;
import com.google.gerrit.client.account.MyGroupsScreen; import com.google.gerrit.client.account.MyGroupsScreen;
import com.google.gerrit.client.account.MyIdentitiesScreen; import com.google.gerrit.client.account.MyIdentitiesScreen;
@@ -527,6 +529,10 @@ public class Dispatcher {
return new MyPreferencesScreen(); return new MyPreferencesScreen();
} }
if (matchExact(SETTINGS_DIFF_PREFERENCES, token)) {
return new MyDiffPreferencesScreen();
}
if (matchExact(SETTINGS_PROJECTS, token)) { if (matchExact(SETTINGS_PROJECTS, token)) {
return new MyWatchedProjectsScreen(); return new MyWatchedProjectsScreen();
} }

View File

@@ -52,6 +52,7 @@ public interface AccountConstants extends Constants {
String tabAccountSummary(); String tabAccountSummary();
String tabAgreements(); String tabAgreements();
String tabContactInformation(); String tabContactInformation();
String tabDiffPreferences();
String tabGpgKeys(); String tabGpgKeys();
String tabHttpAccess(); String tabHttpAccess();
String tabMyGroups(); String tabMyGroups();

View File

@@ -38,6 +38,7 @@ changeScreenNewUi = New Screen
tabAccountSummary = Profile tabAccountSummary = Profile
tabAgreements = Agreements tabAgreements = Agreements
tabContactInformation = Contact Information tabContactInformation = Contact Information
tabDiffPreferences = Diff Preferences
tabGpgKeys = GPG Public Keys tabGpgKeys = GPG Public Keys
tabHttpAccess = HTTP Password tabHttpAccess = HTTP Password
tabMyGroups = Groups tabMyGroups = Groups

View File

@@ -0,0 +1,40 @@
// Copyright (C) 2015 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.client.account;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.diff.PreferencesBox;
import com.google.gwt.user.client.ui.FlowPanel;
public class MyDiffPreferencesScreen extends SettingsScreen {
@Override
protected void onInitUI() {
super.onInitUI();
PreferencesBox pb = new PreferencesBox(null);
pb.set(DiffPreferences.create(Gerrit.getAccountDiffPreference()));
FlowPanel p = new FlowPanel();
p.setStyleName(pb.getStyle().dialog());
p.add(pb);
add(p);
}
@Override
protected void onLoad() {
super.onLoad();
display();
}
}

View File

@@ -37,6 +37,7 @@ public abstract class SettingsScreen extends MenuScreen {
linkByGerrit(Util.C.tabAccountSummary(), PageLinks.SETTINGS); linkByGerrit(Util.C.tabAccountSummary(), PageLinks.SETTINGS);
linkByGerrit(Util.C.tabPreferences(), PageLinks.SETTINGS_PREFERENCES); linkByGerrit(Util.C.tabPreferences(), PageLinks.SETTINGS_PREFERENCES);
linkByGerrit(Util.C.tabDiffPreferences(), PageLinks.SETTINGS_DIFF_PREFERENCES);
linkByGerrit(Util.C.tabWatchedProjects(), PageLinks.SETTINGS_PROJECTS); linkByGerrit(Util.C.tabWatchedProjects(), PageLinks.SETTINGS_PROJECTS);
linkByGerrit(Util.C.tabContactInformation(), PageLinks.SETTINGS_CONTACT); linkByGerrit(Util.C.tabContactInformation(), PageLinks.SETTINGS_CONTACT);
if (Gerrit.info().hasSshd()) { if (Gerrit.info().hasSshd()) {

View File

@@ -35,6 +35,8 @@ import com.google.gerrit.reviewdb.client.AccountDiffPreference.Whitespace;
import com.google.gerrit.reviewdb.client.Patch; import com.google.gerrit.reviewdb.client.Patch;
import com.google.gerrit.reviewdb.client.Patch.ChangeType; import com.google.gerrit.reviewdb.client.Patch.ChangeType;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style.Visibility;
import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.KeyDownEvent; import com.google.gwt.event.dom.client.KeyDownEvent;
@@ -54,6 +56,7 @@ import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.ListBox; import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.PopupPanel; import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.ToggleButton; import com.google.gwt.user.client.ui.ToggleButton;
import com.google.gwt.user.client.ui.UIObject;
import net.codemirror.mode.ModeInfo; import net.codemirror.mode.ModeInfo;
import net.codemirror.mode.ModeInjector; import net.codemirror.mode.ModeInjector;
@@ -62,11 +65,11 @@ import net.codemirror.theme.ThemeLoader;
import java.util.Objects; import java.util.Objects;
/** Displays current diff preferences. */ /** Displays current diff preferences. */
class PreferencesBox extends Composite { public class PreferencesBox extends Composite {
interface Binder extends UiBinder<HTMLPanel, PreferencesBox> {} interface Binder extends UiBinder<HTMLPanel, PreferencesBox> {}
private static final Binder uiBinder = GWT.create(Binder.class); private static final Binder uiBinder = GWT.create(Binder.class);
interface Style extends CssResource { public interface Style extends CssResource {
String dialog(); String dialog();
} }
@@ -76,6 +79,7 @@ class PreferencesBox extends Composite {
private Timer updateContextTimer; private Timer updateContextTimer;
@UiField Style style; @UiField Style style;
@UiField Element header;
@UiField Anchor close; @UiField Anchor close;
@UiField ListBox ignoreWhitespace; @UiField ListBox ignoreWhitespace;
@UiField NpIntTextBox tabWidth; @UiField NpIntTextBox tabWidth;
@@ -87,6 +91,7 @@ class PreferencesBox extends Composite {
@UiField ToggleButton whitespaceErrors; @UiField ToggleButton whitespaceErrors;
@UiField ToggleButton showTabs; @UiField ToggleButton showTabs;
@UiField ToggleButton lineNumbers; @UiField ToggleButton lineNumbers;
@UiField Element leftSideLabel;
@UiField ToggleButton leftSide; @UiField ToggleButton leftSide;
@UiField ToggleButton emptyPane; @UiField ToggleButton emptyPane;
@UiField ToggleButton topMenu; @UiField ToggleButton topMenu;
@@ -95,17 +100,24 @@ class PreferencesBox extends Composite {
@UiField ToggleButton expandAllComments; @UiField ToggleButton expandAllComments;
@UiField ToggleButton renderEntireFile; @UiField ToggleButton renderEntireFile;
@UiField ListBox theme; @UiField ListBox theme;
@UiField Element modeLabel;
@UiField ListBox mode; @UiField ListBox mode;
@UiField Button apply; @UiField Button apply;
@UiField Button save; @UiField Button save;
PreferencesBox(SideBySide view) { public PreferencesBox(SideBySide view) {
this.view = view; this.view = view;
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
initIgnoreWhitespace(); initIgnoreWhitespace();
initTheme(); initTheme();
if (view != null) {
initMode(); initMode();
} else {
UIObject.setVisible(header, false);
apply.getElement().getStyle().setVisibility(Visibility.HIDDEN);
}
} }
@Override @Override
@@ -113,6 +125,8 @@ class PreferencesBox extends Composite {
super.onLoad(); super.onLoad();
save.setVisible(Gerrit.isSignedIn()); save.setVisible(Gerrit.isSignedIn());
if (view != null) {
addDomHandler(new KeyDownHandler() { addDomHandler(new KeyDownHandler() {
@Override @Override
public void onKeyDown(KeyDownEvent event) { public void onKeyDown(KeyDownEvent event) {
@@ -140,13 +154,18 @@ class PreferencesBox extends Composite {
} }
}; };
} }
}
void set(DiffPreferences prefs) { public Style getStyle() {
return style;
}
public void set(DiffPreferences prefs) {
this.prefs = prefs; this.prefs = prefs;
setIgnoreWhitespace(prefs.ignoreWhitespace()); setIgnoreWhitespace(prefs.ignoreWhitespace());
tabWidth.setIntValue(prefs.tabSize()); tabWidth.setIntValue(prefs.tabSize());
if (Patch.COMMIT_MSG.equals(view.getPath())) { if (view != null && Patch.COMMIT_MSG.equals(view.getPath())) {
lineLength.setEnabled(false); lineLength.setEnabled(false);
lineLength.setIntValue(72); lineLength.setIntValue(72);
} else { } else {
@@ -157,17 +176,22 @@ class PreferencesBox extends Composite {
whitespaceErrors.setValue(prefs.showWhitespaceErrors()); whitespaceErrors.setValue(prefs.showWhitespaceErrors());
showTabs.setValue(prefs.showTabs()); showTabs.setValue(prefs.showTabs());
lineNumbers.setValue(prefs.showLineNumbers()); lineNumbers.setValue(prefs.showLineNumbers());
leftSide.setValue(view.diffTable.isVisibleA());
emptyPane.setValue(!prefs.hideEmptyPane()); emptyPane.setValue(!prefs.hideEmptyPane());
if (view != null) {
leftSide.setValue(view.diffTable.isVisibleA());
leftSide.setEnabled(!(prefs.hideEmptyPane() leftSide.setEnabled(!(prefs.hideEmptyPane()
&& view.diffTable.getChangeType() == ChangeType.ADDED)); && view.diffTable.getChangeType() == ChangeType.ADDED));
} else {
UIObject.setVisible(leftSideLabel, false);
leftSide.setVisible(false);
}
topMenu.setValue(!prefs.hideTopMenu()); topMenu.setValue(!prefs.hideTopMenu());
autoHideDiffTableHeader.setValue(!prefs.autoHideDiffTableHeader()); autoHideDiffTableHeader.setValue(!prefs.autoHideDiffTableHeader());
manualReview.setValue(prefs.manualReview()); manualReview.setValue(prefs.manualReview());
expandAllComments.setValue(prefs.expandAllComments()); expandAllComments.setValue(prefs.expandAllComments());
setTheme(prefs.theme()); setTheme(prefs.theme());
if (view.canRenderEntireFile(prefs)) { if (view == null || view.canRenderEntireFile(prefs)) {
renderEntireFile.setValue(prefs.renderEntireFile()); renderEntireFile.setValue(prefs.renderEntireFile());
renderEntireFile.setEnabled(true); renderEntireFile.setEnabled(true);
} else { } else {
@@ -175,11 +199,17 @@ class PreferencesBox extends Composite {
renderEntireFile.setEnabled(false); renderEntireFile.setEnabled(false);
} }
if (view != null) {
mode.setEnabled(prefs.syntaxHighlighting()); mode.setEnabled(prefs.syntaxHighlighting());
if (prefs.syntaxHighlighting()) { if (prefs.syntaxHighlighting()) {
setMode(view.getCmFromSide(DisplaySide.B).getStringOption("mode")); setMode(view.getCmFromSide(DisplaySide.B).getStringOption("mode"));
} }
} else {
UIObject.setVisible(modeLabel, false);
mode.setVisible(false);
}
if (view != null) {
switch (view.getIntraLineStatus()) { switch (view.getIntraLineStatus()) {
case OFF: case OFF:
case OK: case OK:
@@ -192,6 +222,9 @@ class PreferencesBox extends Composite {
intralineDifference.setEnabled(false); intralineDifference.setEnabled(false);
break; break;
} }
} else {
intralineDifference.setValue(prefs.intralineDifference());
}
if (prefs.context() == WHOLE_FILE_CONTEXT) { if (prefs.context() == WHOLE_FILE_CONTEXT) {
contextLastValue = DEFAULT_CONTEXT; contextLastValue = DEFAULT_CONTEXT;
@@ -207,14 +240,18 @@ class PreferencesBox extends Composite {
void onIgnoreWhitespace(@SuppressWarnings("unused") ChangeEvent e) { void onIgnoreWhitespace(@SuppressWarnings("unused") ChangeEvent e) {
prefs.ignoreWhitespace(Whitespace.valueOf( prefs.ignoreWhitespace(Whitespace.valueOf(
ignoreWhitespace.getValue(ignoreWhitespace.getSelectedIndex()))); ignoreWhitespace.getValue(ignoreWhitespace.getSelectedIndex())));
if (view != null) {
view.reloadDiffInfo(); view.reloadDiffInfo();
} }
}
@UiHandler("intralineDifference") @UiHandler("intralineDifference")
void onIntralineDifference(ValueChangeEvent<Boolean> e) { void onIntralineDifference(ValueChangeEvent<Boolean> e) {
prefs.intralineDifference(e.getValue()); prefs.intralineDifference(e.getValue());
if (view != null) {
view.setShowIntraline(prefs.intralineDifference()); view.setShowIntraline(prefs.intralineDifference());
} }
}
@UiHandler("context") @UiHandler("context")
void onContextKey(KeyPressEvent e) { void onContextKey(KeyPressEvent e) {
@@ -239,8 +276,10 @@ class PreferencesBox extends Composite {
return; return;
} }
prefs.context(c); prefs.context(c);
if (view != null) {
updateContextTimer.schedule(200); updateContextTimer.schedule(200);
} }
}
@UiHandler("contextEntireFile") @UiHandler("contextEntireFile")
void onContextEntireFile(ValueChangeEvent<Boolean> e) { void onContextEntireFile(ValueChangeEvent<Boolean> e) {
@@ -257,14 +296,17 @@ class PreferencesBox extends Composite {
context.setFocus(true); context.setFocus(true);
context.setSelectionRange(0, context.getText().length()); context.setSelectionRange(0, context.getText().length());
} }
if (view != null) {
updateContextTimer.schedule(200); updateContextTimer.schedule(200);
} }
}
@UiHandler("tabWidth") @UiHandler("tabWidth")
void onTabWidth(ValueChangeEvent<String> e) { void onTabWidth(ValueChangeEvent<String> e) {
String v = e.getValue(); String v = e.getValue();
if (v != null && v.length() > 0) { if (v != null && v.length() > 0) {
prefs.tabSize(Math.max(1, Integer.parseInt(v))); prefs.tabSize(Math.max(1, Integer.parseInt(v)));
if (view != null) {
view.operation(new Runnable() { view.operation(new Runnable() {
@Override @Override
public void run() { public void run() {
@@ -275,12 +317,14 @@ class PreferencesBox extends Composite {
}); });
} }
} }
}
@UiHandler("lineLength") @UiHandler("lineLength")
void onLineLength(ValueChangeEvent<String> e) { void onLineLength(ValueChangeEvent<String> e) {
String v = e.getValue(); String v = e.getValue();
if (v != null && v.length() > 0) { if (v != null && v.length() > 0) {
prefs.lineLength(Math.max(1, Integer.parseInt(v))); prefs.lineLength(Math.max(1, Integer.parseInt(v)));
if (view != null) {
view.operation(new Runnable() { view.operation(new Runnable() {
@Override @Override
public void run() { public void run() {
@@ -289,23 +333,30 @@ class PreferencesBox extends Composite {
}); });
} }
} }
}
@UiHandler("expandAllComments") @UiHandler("expandAllComments")
void onExpandAllComments(ValueChangeEvent<Boolean> e) { void onExpandAllComments(ValueChangeEvent<Boolean> e) {
prefs.expandAllComments(e.getValue()); prefs.expandAllComments(e.getValue());
if (view != null) {
view.getCommentManager().setExpandAllComments(prefs.expandAllComments()); view.getCommentManager().setExpandAllComments(prefs.expandAllComments());
} }
}
@UiHandler("showTabs") @UiHandler("showTabs")
void onShowTabs(ValueChangeEvent<Boolean> e) { void onShowTabs(ValueChangeEvent<Boolean> e) {
prefs.showTabs(e.getValue()); prefs.showTabs(e.getValue());
if (view != null) {
view.setShowTabs(prefs.showTabs()); view.setShowTabs(prefs.showTabs());
} }
}
@UiHandler("lineNumbers") @UiHandler("lineNumbers")
void onLineNumbers(ValueChangeEvent<Boolean> e) { void onLineNumbers(ValueChangeEvent<Boolean> e) {
prefs.showLineNumbers(e.getValue()); prefs.showLineNumbers(e.getValue());
if (view != null) {
view.setShowLineNumbers(prefs.showLineNumbers()); view.setShowLineNumbers(prefs.showLineNumbers());
} }
}
@UiHandler("leftSide") @UiHandler("leftSide")
void onLeftSide(ValueChangeEvent<Boolean> e) { void onLeftSide(ValueChangeEvent<Boolean> e) {
@@ -315,6 +366,7 @@ class PreferencesBox extends Composite {
@UiHandler("emptyPane") @UiHandler("emptyPane")
void onHideEmptyPane(ValueChangeEvent<Boolean> e) { void onHideEmptyPane(ValueChangeEvent<Boolean> e) {
prefs.hideEmptyPane(!e.getValue()); prefs.hideEmptyPane(!e.getValue());
if (view != null) {
view.diffTable.setHideEmptyPane(prefs.hideEmptyPane()); view.diffTable.setHideEmptyPane(prefs.hideEmptyPane());
if (prefs.hideEmptyPane()) { if (prefs.hideEmptyPane()) {
if (view.diffTable.getChangeType() == ChangeType.ADDED) { if (view.diffTable.getChangeType() == ChangeType.ADDED) {
@@ -326,19 +378,24 @@ class PreferencesBox extends Composite {
leftSide.setEnabled(true); leftSide.setEnabled(true);
} }
} }
}
@UiHandler("topMenu") @UiHandler("topMenu")
void onTopMenu(ValueChangeEvent<Boolean> e) { void onTopMenu(ValueChangeEvent<Boolean> e) {
prefs.hideTopMenu(!e.getValue()); prefs.hideTopMenu(!e.getValue());
if (view != null) {
Gerrit.setHeaderVisible(!prefs.hideTopMenu()); Gerrit.setHeaderVisible(!prefs.hideTopMenu());
view.resizeCodeMirror(); view.resizeCodeMirror();
} }
}
@UiHandler("autoHideDiffTableHeader") @UiHandler("autoHideDiffTableHeader")
void onAutoHideDiffTableHeader(ValueChangeEvent<Boolean> e) { void onAutoHideDiffTableHeader(ValueChangeEvent<Boolean> e) {
prefs.autoHideDiffTableHeader(!e.getValue()); prefs.autoHideDiffTableHeader(!e.getValue());
if (view != null) {
view.setAutoHideDiffHeader(!e.getValue()); view.setAutoHideDiffHeader(!e.getValue());
} }
}
@UiHandler("manualReview") @UiHandler("manualReview")
void onManualReview(ValueChangeEvent<Boolean> e) { void onManualReview(ValueChangeEvent<Boolean> e) {
@@ -348,12 +405,14 @@ class PreferencesBox extends Composite {
@UiHandler("syntaxHighlighting") @UiHandler("syntaxHighlighting")
void onSyntaxHighlighting(ValueChangeEvent<Boolean> e) { void onSyntaxHighlighting(ValueChangeEvent<Boolean> e) {
prefs.syntaxHighlighting(e.getValue()); prefs.syntaxHighlighting(e.getValue());
if (view != null) {
mode.setEnabled(prefs.syntaxHighlighting()); mode.setEnabled(prefs.syntaxHighlighting());
if (prefs.syntaxHighlighting()) { if (prefs.syntaxHighlighting()) {
setMode(view.getContentType()); setMode(view.getContentType());
} }
view.setSyntaxHighlighting(prefs.syntaxHighlighting()); view.setSyntaxHighlighting(prefs.syntaxHighlighting());
} }
}
@UiHandler("mode") @UiHandler("mode")
void onMode(@SuppressWarnings("unused") ChangeEvent e) { void onMode(@SuppressWarnings("unused") ChangeEvent e) {
@@ -386,6 +445,7 @@ class PreferencesBox extends Composite {
@UiHandler("whitespaceErrors") @UiHandler("whitespaceErrors")
void onWhitespaceErrors(ValueChangeEvent<Boolean> e) { void onWhitespaceErrors(ValueChangeEvent<Boolean> e) {
prefs.showWhitespaceErrors(e.getValue()); prefs.showWhitespaceErrors(e.getValue());
if (view != null) {
view.operation(new Runnable() { view.operation(new Runnable() {
@Override @Override
public void run() { public void run() {
@@ -395,17 +455,21 @@ class PreferencesBox extends Composite {
} }
}); });
} }
}
@UiHandler("renderEntireFile") @UiHandler("renderEntireFile")
void onRenderEntireFile(ValueChangeEvent<Boolean> e) { void onRenderEntireFile(ValueChangeEvent<Boolean> e) {
prefs.renderEntireFile(e.getValue()); prefs.renderEntireFile(e.getValue());
if (view != null) {
view.updateRenderEntireFile(); view.updateRenderEntireFile();
} }
}
@UiHandler("theme") @UiHandler("theme")
void onTheme(@SuppressWarnings("unused") ChangeEvent e) { void onTheme(@SuppressWarnings("unused") ChangeEvent e) {
final Theme newTheme = getSelectedTheme(); final Theme newTheme = getSelectedTheme();
prefs.theme(newTheme); prefs.theme(newTheme);
if (view != null) {
ThemeLoader.loadTheme(newTheme, new GerritCallback<Void>() { ThemeLoader.loadTheme(newTheme, new GerritCallback<Void>() {
@Override @Override
public void onSuccess(Void result) { public void onSuccess(Void result) {
@@ -423,6 +487,7 @@ class PreferencesBox extends Composite {
} }
}); });
} }
}
private Theme getSelectedTheme() { private Theme getSelectedTheme() {
return Theme.valueOf(theme.getValue(theme.getSelectedIndex())); return Theme.valueOf(theme.getValue(theme.getSelectedIndex()));
@@ -446,8 +511,10 @@ class PreferencesBox extends Composite {
Gerrit.setAccountDiffPreference(p); Gerrit.setAccountDiffPreference(p);
} }
}); });
if (view != null) {
close(); close();
} }
}
@UiHandler("close") @UiHandler("close")
void onClose(ClickEvent e) { void onClose(ClickEvent e) {

View File

@@ -155,6 +155,7 @@ limitations under the License.
</ui:style> </ui:style>
<g:HTMLPanel styleName='{style.box}'> <g:HTMLPanel styleName='{style.box}'>
<div ui:field='header'>
<table style='width: 100%'> <table style='width: 100%'>
<tr> <tr>
<td><ui:msg>Diff Preferences</ui:msg></td> <td><ui:msg>Diff Preferences</ui:msg></td>
@@ -164,6 +165,7 @@ limitations under the License.
</tr> </tr>
</table> </table>
<hr/> <hr/>
</div>
<table class='{style.table}'> <table class='{style.table}'>
<tr> <tr>
<th><ui:msg>Theme</ui:msg></th> <th><ui:msg>Theme</ui:msg></th>
@@ -208,7 +210,7 @@ limitations under the License.
</g:ToggleButton></td> </g:ToggleButton></td>
</tr> </tr>
<tr> <tr>
<th><ui:msg>Language</ui:msg></th> <th><div ui:field='modeLabel'><ui:msg>Language</ui:msg></div></th>
<td><g:ListBox ui:field='mode'/></td> <td><g:ListBox ui:field='mode'/></td>
</tr> </tr>
<tr> <tr>
@@ -240,7 +242,7 @@ limitations under the License.
</g:ToggleButton></td> </g:ToggleButton></td>
</tr> </tr>
<tr> <tr>
<th><ui:msg>Left Side</ui:msg></th> <th><div ui:field='leftSideLabel'><ui:msg>Left Side</ui:msg></div></th>
<td><g:ToggleButton ui:field='leftSide'> <td><g:ToggleButton ui:field='leftSide'>
<g:upFace><ui:msg>Hide</ui:msg></g:upFace> <g:upFace><ui:msg>Hide</ui:msg></g:upFace>
<g:downFace><ui:msg>Show</ui:msg></g:downFace> <g:downFace><ui:msg>Show</ui:msg></g:downFace>