Search in sources :

Example 1 with AccountInfo

use of com.google.gerrit.client.info.AccountInfo in project gerrit by GerritCodeReview.

the class ChangeScreen method renderUploader.

private void renderUploader(ChangeInfo changeInfo, RevisionInfo revInfo) {
    AccountInfo uploader = revInfo.uploader();
    boolean isOwner = uploader == null || uploader._accountId() == changeInfo.owner()._accountId();
    renderPushCertificate(revInfo, isOwner ? ownerPanel : uploaderPanel);
    if (isOwner) {
        uploaderRow.getStyle().setDisplay(Display.NONE);
        return;
    }
    uploaderRow.getStyle().setDisplay(Display.TABLE_ROW);
    if (uploader.avatar(AvatarInfo.DEFAULT_SIZE) != null) {
        uploaderPanel.insert(new AvatarImage(uploader), 0);
    }
    String name = name(uploader);
    uploaderName.setText(name);
    uploaderName.setTitle(email(uploader, name));
}
Also used : JsArrayString(com.google.gwt.core.client.JsArrayString) AvatarImage(com.google.gerrit.client.AvatarImage) AccountInfo(com.google.gerrit.client.info.AccountInfo)

Example 2 with AccountInfo

use of com.google.gerrit.client.info.AccountInfo in project gerrit by GerritCodeReview.

the class Reviewers method byAccount.

private static Map<Integer, AccountInfo> byAccount(Map<ReviewerState, List<AccountInfo>> reviewers, ReviewerState state) {
    List<AccountInfo> accounts = reviewers.get(state);
    if (accounts == null) {
        return Collections.emptyMap();
    }
    Map<Integer, AccountInfo> result = new HashMap<>();
    for (AccountInfo a : accounts) {
        result.put(a._accountId(), a);
    }
    return result;
}
Also used : HashMap(java.util.HashMap) AccountInfo(com.google.gerrit.client.info.AccountInfo)

Example 3 with AccountInfo

use of com.google.gerrit.client.info.AccountInfo in project gerrit by GerritCodeReview.

the class RegisterScreen method onInitUI.

@Override
protected void onInitUI() {
    super.onInitUI();
    setPageTitle(Util.C.welcomeToGerritCodeReview());
    final FlowPanel formBody = new FlowPanel();
    final FlowPanel contactGroup = new FlowPanel();
    contactGroup.setStyleName(Gerrit.RESOURCES.css().registerScreenSection());
    contactGroup.add(new SmallHeading(Util.C.welcomeReviewContact()));
    final HTML whereFrom = new HTML(Util.C.welcomeContactFrom());
    whereFrom.setStyleName(Gerrit.RESOURCES.css().registerScreenExplain());
    contactGroup.add(whereFrom);
    contactGroup.add(new ContactPanelShort() {

        @Override
        protected void display(AccountInfo account) {
            super.display(account);
            if ("".equals(nameTxt.getText())) {
                // No name? Encourage the user to provide us something.
                //
                nameTxt.setFocus(true);
                save.setEnabled(true);
            }
        }
    });
    formBody.add(contactGroup);
    if (Gerrit.getUserAccount().username() == null && Gerrit.info().auth().canEdit(AccountFieldName.USER_NAME)) {
        final FlowPanel fp = new FlowPanel();
        fp.setStyleName(Gerrit.RESOURCES.css().registerScreenSection());
        fp.add(new SmallHeading(Util.C.welcomeUsernameHeading()));
        final Grid userInfo = new Grid(1, 2);
        final CellFormatter fmt = userInfo.getCellFormatter();
        userInfo.setStyleName(Gerrit.RESOURCES.css().infoBlock());
        userInfo.addStyleName(Gerrit.RESOURCES.css().accountInfoBlock());
        fp.add(userInfo);
        fmt.addStyleName(0, 0, Gerrit.RESOURCES.css().topmost());
        fmt.addStyleName(0, 1, Gerrit.RESOURCES.css().topmost());
        fmt.addStyleName(0, 0, Gerrit.RESOURCES.css().bottomheader());
        UsernameField field = new UsernameField();
        if (LocaleInfo.getCurrentLocale().isRTL()) {
            userInfo.setText(0, 1, Util.C.userName());
            userInfo.setWidget(0, 0, field);
            fmt.addStyleName(0, 1, Gerrit.RESOURCES.css().header());
        } else {
            userInfo.setText(0, 0, Util.C.userName());
            userInfo.setWidget(0, 1, field);
            fmt.addStyleName(0, 0, Gerrit.RESOURCES.css().header());
        }
        formBody.add(fp);
    }
    if (Gerrit.info().hasSshd()) {
        final FlowPanel sshKeyGroup = new FlowPanel();
        sshKeyGroup.setStyleName(Gerrit.RESOURCES.css().registerScreenSection());
        sshKeyGroup.add(new SmallHeading(Util.C.welcomeSshKeyHeading()));
        final HTML whySshKey = new HTML(Util.C.welcomeSshKeyText());
        whySshKey.setStyleName(Gerrit.RESOURCES.css().registerScreenExplain());
        sshKeyGroup.add(whySshKey);
        sshKeyGroup.add(new SshPanel() {

            {
                setKeyTableVisible(false);
            }
        });
        formBody.add(sshKeyGroup);
    }
    final FlowPanel choices = new FlowPanel();
    choices.setStyleName(Gerrit.RESOURCES.css().registerScreenNextLinks());
    if (Gerrit.info().auth().useContributorAgreements()) {
        final FlowPanel agreementGroup = new FlowPanel();
        agreementGroup.setStyleName(Gerrit.RESOURCES.css().registerScreenSection());
        agreementGroup.add(new SmallHeading(Util.C.welcomeAgreementHeading()));
        final HTML whyAgreement = new HTML(Util.C.welcomeAgreementText());
        whyAgreement.setStyleName(Gerrit.RESOURCES.css().registerScreenExplain());
        agreementGroup.add(whyAgreement);
        choices.add(new InlineHyperlink(Util.C.newAgreement(), PageLinks.SETTINGS_NEW_AGREEMENT));
        choices.add(new InlineHyperlink(Util.C.welcomeAgreementLater(), nextToken));
        formBody.add(agreementGroup);
    } else {
        choices.add(new InlineHyperlink(Util.C.welcomeContinue(), nextToken));
    }
    formBody.add(choices);
    final FormPanel form = new FormPanel();
    form.add(formBody);
    add(form);
}
Also used : SmallHeading(com.google.gerrit.client.ui.SmallHeading) InlineHyperlink(com.google.gerrit.client.ui.InlineHyperlink) FormPanel(com.google.gwt.user.client.ui.FormPanel) Grid(com.google.gwt.user.client.ui.Grid) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) HTML(com.google.gwt.user.client.ui.HTML) CellFormatter(com.google.gwt.user.client.ui.HTMLTable.CellFormatter) AccountInfo(com.google.gerrit.client.info.AccountInfo)

