use of com.servoy.j2db.persistence.ISupportHTMLToolTipText in project servoy-client by Servoy.
the class PropertyListCellRenderer method getListCellRendererComponent.
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
int align = LEFT;
Font f = normalFont;
// $NON-NLS-1$
String newvalue = "";
if (value != null)
newvalue = value.toString();
if (value instanceof ScriptMethod) {
newvalue = ((ScriptMethod) value).getDisplayName();
}
if (value instanceof Pair && ((Pair) value).getLeft() != null) {
newvalue = ((Pair) value).getLeft().toString();
}
if (// $NON-NLS-1$
newvalue != null && newvalue.startsWith("*")) {
newvalue = newvalue.substring(1);
f = boldFont;
align = CENTER;
} else {
f = normalFont;
align = LEFT;
}
Component c = super.getListCellRendererComponent(list, newvalue, index, isSelected, cellHasFocus);
if (showToolTips) {
if (value instanceof ISupportHTMLToolTipText) {
String html = ((ISupportHTMLToolTipText) value).toHTML();
if (!html.startsWith("<html>"))
html = "<html>" + html + "</html>";
((JComponent) c).setToolTipText(html);
} else {
((JComponent) c).setToolTipText(null);
}
}
if (normalFont == null) {
normalFont = c.getFont();
boldFont = normalFont.deriveFont(Font.BOLD);
f = normalFont;
}
c.setFont(f);
if (c instanceof JLabel) {
((JLabel) c).setHorizontalAlignment(align);
}
return c;
}
Aggregations