示例#1
0
 public LinkPanel(
     String wicketId,
     String bootstrapIcon,
     String linkCssClass,
     IModel<String> model,
     Class<? extends WebPage> clazz,
     PageParameters parameters,
     boolean newWindow) {
   super(wicketId);
   this.labelModel = model;
   Link<Void> link = null;
   if (parameters == null) {
     link = new BookmarkablePageLink<Void>("link", clazz);
   } else {
     link = new BookmarkablePageLink<Void>("link", clazz, parameters);
   }
   if (newWindow) {
     link.add(new SimpleAttributeModifier("target", "_blank"));
   }
   if (linkCssClass != null) {
     link.add(new SimpleAttributeModifier("class", linkCssClass));
   }
   Label icon = new Label("icon");
   if (StringUtils.isEmpty(bootstrapIcon)) {
     link.add(icon.setVisible(false));
   } else {
     WicketUtils.setCssClass(icon, bootstrapIcon);
     link.add(icon);
   }
   link.add(new Label("label", labelModel).setRenderBodyOnly(true));
   add(link);
 }
示例#2
0
  public GravatarImage(String id, PersonIdent person, int width) {
    super(id);

    String email =
        person.getEmailAddress() == null
            ? person.getName().toLowerCase()
            : person.getEmailAddress().toLowerCase();
    String hash = StringUtils.getMD5(email);
    Link<Void> link =
        new BookmarkablePageLink<Void>(
            "link", GravatarProfilePage.class, WicketUtils.newObjectParameter(hash));
    link.add(new SimpleAttributeModifier("target", "_blank"));
    String url = ActivityUtils.getGravatarThumbnailUrl(email, width);
    ExternalImage image = new ExternalImage("image", url);
    WicketUtils.setCssClass(image, "gravatar");
    link.add(image);
    WicketUtils.setHtmlTooltip(
        link, MessageFormat.format("View Gravatar profile for {0}", person.getName()));
    add(link);
    setVisible(GitBlit.getBoolean(Keys.web.allowGravatar, true));
  }