SideBySide2: Add preference to hide line numbers
The line number gutters take up 60px of horizontal space. On a very narrow display such as a monitor turned into portrait mode users may find the 60px too much wasted width and be unable to read the code. Allow the line numbers to be turned off. Change-Id: Id8431f68c2033618d515b03b13b4d82e29579db3
This commit is contained in:
		@@ -1232,6 +1232,10 @@ Whether deleted files should be skipped on file switch.
 | 
			
		||||
Whether uncommented files should be skipped on file switch.
 | 
			
		||||
|`syntax_highlighting`   |not set if `false`|
 | 
			
		||||
Whether syntax highlighting should be enabled.
 | 
			
		||||
|`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`|
 | 
			
		||||
If true the line numbers are hidden.
 | 
			
		||||
|`tab_size`              ||
 | 
			
		||||
Number of spaces that should be used to display one tab.
 | 
			
		||||
|=====================================
 | 
			
		||||
@@ -1279,6 +1283,10 @@ Whether deleted files should be skipped on file switch.
 | 
			
		||||
Whether uncommented files should be skipped on file switch.
 | 
			
		||||
|`syntax_highlighting`   |optional|
 | 
			
		||||
Whether syntax highlighting should be enabled.
 | 
			
		||||
|`hide_top_menu`         |optional|
 | 
			
		||||
True if the top menu header and site header should be hidden.
 | 
			
		||||
|`hide_line_numbers`     |optional|
 | 
			
		||||
True if the line numbers should be hidden.
 | 
			
		||||
|`tab_size`              |optional|
 | 
			
		||||
Number of spaces that should be used to display one tab.
 | 
			
		||||
|=====================================
 | 
			
		||||
 
 | 
			
		||||
@@ -33,6 +33,7 @@ public class DiffPreferences extends JavaScriptObject {
 | 
			
		||||
    p.showWhitespaceErrors(in.isShowWhitespaceErrors());
 | 
			
		||||
    p.syntaxHighlighting(in.isSyntaxHighlighting());
 | 
			
		||||
    p.hideTopMenu(in.isHideTopMenu());
 | 
			
		||||
    p.hideLineNumbers(in.isHideLineNumbers());
 | 
			
		||||
    p.expandAllComments(in.isExpandAllComments());
 | 
			
		||||
    p.manualReview(in.isManualReview());
 | 
			
		||||
    return p;
 | 
			
		||||
@@ -48,6 +49,7 @@ public class DiffPreferences extends JavaScriptObject {
 | 
			
		||||
    p.setShowWhitespaceErrors(showWhitespaceErrors());
 | 
			
		||||
    p.setSyntaxHighlighting(syntaxHighlighting());
 | 
			
		||||
    p.setHideTopMenu(hideTopMenu());
 | 
			
		||||
    p.setHideLineNumbers(hideLineNumbers());
 | 
			
		||||
    p.setExpandAllComments(expandAllComments());
 | 
			
		||||
    p.setManualReview(manualReview());
 | 
			
		||||
  }
 | 
			
		||||
@@ -65,8 +67,10 @@ 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 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 }-*/;
 | 
			
		||||
  public final void showLineNumbers(boolean s) { hideLineNumbers(!s); }
 | 
			
		||||
 | 
			
		||||
  public final Whitespace ignoreWhitespace() {
 | 
			
		||||
    String s = ignoreWhitespaceRaw();
 | 
			
		||||
@@ -82,8 +86,10 @@ 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 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 }-*/;
 | 
			
		||||
  public final boolean showLineNumbers() { return !hideLineNumbers(); }
 | 
			
		||||
  public final boolean autoReview() { return !manualReview(); }
 | 
			
		||||
 | 
			
		||||
  private final native int get(String n, int d)
 | 
			
		||||
 
 | 
			
		||||
