コード例 #1
0
ファイル: DetailsBox.java プロジェクト: gitools/gitools
  private Component createNameLabel(DetailsDecoration detail) {

    if (detail instanceof JComponentDetailsDecoration) {
      Component c = createComponentNameLabel((JComponentDetailsDecoration) detail);
      if (c != null) {
        c.setForeground(detail.isVisible() ? Color.BLACK : Color.lightGray);
        return c;
      }
    }

    WebLabel label = new WebLabel(StringUtils.capitalize(detail.getName()), JLabel.TRAILING);

    label.setDrawShade(true);
    SwingUtils.changeFontSize(label, -1);

    if (detail.isSelected()) {
      SwingUtils.setBoldFont(label);
    }

    label.setCursor(new Cursor(Cursor.HAND_CURSOR));
    label.addMouseListener(new PropertyMouseListener(detail));

    if (StringUtils.isNotEmpty(detail.getDescription())) {
      String description =
          "<html><body width=\"300px\">" + detail.getDescription() + "</body></html>";
      TooltipManager.setTooltip(label, description, TooltipWay.down, 0);
    }

    if (!StringUtils.isEmpty(detail.getDescriptionLink())) {
      DetailsWebLinkLabel webLabel = new DetailsWebLinkLabel("", JLabel.TRAILING);
      webLabel.setIcon(IconNames.INFO_ICON);
      webLabel.setLink(detail.getDescriptionLink(), false);
      TooltipManager.setTooltip(webLabel, detail.getDescriptionLink(), TooltipWay.down, 0);
      return new GroupPanel(GroupingType.fillFirst, 5, webLabel, label);
    }

    label.setForeground(detail.isVisible() ? Color.BLACK : Color.lightGray);
    return label;
  }