svn-gvsig-desktop / trunk / extensions / extSDE / src / com / iver / cit / gvsig / sde / gui / sdewizard2 / ConnectionTreeRenderer.java @ 11193
History | View | Annotate | Download (1.08 KB)
1 |
package com.iver.cit.gvsig.sde.gui.sdewizard2; |
---|---|
2 |
|
3 |
import java.awt.Component; |
4 |
|
5 |
import javax.swing.ImageIcon; |
6 |
import javax.swing.JTree; |
7 |
import javax.swing.tree.DefaultTreeCellRenderer; |
8 |
|
9 |
public class ConnectionTreeRenderer extends DefaultTreeCellRenderer { |
10 |
|
11 |
private ImageIcon connImage = new ImageIcon(createResourceUrl("images/conn.png")); |
12 |
private ImageIcon disconnImage = new ImageIcon(createResourceUrl("images/disconn.png")); |
13 |
|
14 |
public Component getTreeCellRendererComponent(JTree tree, Object value, |
15 |
boolean selected, boolean expanded, boolean leaf, int row, |
16 |
boolean hasFocus) {
|
17 |
|
18 |
if (value instanceof SDEConnectionTreeLeaf) { |
19 |
SDEConnectionTreeLeaf jdbc = (SDEConnectionTreeLeaf) value; |
20 |
if (jdbc.getConnectionWithParams().isConnected()) {
|
21 |
setLeafIcon(connImage); |
22 |
} else {
|
23 |
setLeafIcon(disconnImage); |
24 |
} |
25 |
} |
26 |
|
27 |
return super.getTreeCellRendererComponent( |
28 |
tree, |
29 |
value, |
30 |
selected, |
31 |
expanded, |
32 |
leaf, |
33 |
row, |
34 |
hasFocus); |
35 |
} |
36 |
|
37 |
private java.net.URL createResourceUrl(String path) { |
38 |
return getClass().getClassLoader().getResource(path);
|
39 |
} |
40 |
|
41 |
} |