@@ -45,6 +45,7 @@ class DiffTable extends Composite {
 | 
			
		||||
    String range();
 | 
			
		||||
    String rangeHighlight();
 | 
			
		||||
    String showTabs();
 | 
			
		||||
    String showLineNumbers();
 | 
			
		||||
    String padding();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -61,6 +61,9 @@ limitations under the License.
 | 
			
		||||
    .a .CodeMirror-scroll { padding-right: 0; }
 | 
			
		||||
    .a .CodeMirror-vscrollbar { display: none !important; }
 | 
			
		||||
 | 
			
		||||
    .showLineNumbers .b { border-left: none; }
 | 
			
		||||
    .b { border-left: 1px solid #ddd; }
 | 
			
		||||
 | 
			
		||||
    .a .diff { background-color: #faa; }
 | 
			
		||||
    .b .diff { background-color: #9f9; }
 | 
			
		||||
    .a .intralineBg { background-color: #fee; }
 | 
			
		||||
@@ -109,7 +112,7 @@ limitations under the License.
 | 
			
		||||
      content: "\00bb";
 | 
			
		||||
      color: #f00;
 | 
			
		||||
    }
 | 
			
		||||
    .padding {
 | 
			
		||||
    .showLineNumbers .padding {
 | 
			
		||||
      margin-left: 21px;
 | 
			
		||||
      border-left: 2px solid #d64040;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -79,6 +79,7 @@ class PreferencesBox extends Composite {
 | 
			
		||||
  @UiField ToggleButton syntaxHighlighting;
 | 
			
		||||
  @UiField ToggleButton whitespaceErrors;
 | 
			
		||||
  @UiField ToggleButton showTabs;
 | 
			
		||||
  @UiField ToggleButton lineNumbers;
 | 
			
		||||
  @UiField ToggleButton topMenu;
 | 
			
		||||
  @UiField ToggleButton manualReview;
 | 
			
		||||
  @UiField ToggleButton expandAllComments;
 | 
			
		||||
@@ -127,6 +128,7 @@ class PreferencesBox extends Composite {
 | 
			
		||||
    syntaxHighlighting.setValue(prefs.syntaxHighlighting());
 | 
			
		||||
    whitespaceErrors.setValue(prefs.showWhitespaceErrors());
 | 
			
		||||
    showTabs.setValue(prefs.showTabs());
 | 
			
		||||
    lineNumbers.setValue(prefs.showLineNumbers());
 | 
			
		||||
    topMenu.setValue(!prefs.hideTopMenu());
 | 
			
		||||
    manualReview.setValue(prefs.manualReview());
 | 
			
		||||
    expandAllComments.setValue(prefs.expandAllComments());
 | 
			
		||||
@@ -238,6 +240,12 @@ class PreferencesBox extends Composite {
 | 
			
		||||
    view.setShowTabs(prefs.showTabs());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @UiHandler("lineNumbers")
 | 
			
		||||
  void onLineNumbers(ValueChangeEvent<Boolean> e) {
 | 
			
		||||
    prefs.showLineNumbers(e.getValue());
 | 
			
		||||
    view.setShowLineNumbers(prefs.showLineNumbers());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @UiHandler("topMenu")
 | 
			
		||||
  void onTopMenu(ValueChangeEvent<Boolean> e) {
 | 
			
		||||
    prefs.hideTopMenu(!e.getValue());
 | 
			
		||||
 
 | 
			
		||||
@@ -196,6 +196,13 @@ limitations under the License.
 | 
			
		||||
          <g:downFace><ui:msg>Show</ui:msg></g:downFace>
 | 
			
		||||
        </g:ToggleButton></td>
 | 
			
		||||
      </tr>
 | 
			
		||||
      <tr>
 | 
			
		||||
        <th><ui:msg>Line Numbers</ui:msg></th>
 | 
			
		||||
        <td><g:ToggleButton ui:field='lineNumbers'>
 | 
			
		||||
          <g:upFace><ui:msg>Hide</ui:msg></g:upFace>
 | 
			
		||||
          <g:downFace><ui:msg>Show</ui:msg></g:downFace>
 | 
			
		||||
        </g:ToggleButton></td>
 | 
			
		||||
      </tr>
 | 
			
		||||
      <tr>
 | 
			
		||||
        <th><ui:msg>Top Menu</ui:msg></th>
 | 
			
		||||
        <td><g:ToggleButton ui:field='topMenu'>
 | 
			
		||||
 
 | 
			
		||||
@@ -498,6 +498,9 @@ public class SideBySide2 extends Screen {
 | 
			
		||||
 | 
			
		||||
    setShowTabs(prefs.showTabs());
 | 
			
		||||
    setShowIntraline(prefs.intralineDifference());
 | 
			
		||||
    if (prefs.showLineNumbers()) {
 | 
			
		||||
      diffTable.addStyleName(DiffTable.style.showLineNumbers());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    cmA = createCodeMirror(diffInfo.meta_a(), diffInfo.text_a(), diffTable.cmA);
 | 
			
		||||
    cmB = createCodeMirror(diffInfo.meta_b(), diffInfo.text_b(), diffTable.cmB);
 | 
			
		||||
@@ -561,7 +564,7 @@ public class SideBySide2 extends Screen {
 | 
			
		||||
      .set("readOnly", true)
 | 
			
		||||
      .set("cursorBlinkRate", 0)
 | 
			
		||||
      .set("cursorHeight", 0.85)
 | 
			
		||||
      .set("lineNumbers", true)
 | 
			
		||||
      .set("lineNumbers", prefs.showLineNumbers())
 | 
			
		||||
      .set("tabSize", prefs.tabSize())
 | 
			
		||||
      .set("mode", largeFile ? null : getContentType(meta))
 | 
			
		||||
      .set("lineWrapping", false)
 | 
			
		||||
@@ -584,6 +587,16 @@ public class SideBySide2 extends Screen {
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  void setShowLineNumbers(boolean b) {
 | 
			
		||||
    cmA.setOption("lineNumbers", b);
 | 
			
		||||
    cmB.setOption("lineNumbers", b);
 | 
			
		||||
    if (b) {
 | 
			
		||||
      diffTable.addStyleName(DiffTable.style.showLineNumbers());
 | 
			
		||||
    } else {
 | 
			
		||||
      diffTable.removeStyleName(DiffTable.style.showLineNumbers());
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  void setShowIntraline(boolean b) {
 | 
			
		||||
    if (b && getIntraLineStatus() == DiffInfo.IntraLineStatus.OFF) {
 | 
			
		||||
      reloadDiffInfo();
 | 
			
		||||
 
 | 
			
		||||
@@ -119,6 +119,9 @@ public class AccountDiffPreference {
 | 
			
		||||
  @Column(id = 16)
 | 
			
		||||
  protected boolean hideTopMenu;
 | 
			
		||||
 | 
			
		||||
  @Column(id = 17)
 | 
			
		||||
  protected boolean hideLineNumbers;
 | 
			
		||||
 | 
			
		||||
  protected AccountDiffPreference() {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -143,6 +146,7 @@ public class AccountDiffPreference {
 | 
			
		||||
    this.retainHeader = p.retainHeader;
 | 
			
		||||
    this.manualReview = p.manualReview;
 | 
			
		||||
    this.hideTopMenu = p.hideTopMenu;
 | 
			
		||||
    this.hideLineNumbers = p.hideLineNumbers;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public Account.Id getAccountId() {
 | 
			
		||||
@@ -264,11 +268,19 @@ public class AccountDiffPreference {
 | 
			
		||||
    manualReview = manual;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public boolean isHideTopMenu() {
 | 
			
		||||
    return hideTopMenu;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public void setHideTopMenu(boolean hide) {
 | 
			
		||||
    hideTopMenu = hide;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public boolean isHideTopMenu() {
 | 
			
		||||
    return hideTopMenu;
 | 
			
		||||
  public boolean isHideLineNumbers() {
 | 
			
		||||
    return hideLineNumbers;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public void setHideLineNumbers(boolean hide) {
 | 
			
		||||
    hideLineNumbers = hide;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -67,6 +67,7 @@ public class GetDiffPreferences implements RestReadView<AccountResource> {
 | 
			
		||||
      info.skipDeleted = p.isSkipDeleted() ? true : null;
 | 
			
		||||
      info.skipUncommented = p.isSkipUncommented() ? true : null;
 | 
			
		||||
      info.hideTopMenu = p.isHideTopMenu() ? true : null;
 | 
			
		||||
      info.hideLineNumbers = p.isHideLineNumbers() ? true : null;
 | 
			
		||||
      info.syntaxHighlighting = p.isSyntaxHighlighting() ? true : null;
 | 
			
		||||
      info.tabSize = p.getTabSize();
 | 
			
		||||
      return info;
 | 
			
		||||
@@ -86,6 +87,7 @@ public class GetDiffPreferences implements RestReadView<AccountResource> {
 | 
			
		||||
    Boolean skipUncommented;
 | 
			
		||||
    Boolean syntaxHighlighting;
 | 
			
		||||
    Boolean hideTopMenu;
 | 
			
		||||
    Boolean hideLineNumbers;
 | 
			
		||||
    int tabSize;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -45,6 +45,7 @@ public class SetDiffPreferences implements RestModifyView<AccountResource, Input
 | 
			
		||||
    Boolean skipUncommented;
 | 
			
		||||
    Boolean syntaxHighlighting;
 | 
			
		||||
    Boolean hideTopMenu;
 | 
			
		||||
    Boolean hideLineNumbers;
 | 
			
		||||
    Integer tabSize;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -120,6 +121,9 @@ public class SetDiffPreferences implements RestModifyView<AccountResource, Input
 | 
			
		||||
      if (input.hideTopMenu != null) {
 | 
			
		||||
        p.setHideTopMenu(input.hideTopMenu);
 | 
			
		||||
      }
 | 
			
		||||
      if (input.hideLineNumbers != null) {
 | 
			
		||||
        p.setHideLineNumbers(input.hideLineNumbers);
 | 
			
		||||
      }
 | 
			
		||||
      if (input.tabSize != null) {
 | 
			
		||||
        p.setTabSize(input.tabSize);
 | 
			
		||||
      }
 | 
			
		||||
 
 | 
			
		||||
@@ -32,7 +32,7 @@ import java.util.List;
 | 
			
		||||
/** A version of the database schema. */
 | 
			
		||||
public abstract class SchemaVersion {
 | 
			
		||||
  /** The current schema version. */
 | 
			
		||||
  public static final Class<Schema_90> C = Schema_90.class;
 | 
			
		||||
  public static final Class<Schema_91> C = Schema_91.class;
 | 
			
		||||
 | 
			
		||||
  public static class Module extends AbstractModule {
 | 
			
		||||
    @Override
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,25 @@
 | 
			
		||||
// 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_91 extends SchemaVersion {
 | 
			
		||||
  @Inject
 | 
			
		||||
  Schema_91(Provider<Schema_90> prior) {
 | 
			
		||||
    super(prior);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user