root / branches / v10 / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / attributesTree / CheckBoxTreeCellRenderer.java @ 8847
History | View | Annotate | Download (3.74 KB)
1 |
package com.iver.cit.gvsig.gui.panels.attributesTree; |
---|---|
2 |
|
3 |
import java.awt.Component; |
4 |
import java.awt.Dimension; |
5 |
|
6 |
import javax.swing.JButton; |
7 |
import javax.swing.JLabel; |
8 |
import javax.swing.JTree; |
9 |
import javax.swing.UIManager; |
10 |
import javax.swing.tree.DefaultTreeCellRenderer; |
11 |
import javax.swing.tree.TreePath; |
12 |
|
13 |
import org.gvsig.remoteClient.gml.schemas.IXMLType; |
14 |
import org.gvsig.remoteClient.gml.schemas.XMLElement; |
15 |
|
16 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
17 |
*
|
18 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
19 |
*
|
20 |
* This program is free software; you can redistribute it and/or
|
21 |
* modify it under the terms of the GNU General Public License
|
22 |
* as published by the Free Software Foundation; either version 2
|
23 |
* of the License, or (at your option) any later version.
|
24 |
*
|
25 |
* This program is distributed in the hope that it will be useful,
|
26 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
27 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
28 |
* GNU General Public License for more details.
|
29 |
*
|
30 |
* You should have received a copy of the GNU General Public License
|
31 |
* along with this program; if not, write to the Free Software
|
32 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
33 |
*
|
34 |
* For more information, contact:
|
35 |
*
|
36 |
* Generalitat Valenciana
|
37 |
* Conselleria d'Infraestructures i Transport
|
38 |
* Av. Blasco Ib??ez, 50
|
39 |
* 46010 VALENCIA
|
40 |
* SPAIN
|
41 |
*
|
42 |
* +34 963862235
|
43 |
* gvsig@gva.es
|
44 |
* www.gvsig.gva.es
|
45 |
*
|
46 |
* or
|
47 |
*
|
48 |
* IVER T.I. S.A
|
49 |
* Salamanca 50
|
50 |
* 46005 Valencia
|
51 |
* Spain
|
52 |
*
|
53 |
* +34 963163400
|
54 |
* dac@iver.es
|
55 |
*/
|
56 |
/* CVS MESSAGES:
|
57 |
*
|
58 |
* $Id: CheckBoxTreeCellRenderer.java 8847 2006-11-17 11:29:00Z ppiqueras $
|
59 |
* $Log$
|
60 |
* Revision 1.3.2.2 2006-11-17 11:28:45 ppiqueras
|
61 |
* Corregidos bugs y a?adida nueva funcionalidad.
|
62 |
*
|
63 |
* Revision 1.3 2006/10/31 12:24:04 jorpiell
|
64 |
* Comprobado el caso en el que los atributos no tienen tipo
|
65 |
*
|
66 |
* Revision 1.2 2006/10/31 09:39:44 jorpiell
|
67 |
* Se devuelve el tipo de la entidad completo, y no sus hijos
|
68 |
*
|
69 |
* Revision 1.1 2006/10/27 11:33:19 jorpiell
|
70 |
* A?adida la treetable con los check box para seleccionar los atributos
|
71 |
*
|
72 |
*
|
73 |
*/
|
74 |
/**
|
75 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
76 |
*/
|
77 |
public class CheckBoxTreeCellRenderer extends DefaultTreeCellRenderer{ |
78 |
private JTree tree; |
79 |
private AttributesTreeTable treetable;
|
80 |
|
81 |
public CheckBoxTreeCellRenderer(AttributesTreeTable treetable) {
|
82 |
this.treetable = treetable;
|
83 |
this.tree = (JTree)treetable.getTree(); |
84 |
} |
85 |
|
86 |
/*
|
87 |
* (non-Javadoc)
|
88 |
* @see javax.swing.tree.TreeCellRenderer#getTreeCellRendererComponent(javax.swing.JTree, java.lang.Object, boolean, boolean, boolean, int, boolean)
|
89 |
*/
|
90 |
public Component getTreeCellRendererComponent(JTree tree, Object value, |
91 |
boolean selected, boolean expanded, boolean leaf, int row, |
92 |
boolean hasFocus) {
|
93 |
int[] rows = tree.getSelectionRows(); |
94 |
TreePath path = tree.getPathForRow(row);
|
95 |
if (path != null){ |
96 |
Object node = path.getLastPathComponent();
|
97 |
if ((node != null) && (node instanceof CheckBoxNode)){ |
98 |
CheckBoxNode selectedNode = (CheckBoxNode)node; |
99 |
if (selectedNode.getParent() == null){ |
100 |
tree.expandRow(0);
|
101 |
} |
102 |
if (selected){
|
103 |
selectedNode.setBackground(UIManager.getColor("Tree.selectionBackground")); |
104 |
if (hasFocus){
|
105 |
if ((selectedNode.getElement().getEntityType() == null) || |
106 |
!(selectedNode.getElement().getEntityType().getType() == IXMLType.GML_GEOMETRY)){ |
107 |
treetable.setUpdated(true);
|
108 |
selectedNode.setSelected(!selectedNode.isSelected()); |
109 |
selectedNode.setColor(TetraStateCheckBox.WHITE); |
110 |
} |
111 |
} |
112 |
}else{
|
113 |
selectedNode.setBackground(UIManager.getColor("Tree.textBackground")); |
114 |
} |
115 |
return selectedNode;
|
116 |
} |
117 |
} |
118 |
JLabel label = new JLabel(CheckBoxNode.fillNameWithBlancs("Feature")); |
119 |
return label;
|
120 |
} |
121 |
|
122 |
|
123 |
} |