01: package net.sourceforge.squirrel_sql.plugins.hibernate.mapping;
02:
03: import net.sourceforge.squirrel_sql.plugins.hibernate.HibernatePluginResources;
04:
05: import javax.swing.tree.DefaultTreeCellRenderer;
06: import javax.swing.tree.DefaultMutableTreeNode;
07: import javax.swing.*;
08: import java.awt.*;
09:
10: public class MappingTreeCellRenderer extends DefaultTreeCellRenderer {
11: private ImageIcon _propertyIcon;
12:
13: public MappingTreeCellRenderer(HibernatePluginResources resource) {
14: _propertyIcon = resource
15: .getIcon(HibernatePluginResources.IKeys.PROPERTY_IMAGE);
16: }
17:
18: public Component getTreeCellRendererComponent(JTree tree,
19: Object value, boolean sel, boolean expanded, boolean leaf,
20: int row, boolean hasFocus) {
21: DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
22:
23: JLabel rendererComponent = (JLabel) super
24: .getTreeCellRendererComponent(tree, value, sel,
25: expanded, leaf, row, hasFocus);
26:
27: if (node.getUserObject() instanceof PropertyInfoTreeWrapper) {
28: rendererComponent.setIcon(_propertyIcon);
29: }
30:
31: return rendererComponent;
32: }
33: }
|