SideBySide2: Add Shift-a keybinding to show/hide left side
When a new file is added there is nothing to display on the left side. Some reviewers may prefer to fill the screen with the right side while reading the new code. Add a setting to toggle the visibility of the left side, and a keyboard binding of "Shift-a" to trigger this. The preference is not currently saved to prevent reviewers from missing deletions in modified files. Change-Id: Ic6659de6bdfb8b564a2cbcb2cc8ccab871af9e6a
This commit is contained in:
		@@ -47,6 +47,7 @@ class DiffTable extends Composite {
 | 
				
			|||||||
    String rangeHighlight();
 | 
					    String rangeHighlight();
 | 
				
			||||||
    String showTabs();
 | 
					    String showTabs();
 | 
				
			||||||
    String showLineNumbers();
 | 
					    String showLineNumbers();
 | 
				
			||||||
 | 
					    String hideA();
 | 
				
			||||||
    String columnMargin();
 | 
					    String columnMargin();
 | 
				
			||||||
    String padding();
 | 
					    String padding();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -68,6 +69,7 @@ class DiffTable extends Composite {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  private SideBySide2 parent;
 | 
					  private SideBySide2 parent;
 | 
				
			||||||
  private boolean headerVisible;
 | 
					  private boolean headerVisible;
 | 
				
			||||||
 | 
					  private boolean visibleA;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DiffTable(SideBySide2 parent, PatchSet.Id base, PatchSet.Id revision,
 | 
					  DiffTable(SideBySide2 parent, PatchSet.Id base, PatchSet.Id revision,
 | 
				
			||||||
      String path) {
 | 
					      String path) {
 | 
				
			||||||
@@ -80,6 +82,29 @@ class DiffTable extends Composite {
 | 
				
			|||||||
    initWidget(uiBinder.createAndBindUi(this));
 | 
					    initWidget(uiBinder.createAndBindUi(this));
 | 
				
			||||||
    this.parent = parent;
 | 
					    this.parent = parent;
 | 
				
			||||||
    this.headerVisible = true;
 | 
					    this.headerVisible = true;
 | 
				
			||||||
 | 
					    this.visibleA = true;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  boolean isVisibleA() {
 | 
				
			||||||
 | 
					    return visibleA;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void setVisibleA(boolean show) {
 | 
				
			||||||
 | 
					    visibleA = show;
 | 
				
			||||||
 | 
					    if (show) {
 | 
				
			||||||
 | 
					      removeStyleName(style.hideA());
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      addStyleName(style.hideA());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Runnable toggleA() {
 | 
				
			||||||
 | 
					    return new Runnable() {
 | 
				
			||||||
 | 
					      @Override
 | 
				
			||||||
 | 
					      public void run() {
 | 
				
			||||||
 | 
					        setVisibleA(!isVisibleA());
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  boolean isHeaderVisible() {
 | 
					  boolean isHeaderVisible() {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -52,6 +52,11 @@ limitations under the License.
 | 
				
			|||||||
      padding-bottom: 1px;
 | 
					      padding-bottom: 1px;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    .hideA .psNavA,
 | 
				
			||||||
 | 
					    .hideA .a {
 | 
				
			||||||
 | 
					      display: none;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    .table {
 | 
					    .table {
 | 
				
			||||||
      width: 100%;
 | 
					      width: 100%;
 | 
				
			||||||
      table-layout: fixed;
 | 
					      table-layout: fixed;
 | 
				
			||||||
@@ -156,7 +161,7 @@ limitations under the License.
 | 
				
			|||||||
  <g:HTMLPanel styleName='{style.difftable}'>
 | 
					  <g:HTMLPanel styleName='{style.difftable}'>
 | 
				
			||||||
    <table class='{style.table}'>
 | 
					    <table class='{style.table}'>
 | 
				
			||||||
      <tr ui:field='patchSetNavRow' class='{style.patchSetNav}'>
 | 
					      <tr ui:field='patchSetNavRow' class='{style.patchSetNav}'>
 | 
				
			||||||
        <td ui:field='patchSetNavCellA'>
 | 
					        <td ui:field='patchSetNavCellA' class='{style.psNavA}'>
 | 
				
			||||||
          <d:PatchSetSelectBox2 ui:field='patchSetSelectBoxA' />
 | 
					          <d:PatchSetSelectBox2 ui:field='patchSetSelectBoxA' />
 | 
				
			||||||
        </td>
 | 
					        </td>
 | 
				
			||||||
        <td ui:field='patchSetNavCellB'>
 | 
					        <td ui:field='patchSetNavCellB'>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -86,6 +86,7 @@ class PreferencesBox extends Composite {
 | 
				
			|||||||
  @UiField ToggleButton whitespaceErrors;
 | 
					  @UiField ToggleButton whitespaceErrors;
 | 
				
			||||||
  @UiField ToggleButton showTabs;
 | 
					  @UiField ToggleButton showTabs;
 | 
				
			||||||
  @UiField ToggleButton lineNumbers;
 | 
					  @UiField ToggleButton lineNumbers;
 | 
				
			||||||
 | 
					  @UiField ToggleButton leftSide;
 | 
				
			||||||
  @UiField ToggleButton topMenu;
 | 
					  @UiField ToggleButton topMenu;
 | 
				
			||||||
  @UiField ToggleButton manualReview;
 | 
					  @UiField ToggleButton manualReview;
 | 
				
			||||||
  @UiField ToggleButton expandAllComments;
 | 
					  @UiField ToggleButton expandAllComments;
 | 
				
			||||||
@@ -149,6 +150,7 @@ 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());
 | 
				
			||||||
    topMenu.setValue(!prefs.hideTopMenu());
 | 
					    topMenu.setValue(!prefs.hideTopMenu());
 | 
				
			||||||
    manualReview.setValue(prefs.manualReview());
 | 
					    manualReview.setValue(prefs.manualReview());
 | 
				
			||||||
    expandAllComments.setValue(prefs.expandAllComments());
 | 
					    expandAllComments.setValue(prefs.expandAllComments());
 | 
				
			||||||
@@ -288,6 +290,11 @@ class PreferencesBox extends Composite {
 | 
				
			|||||||
    view.setShowLineNumbers(prefs.showLineNumbers());
 | 
					    view.setShowLineNumbers(prefs.showLineNumbers());
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @UiHandler("leftSide")
 | 
				
			||||||
 | 
					  void onLeftSide(ValueChangeEvent<Boolean> e) {
 | 
				
			||||||
 | 
					    view.diffTable.setVisibleA(e.getValue());
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @UiHandler("topMenu")
 | 
					  @UiHandler("topMenu")
 | 
				
			||||||
  void onTopMenu(ValueChangeEvent<Boolean> e) {
 | 
					  void onTopMenu(ValueChangeEvent<Boolean> e) {
 | 
				
			||||||
    prefs.hideTopMenu(!e.getValue());
 | 
					    prefs.hideTopMenu(!e.getValue());
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -228,6 +228,13 @@ limitations under the License.
 | 
				
			|||||||
          <g:downFace><ui:msg>Show</ui:msg></g:downFace>
 | 
					          <g:downFace><ui:msg>Show</ui:msg></g:downFace>
 | 
				
			||||||
        </g:ToggleButton></td>
 | 
					        </g:ToggleButton></td>
 | 
				
			||||||
      </tr>
 | 
					      </tr>
 | 
				
			||||||
 | 
					      <tr>
 | 
				
			||||||
 | 
					        <th><ui:msg>Left Side</ui:msg></th>
 | 
				
			||||||
 | 
					        <td><g:ToggleButton ui:field='leftSide'>
 | 
				
			||||||
 | 
					          <g:upFace><ui:msg>Hide</ui:msg></g:upFace>
 | 
				
			||||||
 | 
					          <g:downFace><ui:msg>Show</ui:msg></g:downFace>
 | 
				
			||||||
 | 
					        </g:ToggleButton></td>
 | 
				
			||||||
 | 
					      </tr>
 | 
				
			||||||
      <tr>
 | 
					      <tr>
 | 
				
			||||||
        <th><ui:msg>Top Menu</ui:msg></th>
 | 
					        <th><ui:msg>Top Menu</ui:msg></th>
 | 
				
			||||||
        <td><g:ToggleButton ui:field='topMenu'>
 | 
					        <td><g:ToggleButton ui:field='topMenu'>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -324,6 +324,7 @@ public class SideBySide2 extends Screen {
 | 
				
			|||||||
        .on("C", commentManager.insertNewDraft(cm))
 | 
					        .on("C", commentManager.insertNewDraft(cm))
 | 
				
			||||||
        .on("N", maybeNextVimSearch(cm))
 | 
					        .on("N", maybeNextVimSearch(cm))
 | 
				
			||||||
        .on("P", chunkManager.diffChunkNav(cm, Direction.PREV))
 | 
					        .on("P", chunkManager.diffChunkNav(cm, Direction.PREV))
 | 
				
			||||||
 | 
					        .on("Shift-A", diffTable.toggleA())
 | 
				
			||||||
        .on("Shift-M", header.reviewedAndNext())
 | 
					        .on("Shift-M", header.reviewedAndNext())
 | 
				
			||||||
        .on("Shift-N", maybePrevVimSearch(cm))
 | 
					        .on("Shift-N", maybePrevVimSearch(cm))
 | 
				
			||||||
        .on("Shift-P", commentManager.commentNav(cm, Direction.PREV))
 | 
					        .on("Shift-P", commentManager.commentNav(cm, Direction.PREV))
 | 
				
			||||||
@@ -457,6 +458,13 @@ public class SideBySide2 extends Screen {
 | 
				
			|||||||
        upToChange(true).run();
 | 
					        upToChange(true).run();
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					    keysAction.add(new KeyCommand(
 | 
				
			||||||
 | 
					        KeyCommand.M_SHIFT, 'a', PatchUtil.C.toggleSideA()) {
 | 
				
			||||||
 | 
					      @Override
 | 
				
			||||||
 | 
					      public void onKeyPress(KeyPressEvent event) {
 | 
				
			||||||
 | 
					        diffTable.toggleA().run();
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
    keysAction.add(new KeyCommand(0, ',', PatchUtil.C.showPreferences()) {
 | 
					    keysAction.add(new KeyCommand(0, ',', PatchUtil.C.showPreferences()) {
 | 
				
			||||||
      @Override
 | 
					      @Override
 | 
				
			||||||
      public void onKeyPress(KeyPressEvent event) {
 | 
					      public void onKeyPress(KeyPressEvent event) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -54,6 +54,7 @@ public interface PatchConstants extends Constants {
 | 
				
			|||||||
  String fileList();
 | 
					  String fileList();
 | 
				
			||||||
  String expandComment();
 | 
					  String expandComment();
 | 
				
			||||||
  String expandAllCommentsOnCurrentLine();
 | 
					  String expandAllCommentsOnCurrentLine();
 | 
				
			||||||
 | 
					  String toggleSideA();
 | 
				
			||||||
  String toggleIntraline();
 | 
					  String toggleIntraline();
 | 
				
			||||||
  String showPreferences();
 | 
					  String showPreferences();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -36,6 +36,7 @@ focusSideB = Focus right side
 | 
				
			|||||||
fileList = Browse files in patch set
 | 
					fileList = Browse files in patch set
 | 
				
			||||||
expandComment = Expand or collapse comment
 | 
					expandComment = Expand or collapse comment
 | 
				
			||||||
expandAllCommentsOnCurrentLine = Expand or collapse all comments on current line
 | 
					expandAllCommentsOnCurrentLine = Expand or collapse all comments on current line
 | 
				
			||||||
 | 
					toggleSideA = Toggle left side
 | 
				
			||||||
toggleIntraline = Toggle intraline difference
 | 
					toggleIntraline = Toggle intraline difference
 | 
				
			||||||
showPreferences = Show diff preferences
 | 
					showPreferences = Show diff preferences
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user