01: /*
02: * ProfileTreeCellRenderer.java
03: *
04: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
05: *
06: * Copyright 2002-2008, Thomas Kellerer
07: * No part of this code maybe reused without the permission of the author
08: *
09: * To contact the author please send an email to: support@sql-workbench.net
10: *
11: */
12: package workbench.gui.profiles;
13:
14: import java.awt.Color;
15: import java.awt.Component;
16: import javax.swing.JTree;
17: import javax.swing.border.Border;
18: import javax.swing.border.LineBorder;
19: import javax.swing.tree.DefaultTreeCellRenderer;
20:
21: /**
22: * A tree cell renderer that can indicate a drop target
23: * @author support@sql-workbench.net
24: */
25: public class ProfileTreeCellRenderer extends DefaultTreeCellRenderer {
26: private Object dropTargetItem = null;
27: private Border dropBorder = null;
28:
29: public ProfileTreeCellRenderer() {
30: super ();
31: Color c = getBackgroundSelectionColor();
32: dropBorder = new LineBorder(c, 1);
33: }
34:
35: public void setDropTargetItem(Object target) {
36: this .dropTargetItem = target;
37: }
38:
39: public Component getTreeCellRendererComponent(JTree tree,
40: Object value, boolean sel, boolean expanded, boolean leaf,
41: int row, boolean hasFocus) {
42: if (this.dropTargetItem != null && dropTargetItem == value) {
43: setBorder(dropBorder);
44: } else {
45: setBorder(null);
46: }
47: return super.getTreeCellRendererComponent(tree, value, sel,
48: expanded, leaf, row, hasFocus);
49: }
50:
51: }
|