diff --git a/Documentation/images/user-review-ui-side-by-side-diff-screen-preferences-popup.png b/Documentation/images/user-review-ui-side-by-side-diff-screen-preferences-popup.png index 35e29a3aa0..043c1ff921 100644 Binary files a/Documentation/images/user-review-ui-side-by-side-diff-screen-preferences-popup.png and b/Documentation/images/user-review-ui-side-by-side-diff-screen-preferences-popup.png differ diff --git a/Documentation/rest-api-accounts.txt b/Documentation/rest-api-accounts.txt index 11a482f614..b1f6bcc3e5 100644 --- a/Documentation/rest-api-accounts.txt +++ b/Documentation/rest-api-accounts.txt @@ -1417,48 +1417,51 @@ The `DiffPreferencesInfo` entity contains information about the diff preferences of a user. [options="header",width="50%",cols="1,^1,5"] -|===================================== -|Field Name ||Description -|`context` || +|=========================================== +|Field Name ||Description +|`context` || The number of lines of context when viewing a patch. -|`expand_all_comments` |not set if `false`| +|`expand_all_comments` |not set if `false`| Whether all inline comments should be automatically expanded. -|`ignore_whitespace` || +|`ignore_whitespace` || Whether whitespace changes should be ignored and if yes, which whitespace changes should be ignored. + Allowed values are `IGNORE_NONE`, `IGNORE_SPACE_AT_EOL`, `IGNORE_SPACE_CHANGE`, `IGNORE_ALL_SPACE`. -|`intraline_difference` |not set if `false`| +|`intraline_difference` |not set if `false`| Whether intraline differences should be highlighted. -|`line_length` || +|`line_length` || Number of characters that should be displayed in one line. -|`manual_review` |not set if `false`| +|`manual_review` |not set if `false`| Whether the 'Reviewed' flag should not be set automatically on a patch when it is viewed. -|`retain_header` |not set if `false`| +|`retain_header` |not set if `false`| Whether the header that is displayed above the patch (that either shows the commit message, the diff preferences, the patch sets or the files) should be retained on file switch. -|`show_line_endings` |not set if `false`| +|`show_line_endings` |not set if `false`| Whether Windows EOL/Cr-Lf should be displayed as '\r' in a dotted-line box. -|`show_tabs` |not set if `false`| +|`show_tabs` |not set if `false`| Whether tabs should be shown. -|`show_whitespace_errors`|not set if `false`| +|`show_whitespace_errors` |not set if `false`| Whether whitespace errors should be shown. -|`skip_deleted` |not set if `false`| +|`skip_deleted` |not set if `false`| Whether deleted files should be skipped on file switch. -|`skip_uncommented` |not set if `false`| +|`skip_uncommented` |not set if `false`| Whether uncommented files should be skipped on file switch. -|`syntax_highlighting` |not set if `false`| +|`syntax_highlighting` |not set if `false`| Whether syntax highlighting should be enabled. -|`hide_top_menu` |not set if `false`| +|`hide_top_menu` |not set if `false`| If true the top menu header and site header is hidden. -|`hide_line_numbers` |not set if `false`| +|`auto_hide_diff_table_header` |not set if `false`| +If true the diff table header is automatically hidden when +scrolling down more than half of a page. +|`hide_line_numbers` |not set if `false`| If true the line numbers are hidden. -|`tab_size` || +|`tab_size` || Number of spaces that should be used to display one tab. -|===================================== +|=========================================== [[diff-preferences-input]] === DiffPreferencesInput @@ -1467,48 +1470,51 @@ diff preferences of a user. Fields which are not set will not be updated. [options="header",width="50%",cols="1,^1,5"] -|===================================== -|Field Name ||Description -|`context` |optional| +|=========================================== +|Field Name ||Description +|`context` |optional| The number of lines of context when viewing a patch. -|`expand_all_comments` |optional| +|`expand_all_comments` |optional| Whether all inline comments should be automatically expanded. -|`ignore_whitespace` |optional| +|`ignore_whitespace` |optional| Whether whitespace changes should be ignored and if yes, which whitespace changes should be ignored. + Allowed values are `IGNORE_NONE`, `IGNORE_SPACE_AT_EOL`, `IGNORE_SPACE_CHANGE`, `IGNORE_ALL_SPACE`. -|`intraline_difference` |optional| +|`intraline_difference` |optional| Whether intraline differences should be highlighted. -|`line_length` |optional| +|`line_length` |optional| Number of characters that should be displayed in one line. -|`manual_review` |optional| +|`manual_review` |optional| Whether the 'Reviewed' flag should not be set automatically on a patch when it is viewed. -|`retain_header` |optional| +|`retain_header` |optional| Whether the header that is displayed above the patch (that either shows the commit message, the diff preferences, the patch sets or the files) should be retained on file switch. -|`show_line_endings` |optional| +|`show_line_endings` |optional| Whether Windows EOL/Cr-Lf should be displayed as '\r' in a dotted-line box. -|`show_tabs` |optional| +|`show_tabs` |optional| Whether tabs should be shown. -|`show_whitespace_errors`|optional| +|`show_whitespace_errors` |optional| Whether whitespace errors should be shown. -|`skip_deleted` |optional| +|`skip_deleted` |optional| Whether deleted files should be skipped on file switch. -|`skip_uncommented` |optional| +|`skip_uncommented` |optional| Whether uncommented files should be skipped on file switch. -|`syntax_highlighting` |optional| +|`syntax_highlighting` |optional| Whether syntax highlighting should be enabled. -|`hide_top_menu` |optional| +|`hide_top_menu` |optional| True if the top menu header and site header should be hidden. -|`hide_line_numbers` |optional| +|`auto_hide_diff_table_header` |optional| +True if the diff table header is automatically hidden when +scrolling down more than half of a page. +|`hide_line_numbers` |optional| True if the line numbers should be hidden. -|`tab_size` |optional| +|`tab_size` |optional| Number of spaces that should be used to display one tab. -|===================================== +|=========================================== [[email-info]] === EmailInfo diff --git a/Documentation/user-review-ui.txt b/Documentation/user-review-ui.txt index bb1aeefffc..3d5e418ffa 100644 --- a/Documentation/user-review-ui.txt +++ b/Documentation/user-review-ui.txt @@ -1046,6 +1046,11 @@ patch diff is opened, this preference is reset to `Show`. + Controls whether the top menu is shown. +- `Auto Hide Diff Table Header`: ++ +Controls whether the diff table header should be automatically hidden +when scrolling down more than half of a page. + [[mark-reviewed]] - `Mark Reviewed`: + diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/DiffPreferences.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/DiffPreferences.java index 8a4666b412..029e7c2aa4 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/DiffPreferences.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/DiffPreferences.java @@ -35,6 +35,7 @@ public class DiffPreferences extends JavaScriptObject { p.showWhitespaceErrors(in.isShowWhitespaceErrors()); p.syntaxHighlighting(in.isSyntaxHighlighting()); p.hideTopMenu(in.isHideTopMenu()); + p.autoHideDiffTableHeader(in.isAutoHideDiffTableHeader()); p.hideLineNumbers(in.isHideLineNumbers()); p.expandAllComments(in.isExpandAllComments()); p.manualReview(in.isManualReview()); @@ -55,6 +56,7 @@ public class DiffPreferences extends JavaScriptObject { p.setShowWhitespaceErrors(showWhitespaceErrors()); p.setSyntaxHighlighting(syntaxHighlighting()); p.setHideTopMenu(hideTopMenu()); + p.setAutoHideDiffTableHeader(autoHideDiffTableHeader()); p.setHideLineNumbers(hideLineNumbers()); p.setExpandAllComments(expandAllComments()); p.setManualReview(manualReview()); @@ -82,6 +84,7 @@ public class DiffPreferences extends JavaScriptObject { public final native void showWhitespaceErrors(boolean s) /*-{ this.show_whitespace_errors = s }-*/; public final native void syntaxHighlighting(boolean s) /*-{ this.syntax_highlighting = s }-*/; public final native void hideTopMenu(boolean s) /*-{ this.hide_top_menu = s }-*/; + public final native void autoHideDiffTableHeader(boolean s) /*-{ this.auto_hide_diff_table_header = s }-*/; public final native void hideLineNumbers(boolean s) /*-{ this.hide_line_numbers = s }-*/; public final native void expandAllComments(boolean e) /*-{ this.expand_all_comments = e }-*/; public final native void manualReview(boolean r) /*-{ this.manual_review = r }-*/; @@ -110,6 +113,7 @@ public class DiffPreferences extends JavaScriptObject { public final native boolean showWhitespaceErrors() /*-{ return this.show_whitespace_errors || false }-*/; public final native boolean syntaxHighlighting() /*-{ return this.syntax_highlighting || false }-*/; public final native boolean hideTopMenu() /*-{ return this.hide_top_menu || false }-*/; + public final native boolean autoHideDiffTableHeader() /*-{ return this.auto_hide_diff_table_header || false }-*/; public final native boolean hideLineNumbers() /*-{ return this.hide_line_numbers || false }-*/; public final native boolean expandAllComments() /*-{ return this.expand_all_comments || false }-*/; public final native boolean manualReview() /*-{ return this.manual_review || false }-*/; diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/DiffTable.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/DiffTable.java index 78d3e4f1ec..2cf2f51aef 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/DiffTable.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/DiffTable.java @@ -80,6 +80,7 @@ class DiffTable extends Composite { private SideBySide2 parent; private boolean header; private boolean headerVisible; + private boolean autoHideHeader; private boolean visibleA; private ChangeType changeType; @@ -134,7 +135,11 @@ class DiffTable extends Composite { } void setHeaderVisible(boolean show) { - headerVisible = show; + headerVisible = !autoHideHeader || show; + showHeader(headerVisible); + } + + private void showHeader(boolean show) { UIObject.setVisible(patchSetNavRow, show); UIObject.setVisible(diffHeaderRow, show && header); if (show) { @@ -145,6 +150,13 @@ class DiffTable extends Composite { parent.resizeCodeMirror(); } + void setAutoHideDiffHeader(boolean hide) { + autoHideHeader = hide; + if (!hide) { + showHeader(true); + } + } + int getHeaderHeight() { int h = patchSetSelectBoxA.getOffsetHeight(); if (header) { @@ -159,6 +171,7 @@ class DiffTable extends Composite { void set(DiffPreferences prefs, JsArray list, DiffInfo info) { this.changeType = info.change_type(); + this.autoHideHeader = prefs.autoHideDiffTableHeader(); patchSetSelectBoxA.setUpPatchSetNav(list, info.meta_a(), Natives.asList(info.web_links_a())); patchSetSelectBoxB.setUpPatchSetNav(list, info.meta_b(), diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/PreferencesBox.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/PreferencesBox.java index ac11cd5c50..0978d1303a 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/PreferencesBox.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/PreferencesBox.java @@ -90,6 +90,7 @@ class PreferencesBox extends Composite { @UiField ToggleButton leftSide; @UiField ToggleButton emptyPane; @UiField ToggleButton topMenu; + @UiField ToggleButton autoHideDiffTableHeader; @UiField ToggleButton manualReview; @UiField ToggleButton expandAllComments; @UiField ToggleButton renderEntireFile; @@ -157,6 +158,7 @@ class PreferencesBox extends Composite { leftSide.setEnabled(!(prefs.hideEmptyPane() && view.diffTable.getChangeType() == ChangeType.ADDED)); topMenu.setValue(!prefs.hideTopMenu()); + autoHideDiffTableHeader.setValue(!prefs.autoHideDiffTableHeader()); manualReview.setValue(prefs.manualReview()); expandAllComments.setValue(prefs.expandAllComments()); renderEntireFile.setValue(prefs.renderEntireFile()); @@ -322,6 +324,13 @@ class PreferencesBox extends Composite { view.resizeCodeMirror(); } + @UiHandler("autoHideDiffTableHeader") + void onAutoHideDiffTableHeader(ValueChangeEvent e) { + prefs.autoHideDiffTableHeader(!e.getValue()); + view.setAutoHideDiffHeader(!e.getValue()); + view.resizeCodeMirror(); + } + @UiHandler("manualReview") void onManualReview(ValueChangeEvent e) { prefs.manualReview(e.getValue()); diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/PreferencesBox.ui.xml b/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/PreferencesBox.ui.xml index af539165e3..2f22cddf30 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/PreferencesBox.ui.xml +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/PreferencesBox.ui.xml @@ -249,6 +249,13 @@ limitations under the License. Show + + Auto Hide Diff Table Header + + Yes + No + + Mark Reviewed diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/SideBySide2.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/SideBySide2.java index 2d276d6db4..1f843bba53 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/SideBySide2.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/SideBySide2.java @@ -715,6 +715,10 @@ public class SideBySide2 extends Screen { }); } + void setAutoHideDiffHeader(boolean hide) { + diffTable.setAutoHideDiffHeader(hide); + } + private void render(DiffInfo diff) { header.setNoDiff(diff); chunkManager.render(diff); diff --git a/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/AccountDiffPreference.java b/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/AccountDiffPreference.java index cf951c1e20..6bdd4b06ac 100644 --- a/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/AccountDiffPreference.java +++ b/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/AccountDiffPreference.java @@ -92,6 +92,7 @@ public class AccountDiffPreference { p.setContext(DEFAULT_CONTEXT); p.setManualReview(false); p.setHideEmptyPane(false); + p.setAutoHideDiffTableHeader(true); return p; } @@ -156,6 +157,9 @@ public class AccountDiffPreference { @Column(id = 20) protected boolean hideEmptyPane; + @Column(id = 21) + protected boolean autoHideDiffTableHeader; + protected AccountDiffPreference() { } @@ -183,6 +187,7 @@ public class AccountDiffPreference { this.hideLineNumbers = p.hideLineNumbers; this.renderEntireFile = p.renderEntireFile; this.hideEmptyPane = p.hideEmptyPane; + this.autoHideDiffTableHeader = p.autoHideDiffTableHeader; } public Account.Id getAccountId() { @@ -343,4 +348,12 @@ public class AccountDiffPreference { public void setHideEmptyPane(boolean hideEmptyPane) { this.hideEmptyPane = hideEmptyPane; } + + public void setAutoHideDiffTableHeader(boolean hide) { + autoHideDiffTableHeader = hide; + } + + public boolean isAutoHideDiffTableHeader() { + return autoHideDiffTableHeader; + } } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/account/GetDiffPreferences.java b/gerrit-server/src/main/java/com/google/gerrit/server/account/GetDiffPreferences.java index 5959fac306..7169e91af8 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/account/GetDiffPreferences.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/account/GetDiffPreferences.java @@ -70,6 +70,7 @@ public class GetDiffPreferences implements RestReadView { info.skipDeleted = p.isSkipDeleted() ? true : null; info.skipUncommented = p.isSkipUncommented() ? true : null; info.hideTopMenu = p.isHideTopMenu() ? true : null; + info.autoHideDiffTableHeader = p.isAutoHideDiffTableHeader() ? true : null; info.hideLineNumbers = p.isHideLineNumbers() ? true : null; info.syntaxHighlighting = p.isSyntaxHighlighting() ? true : null; info.tabSize = p.getTabSize(); @@ -93,6 +94,7 @@ public class GetDiffPreferences implements RestReadView { public Boolean skipUncommented; public Boolean syntaxHighlighting; public Boolean hideTopMenu; + public Boolean autoHideDiffTableHeader; public Boolean hideLineNumbers; public Boolean renderEntireFile; public Boolean hideEmptyPane; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/account/SetDiffPreferences.java b/gerrit-server/src/main/java/com/google/gerrit/server/account/SetDiffPreferences.java index 08386b2588..d922faf08e 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/account/SetDiffPreferences.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/account/SetDiffPreferences.java @@ -48,6 +48,7 @@ public class SetDiffPreferences implements RestModifyView C = Schema_98.class; + public static final Class C = Schema_99.class; public static class Module extends AbstractModule { @Override diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_99.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_99.java new file mode 100644 index 0000000000..b7fab7f659 --- /dev/null +++ b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_99.java @@ -0,0 +1,25 @@ +// Copyright (C) 2014 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_99 extends SchemaVersion { + @Inject + Schema_99(Provider prior) { + super(prior); + } +}