Search in sources :

Example 1 with GeneralPreferences

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);
        }
    });
}
Also used : GeneralPreferences(com.google.gerrit.client.info.GeneralPreferences) ArrayList(java.util.ArrayList) TopMenuItem(com.google.gerrit.client.info.TopMenuItem)

Example 2 with GeneralPreferences

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);
            }
        }
    }));
}
Also used : DocInfo(com.google.gerrit.client.documentation.DocInfo) ServerInfo(com.google.gerrit.client.info.ServerInfo) GeneralPreferences(com.google.gerrit.client.info.GeneralPreferences) CallbackGroup(com.google.gerrit.client.rpc.CallbackGroup) EditPreferences(com.google.gerrit.client.account.EditPreferences) HostPageData(com.google.gerrit.common.data.HostPageData) GerritCallback(com.google.gerrit.client.rpc.GerritCallback) EditPreferencesInfo(com.google.gerrit.extensions.client.EditPreferencesInfo) AccountInfo(com.google.gerrit.client.info.AccountInfo) KeyUtil(com.google.gwtorm.client.KeyUtil)

Example 3 with GeneralPreferences

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) {
            }
        });
    }
}
Also used : JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) GeneralPreferences(com.google.gerrit.client.info.GeneralPreferences)

Example 4 with GeneralPreferences

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);
        }
    });
}
Also used : ExtensionPanel(com.google.gerrit.client.api.ExtensionPanel) GeneralPreferences(com.google.gerrit.client.info.GeneralPreferences)

Example 5 with GeneralPreferences

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) {
            }
        });
    }
}
Also used : JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) GeneralPreferences(com.google.gerrit.client.info.GeneralPreferences)

Aggregations

GeneralPreferences (com.google.gerrit.client.info.GeneralPreferences)5 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)2 EditPreferences (com.google.gerrit.client.account.EditPreferences)1 ExtensionPanel (com.google.gerrit.client.api.ExtensionPanel)1 DocInfo (com.google.gerrit.client.documentation.DocInfo)1 AccountInfo (com.google.gerrit.client.info.AccountInfo)1 ServerInfo (com.google.gerrit.client.info.ServerInfo)1 TopMenuItem (com.google.gerrit.client.info.TopMenuItem)1 CallbackGroup (com.google.gerrit.client.rpc.CallbackGroup)1 GerritCallback (com.google.gerrit.client.rpc.GerritCallback)1 HostPageData (com.google.gerrit.common.data.HostPageData)1 EditPreferencesInfo (com.google.gerrit.extensions.client.EditPreferencesInfo)1 KeyUtil (com.google.gwtorm.client.KeyUtil)1 ArrayList (java.util.ArrayList)1