Exemplo n.º 1
0
 public void setAccount(AccountInfo account, int size, boolean addPopup) {
   if (account == null) {
     setVisible(false);
   } else if (isGerritServer(account)) {
     setVisible(true);
     setResource(Gerrit.RESOURCES.gerritAvatar26());
   } else if (account.hasAvatarInfo()) {
     setVisible(false);
     AvatarInfo info = account.avatar(size);
     if (info != null) {
       setWidth(info.width() > 0 ? info.width() + "px" : "");
       setHeight(info.height() > 0 ? info.height() + "px" : "");
       setUrl(info.url());
       popup(account, addPopup);
     } else if (account.email() != null) {
       loadAvatar(account, size, addPopup);
     }
   } else if (account.email() != null) {
     loadAvatar(account, size, addPopup);
   } else {
     setVisible(false);
   }
 }
Exemplo n.º 2
0
 private static String name(AccountInfo ai) {
   if (ai.email() != null) {
     return ai.email();
   } else if (ai.name() != null) {
     return ai.name();
   } else if (ai._accountId() != 0) {
     return "" + ai._accountId();
   } else {
     return "";
   }
 }
Exemplo n.º 3
0
  private void loadAvatar(AccountInfo account, int size, boolean addPopup) {
    if (!Gerrit.info().plugin().hasAvatars()) {
      setVisible(false);
      return;
    }

    // TODO Kill /accounts/*/avatar URL.
    String u = account.email();
    if (Gerrit.isSignedIn() && u.equals(Gerrit.getUserAccount().email())) {
      u = "self";
    }
    RestApi api = new RestApi("/accounts/").id(u).view("avatar");
    if (size > 0) {
      api.addParameter("s", size);
      setSize("", size + "px");
    }
    setVisible(false);
    setUrl(api.url());
    popup(account, addPopup);
  }
Exemplo n.º 4
0
 private static boolean isGerritServer(AccountInfo account) {
   return account._accountId() == 0 && Util.C.messageNoAuthor().equals(account.name());
 }