SideBySide2: Honor some diff preferences

Honor the user's stored settings for:

  * ignore whitespace
  * show whitespace errors
  * intraline difference
  * tab size
  * syntax highlighting

Initialize the preferences in the constructor.  Later when preferences
are editable on the fly some will force the screen to reload, while
others might be applied on the fly.

Change-Id: I31a039d834c9f38f1ca2678433bd76c7c42f8154
This commit is contained in:
Shawn Pearce
2013-08-18 11:48:06 -07:00
parent ef87384292
commit 2f6f946779
2 changed files with 35 additions and 12 deletions

View File

@@ -17,6 +17,7 @@ package com.google.gerrit.client.diff;
import com.google.gerrit.client.changes.ChangeApi;
import com.google.gerrit.client.rpc.NativeMap;
import com.google.gerrit.client.rpc.RestApi;
import com.google.gerrit.reviewdb.client.AccountDiffPreference;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -51,6 +52,20 @@ public class DiffApi {
return this;
}
public DiffApi ignoreWhitespace(AccountDiffPreference.Whitespace w) {
switch (w) {
default:
case IGNORE_NONE:
return ignoreWhitespace(IgnoreWhitespace.NONE);
case IGNORE_SPACE_AT_EOL:
return ignoreWhitespace(IgnoreWhitespace.TRAILING);
case IGNORE_SPACE_CHANGE:
return ignoreWhitespace(IgnoreWhitespace.CHANGED);
case IGNORE_ALL_SPACE:
return ignoreWhitespace(IgnoreWhitespace.ALL);
}
}
public DiffApi ignoreWhitespace(IgnoreWhitespace w) {
if (w != null && w != IgnoreWhitespace.NONE) {
call.addParameter("ignore-whitespace", w);
@@ -58,8 +73,10 @@ public class DiffApi {
return this;
}
public DiffApi intraline() {
call.addParameterTrue("intraline");
public DiffApi intraline(boolean intraline) {
if (intraline) {
call.addParameterTrue("intraline");
}
return this;
}