use of com.google.gerrit.client.info.GeneralPreferences in project gerrit by GerritCodeReview.
the class MyPreferencesScreen method doSave.
private void doSave() {
GeneralPreferences p = GeneralPreferences.create();
p.showSiteHeader(showSiteHeader.getValue());
p.useFlashClipboard(useFlashClipboard.getValue());
p.changesPerPage(getListBox(maximumPageSize, DEFAULT_PAGESIZE));
p.dateFormat(getListBox(dateFormat, GeneralPreferencesInfo.DateFormat.STD, GeneralPreferencesInfo.DateFormat.values()));
p.timeFormat(getListBox(timeFormat, GeneralPreferencesInfo.TimeFormat.HHMM_12, GeneralPreferencesInfo.TimeFormat.values()));
p.highlightAssigneeInChangeTable(highlightAssigneeInChangeTable.getValue());
p.relativeDateInChangeTable(relativeDateInChangeTable.getValue());
p.sizeBarInChangeTable(sizeBarInChangeTable.getValue());
p.legacycidInChangeTable(legacycidInChangeTable.getValue());
p.muteCommonPathPrefixes(muteCommonPathPrefixes.getValue());
p.signedOffBy(signedOffBy.getValue());
p.publishCommentsOnPush(publishCommentsOnPush.getValue());
p.reviewCategoryStrategy(getListBox(reviewCategoryStrategy, ReviewCategoryStrategy.NONE, ReviewCategoryStrategy.values()));
p.diffView(getListBox(diffView, GeneralPreferencesInfo.DiffView.SIDE_BY_SIDE, GeneralPreferencesInfo.DiffView.values()));
p.emailStrategy(getListBox(emailStrategy, GeneralPreferencesInfo.EmailStrategy.ENABLED, GeneralPreferencesInfo.EmailStrategy.values()));
p.emailFormat(getListBox(emailFormat, GeneralPreferencesInfo.EmailFormat.HTML_PLAINTEXT, GeneralPreferencesInfo.EmailFormat.values()));
p.defaultBaseForMerges(getListBox(defaultBaseForMerges, GeneralPreferencesInfo.DefaultBase.FIRST_PARENT, GeneralPreferencesInfo.DefaultBase.values()));
List<TopMenuItem> items = new ArrayList<>();
for (List<String> v : myMenus.getValues()) {
items.add(TopMenuItem.create(v.get(0), v.get(1)));
}
p.setMyMenus(items);
enable(false);
save.setEnabled(false);
AccountApi.self().view("preferences").put(p, new GerritCallback<GeneralPreferences>() {
@Override
public void onSuccess(GeneralPreferences prefs) {
Gerrit.setUserPreferences(prefs);
enable(true);
display(prefs);
}
@Override
public void onFailure(Throwable caught) {
enable(true);
save.setEnabled(true);
super.onFailure(caught);
}
});
}
use of com.google.gerrit.client.info.GeneralPreferences in project gerrit by GerritCodeReview.
the class Gerrit method onModuleLoad.
@Override
public void onModuleLoad() {
if (!canLoadInIFrame()) {
UserAgent.assertNotInIFrame();
}
setXsrfToken();
KeyUtil.setEncoderImpl(new KeyUtil.Encoder() {
@Override
public String encode(String e) {
e = URL.encodeQueryString(e);
e = fixPathImpl(e);
e = fixColonImpl(e);
e = fixDoubleQuote(e);
return e;
}
@Override
public String decode(final String e) {
return URL.decodeQueryString(e);
}
private native String fixPathImpl(String path);
private native String fixColonImpl(String path);
private native String fixDoubleQuote(String path);
});
initHostname();
Window.setTitle(M.windowTitle1(myHost));
RpcStatus.INSTANCE = new RpcStatus();
CallbackGroup cbg = new CallbackGroup();
getDocIndex(cbg.add(new GerritCallback<DocInfo>() {
@Override
public void onSuccess(DocInfo indexInfo) {
hasDocumentation = indexInfo != null;
docUrl = selfRedirect("/Documentation/");
}
}));
ConfigServerApi.serverInfo(cbg.add(new GerritCallback<ServerInfo>() {
@Override
public void onSuccess(ServerInfo info) {
myServerInfo = info;
urlAliasMatcher = new UrlAliasMatcher(info.urlAliases());
String du = info.gerrit().docUrl();
if (du != null && !du.isEmpty()) {
hasDocumentation = true;
docUrl = du;
}
docSearch = info.gerrit().docSearch();
}
}));
HostPageDataService hpd = GWT.create(HostPageDataService.class);
hpd.load(cbg.addFinal(new GerritCallback<HostPageData>() {
@Override
public void onSuccess(final HostPageData result) {
Document.get().getElementById("gerrit_hostpagedata").removeFromParent();
myTheme = result.theme;
isNoteDbEnabled = result.isNoteDbEnabled;
if (result.accountDiffPref != null) {
myAccountDiffPref = result.accountDiffPref;
}
if (result.accountDiffPref != null) {
// TODO: Support options on the GetDetail REST endpoint so that it can
// also return the preferences. Then we can fetch everything with a
// single request and we don't need the callback group anymore.
CallbackGroup cbg = new CallbackGroup();
AccountApi.self().view("detail").get(cbg.add(new GerritCallback<AccountInfo>() {
@Override
public void onSuccess(AccountInfo result) {
myAccount = result;
}
}));
AccountApi.self().view("preferences").get(cbg.add(new GerritCallback<GeneralPreferences>() {
@Override
public void onSuccess(GeneralPreferences prefs) {
myPrefs = prefs;
onModuleLoad2(result);
}
}));
AccountApi.getEditPreferences(cbg.addFinal(new GerritCallback<EditPreferences>() {
@Override
public void onSuccess(EditPreferences prefs) {
EditPreferencesInfo prefsInfo = new EditPreferencesInfo();
prefs.copyTo(prefsInfo);
editPrefs = prefsInfo;
}
}));
} else {
myAccount = AccountInfo.create(0, null, null, null);
myPrefs = GeneralPreferences.createDefault();
editPrefs = null;
onModuleLoad2(result);
}
}
}));
}
use of com.google.gerrit.client.info.GeneralPreferences in project gerrit by GerritCodeReview.
the class DownloadBox method saveScheme.
private void saveScheme() {
String schemeStr = scheme.getValue(scheme.getSelectedIndex());
GeneralPreferences prefs = Gerrit.getUserPreferences();
if (Gerrit.isSignedIn() && !schemeStr.equals(prefs.downloadScheme())) {
prefs.downloadScheme(schemeStr);
GeneralPreferences in = GeneralPreferences.create();
in.downloadScheme(schemeStr);
AccountApi.self().view("preferences").put(in, new AsyncCallback<JavaScriptObject>() {
@Override
public void onSuccess(JavaScriptObject result) {
}
@Override
public void onFailure(Throwable caught) {
}
});
}
}
use of com.google.gerrit.client.info.GeneralPreferences in project gerrit by GerritCodeReview.
the class MyPreferencesScreen method onLoad.
@Override
protected void onLoad() {
super.onLoad();
ExtensionPanel extensionPanel = createExtensionPoint(GerritUiExtensionPoint.PREFERENCES_SCREEN_BOTTOM);
extensionPanel.addStyleName(Gerrit.RESOURCES.css().extensionPanel());
add(extensionPanel);
AccountApi.self().view("preferences").get(new ScreenLoadCallback<GeneralPreferences>(this) {
@Override
public void preDisplay(GeneralPreferences prefs) {
display(prefs);
}
});
}
use of com.google.gerrit.client.info.GeneralPreferences in project gerrit by GerritCodeReview.
the class DownloadUrlLink method onClick.
@Override
public void onClick(ClickEvent event) {
event.preventDefault();
event.stopPropagation();
select();
GeneralPreferences prefs = Gerrit.getUserPreferences();
if (Gerrit.isSignedIn() && !schemeName.equals(prefs.downloadScheme())) {
prefs.downloadScheme(schemeName);
GeneralPreferences in = GeneralPreferences.create();
in.downloadScheme(schemeName);
AccountApi.self().view("preferences").put(in, new AsyncCallback<JavaScriptObject>() {
@Override
public void onSuccess(JavaScriptObject result) {
}
@Override
public void onFailure(Throwable caught) {
}
});
}
}
Aggregations