Persisting users diff formatting preferences
When a user changes diff formatting preferences and clicks the Update button the preferences will then be persisted in the database. This way a user doesn't have to adjust the diff formatting preferences each time it switches to the next file diff. Bug: issue 579 Change-Id: I52cd1dcf702ed04046b236228f994fb9042243d9 Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
This commit is contained in:
committed by
Shawn O. Pearce
parent
5a00b3161d
commit
077b2c5dd0
@@ -16,6 +16,7 @@ package com.google.gerrit.common.data;
|
||||
|
||||
import com.google.gerrit.common.auth.SignInRequired;
|
||||
import com.google.gerrit.reviewdb.Account;
|
||||
import com.google.gerrit.reviewdb.AccountDiffPreference;
|
||||
import com.google.gerrit.reviewdb.AccountGeneralPreferences;
|
||||
import com.google.gerrit.reviewdb.AccountProjectWatch;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
@@ -32,10 +33,17 @@ public interface AccountService extends RemoteJsonService {
|
||||
@SignInRequired
|
||||
void myAccount(AsyncCallback<Account> callback);
|
||||
|
||||
@SignInRequired
|
||||
void myDiffPreferences(AsyncCallback<AccountDiffPreference> callback);
|
||||
|
||||
@SignInRequired
|
||||
void changePreferences(AccountGeneralPreferences pref,
|
||||
AsyncCallback<VoidResult> gerritCallback);
|
||||
|
||||
@SignInRequired
|
||||
void changeDiffPreferences(AccountDiffPreference diffPref,
|
||||
AsyncCallback<VoidResult> callback);
|
||||
|
||||
@SignInRequired
|
||||
void myProjectWatch(AsyncCallback<List<AccountProjectWatchInfo>> callback);
|
||||
|
||||
|
||||
@@ -15,9 +15,11 @@
|
||||
package com.google.gerrit.common.data;
|
||||
|
||||
import com.google.gerrit.reviewdb.Account;
|
||||
import com.google.gerrit.reviewdb.AccountDiffPreference;
|
||||
|
||||
/** Data sent as part of the host page, to bootstrap the UI. */
|
||||
public class HostPageData {
|
||||
public Account account;
|
||||
public AccountDiffPreference accountDiffPref;
|
||||
public GerritConfig config;
|
||||
}
|
||||
|
||||
@@ -14,17 +14,16 @@
|
||||
|
||||
package com.google.gerrit.common.data;
|
||||
|
||||
import static com.google.gerrit.reviewdb.AccountGeneralPreferences.WHOLE_FILE_CONTEXT;
|
||||
|
||||
import com.google.gerrit.common.data.PatchScriptSettings.Whitespace;
|
||||
import com.google.gerrit.prettify.client.ClientSideFormatter;
|
||||
import com.google.gerrit.prettify.common.EditList;
|
||||
import com.google.gerrit.prettify.common.PrettyFormatter;
|
||||
import com.google.gerrit.prettify.common.PrettySettings;
|
||||
import com.google.gerrit.prettify.common.SparseFileContent;
|
||||
import com.google.gerrit.prettify.common.SparseHtmlFile;
|
||||
import com.google.gerrit.reviewdb.AccountDiffPreference;
|
||||
import com.google.gerrit.reviewdb.Change;
|
||||
import com.google.gerrit.reviewdb.Patch;
|
||||
import com.google.gerrit.reviewdb.AccountDiffPreference.Whitespace;
|
||||
import com.google.gerrit.reviewdb.Patch.ChangeType;
|
||||
|
||||
import org.eclipse.jgit.diff.Edit;
|
||||
@@ -178,7 +177,7 @@ public class PatchScript {
|
||||
|
||||
public Iterable<EditList.Hunk> getHunks() {
|
||||
int ctx = settings.getContext();
|
||||
if (ctx == WHOLE_FILE_CONTEXT) {
|
||||
if (ctx == AccountDiffPreference.WHOLE_FILE_CONTEXT) {
|
||||
ctx = Math.max(a.size(), b.size());
|
||||
}
|
||||
return new EditList(edits, ctx, a.size(), b.size()).getHunks();
|
||||
|
||||
@@ -15,33 +15,16 @@
|
||||
package com.google.gerrit.common.data;
|
||||
|
||||
import com.google.gerrit.prettify.common.PrettySettings;
|
||||
import com.google.gerrit.reviewdb.AccountGeneralPreferences;
|
||||
import com.google.gerrit.reviewdb.CodedEnum;
|
||||
import com.google.gerrit.reviewdb.AccountDiffPreference;
|
||||
import com.google.gerrit.reviewdb.AccountDiffPreference.Whitespace;
|
||||
|
||||
public class PatchScriptSettings {
|
||||
public static enum Whitespace implements CodedEnum {
|
||||
IGNORE_NONE('N'), //
|
||||
IGNORE_SPACE_AT_EOL('E'), //
|
||||
IGNORE_SPACE_CHANGE('S'), //
|
||||
IGNORE_ALL_SPACE('A');
|
||||
|
||||
private final char code;
|
||||
|
||||
private Whitespace(final char c) {
|
||||
code = c;
|
||||
}
|
||||
|
||||
public char getCode() {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
protected int context;
|
||||
protected Whitespace whitespace;
|
||||
protected PrettySettings pretty;
|
||||
|
||||
public PatchScriptSettings() {
|
||||
context = AccountGeneralPreferences.DEFAULT_CONTEXT;
|
||||
context = AccountDiffPreference.DEFAULT_CONTEXT;
|
||||
whitespace = Whitespace.IGNORE_NONE;
|
||||
pretty = new PrettySettings();
|
||||
}
|
||||
@@ -65,7 +48,7 @@ public class PatchScriptSettings {
|
||||
}
|
||||
|
||||
public void setContext(final int ctx) {
|
||||
assert 0 <= ctx || ctx == AccountGeneralPreferences.WHOLE_FILE_CONTEXT;
|
||||
assert 0 <= ctx || ctx == AccountDiffPreference.WHOLE_FILE_CONTEXT;
|
||||
context = ctx;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user