public Component getTreeCellRendererComponent(JTree tree,
Object value,
boolean sel,
boolean expanded,
boolean leaf,
int row,
boolean hasFocus) {
if (value instanceof ConfigTreeRootNode)
{
return super.getTreeCellRendererComponent(tree, "< Root >", //$NON-NLS-1$
sel, expanded, leaf, row, hasFocus);
}
else if (value instanceof ConfigTreeSectionNode)
{
final ConfigTreeSectionNode node = (ConfigTreeSectionNode) value;
return super.getTreeCellRendererComponent(tree, node.getName(),
sel, expanded, leaf, row, hasFocus);
}
else if (value instanceof ConfigTreeModuleNode)
{
final ConfigTreeModuleNode node = (ConfigTreeModuleNode) value;
final StringBuffer text = new StringBuffer();
text.append(node.getModule().getName());
text.append(" - "); //$NON-NLS-1$
text.append(node.getModule().getMajorVersion());
text.append('.");
text.append(node.getModule().getMinorVersion());
text.append('-");
text.append(node.getModule().getPatchLevel());
return super.getTreeCellRendererComponent(tree, text.toString(),
sel, expanded, leaf, row, hasFocus);
}
return super.getTreeCellRendererComponent(tree, value,
sel, expanded, leaf, row, hasFocus);
}
Configures the renderer based on the passed in components. The value is set from
messaging the tree with convertValueToText, which ultimately invokes
toString on value. The foreground color is set based on the
selection and the icon is set based on on leaf and expanded. |