Example 4 with AccountInfo

use of com.google.gerrit.client.info.AccountInfo in project gerrit by GerritCodeReview.

the class Gerrit method whoAmI.

private static void whoAmI(boolean canLogOut) {
    AccountInfo account = getUserAccount();
    final UserPopupPanel userPopup = new UserPopupPanel(account, canLogOut, true);
    final FlowPanel userSummaryPanel = new FlowPanel();
    class PopupHandler implements KeyDownHandler, ClickHandler {

        private void showHidePopup() {
            if (userPopup.isShowing() && userPopup.isVisible()) {
                userPopup.hide();
            } else {
                userPopup.showRelativeTo(userSummaryPanel);
            }
        }

        @Override
        public void onClick(ClickEvent event) {
            showHidePopup();
        }

        @Override
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                showHidePopup();
                event.preventDefault();
            }
        }
    }
    final PopupHandler popupHandler = new PopupHandler();
    final InlineLabel l = new InlineLabel(FormatUtil.name(account));
    l.setStyleName(RESOURCES.css().menuBarUserName());
    final AvatarImage avatar = new AvatarImage(account, 26, false);
    avatar.setStyleName(RESOURCES.css().menuBarUserNameAvatar());
    userSummaryPanel.setStyleName(RESOURCES.css().menuBarUserNamePanel());
    userSummaryPanel.add(l);
    userSummaryPanel.add(avatar);
    // "BLACK DOWN-POINTING SMALL TRIANGLE"
    userSummaryPanel.add(new InlineLabel(" ▾"));
    userPopup.addAutoHidePartner(userSummaryPanel.getElement());
    FocusPanel fp = new FocusPanel(userSummaryPanel);
    fp.setStyleName(RESOURCES.css().menuBarUserNameFocusPanel());
    fp.addKeyDownHandler(popupHandler);
    fp.addClickHandler(popupHandler);
    menuRight.add(fp);
}
Also used : KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) KeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) InlineLabel(com.google.gwt.user.client.ui.InlineLabel) FocusPanel(com.google.gwt.user.client.ui.FocusPanel) AccountInfo(com.google.gerrit.client.info.AccountInfo)

Example 5 with AccountInfo

use of com.google.gerrit.client.info.AccountInfo 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)

Aggregations

AccountInfo (com.google.gerrit.client.info.AccountInfo)11 GerritCallback (com.google.gerrit.client.rpc.GerritCallback)3 NativeString (com.google.gerrit.client.rpc.NativeString)3 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)3 CallbackGroup (com.google.gerrit.client.rpc.CallbackGroup)2 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)2 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)2 FormPanel (com.google.gwt.user.client.ui.FormPanel)2 HTML (com.google.gwt.user.client.ui.HTML)2 AvatarImage (com.google.gerrit.client.AvatarImage)1 ErrorDialog (com.google.gerrit.client.ErrorDialog)1 EditPreferences (com.google.gerrit.client.account.EditPreferences)1 DocInfo (com.google.gerrit.client.documentation.DocInfo)1 AvatarInfo (com.google.gerrit.client.info.AccountInfo.AvatarInfo)1 GeneralPreferences (com.google.gerrit.client.info.GeneralPreferences)1 ServerInfo (com.google.gerrit.client.info.ServerInfo)1 InlineHyperlink (com.google.gerrit.client.ui.InlineHyperlink)1 SmallHeading (com.google.gerrit.client.ui.SmallHeading)1 HostPageData (com.google.gerrit.common.data.HostPageData)1 EditPreferencesInfo (com.google.gerrit.extensions.client.EditPreferencesInfo)1