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));
}
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;
}
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);
}
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);
}
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);
}
}
}));
}
Aggregations