root / org.gvsig.wfs.app / trunk / org.gvsig.wfs.app / org.gvsig.wfs.app.mainplugin / src / main / java / org / gvsig / wfs / gui / panels / fieldstree / CheckBoxTreeCellRenderer.java @ 10
History | View | Annotate | Download (4.09 KB)
1 |
package org.gvsig.wfs.gui.panels.fieldstree; |
---|---|
2 |
|
3 |
import java.awt.Component; |
4 |
|
5 |
import javax.swing.JLabel; |
6 |
import javax.swing.JTree; |
7 |
import javax.swing.UIManager; |
8 |
import javax.swing.tree.DefaultTreeCellRenderer; |
9 |
import javax.swing.tree.TreePath; |
10 |
|
11 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
12 |
*
|
13 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
14 |
*
|
15 |
* This program is free software; you can redistribute it and/or
|
16 |
* modify it under the terms of the GNU General Public License
|
17 |
* as published by the Free Software Foundation; either version 2
|
18 |
* of the License, or (at your option) any later version.
|
19 |
*
|
20 |
* This program is distributed in the hope that it will be useful,
|
21 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
22 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
23 |
* GNU General Public License for more details.
|
24 |
*
|
25 |
* You should have received a copy of the GNU General Public License
|
26 |
* along with this program; if not, write to the Free Software
|
27 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
28 |
*
|
29 |
* For more information, contact:
|
30 |
*
|
31 |
* Generalitat Valenciana
|
32 |
* Conselleria d'Infraestructures i Transport
|
33 |
* Av. Blasco Ib??ez, 50
|
34 |
* 46010 VALENCIA
|
35 |
* SPAIN
|
36 |
*
|
37 |
* +34 963862235
|
38 |
* gvsig@gva.es
|
39 |
* www.gvsig.gva.es
|
40 |
*
|
41 |
* or
|
42 |
*
|
43 |
* IVER T.I. S.A
|
44 |
* Salamanca 50
|
45 |
* 46005 Valencia
|
46 |
* Spain
|
47 |
*
|
48 |
* +34 963163400
|
49 |
* dac@iver.es
|
50 |
*/
|
51 |
/* CVS MESSAGES:
|
52 |
*
|
53 |
* $Id$
|
54 |
* $Log$
|
55 |
* Revision 1.3 2007-09-19 16:14:50 jaume
|
56 |
* removed unnecessary imports
|
57 |
*
|
58 |
* Revision 1.2 2006/12/26 10:25:37 ppiqueras
|
59 |
* Corregidas las dependencias con las nuevas ubicaciones de clases: IXMLType, XMLElement, IXMLComplexType, etc. (en libRemoteServices)
|
60 |
*
|
61 |
* Revision 1.1 2006/12/26 09:12:48 ppiqueras
|
62 |
* Cambiado "atttibutes" en todas las aparaciones en atributos, m?todos, clases, paquetes o comentarios por "fields". (S?lo a aquellas que afectan a clases dentro del proyecto extWFS2). (En este caso se ha cambiado el nombre del paquete aparte de alguno otro nombre que puede haber cambiado).
|
63 |
*
|
64 |
* Revision 1.3 2006/10/31 12:24:04 jorpiell
|
65 |
* Comprobado el caso en el que los atributos no tienen tipo
|
66 |
*
|
67 |
* Revision 1.2 2006/10/31 09:39:44 jorpiell
|
68 |
* Se devuelve el tipo de la entidad completo, y no sus hijos
|
69 |
*
|
70 |
* Revision 1.1 2006/10/27 11:33:19 jorpiell
|
71 |
* A?adida la treetable con los check box para seleccionar los atributos
|
72 |
*
|
73 |
*
|
74 |
*/
|
75 |
/**
|
76 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
77 |
*/
|
78 |
public class CheckBoxTreeCellRenderer extends DefaultTreeCellRenderer{ |
79 |
private JTree tree; |
80 |
private FieldsTreeTable treetable;
|
81 |
|
82 |
public CheckBoxTreeCellRenderer(FieldsTreeTable treetable) {
|
83 |
this.treetable = treetable;
|
84 |
this.tree = (JTree)treetable.getTree(); |
85 |
} |
86 |
|
87 |
/*
|
88 |
* (non-Javadoc)
|
89 |
* @see javax.swing.tree.TreeCellRenderer#getTreeCellRendererComponent(javax.swing.JTree, java.lang.Object, boolean, boolean, boolean, int, boolean)
|
90 |
*/
|
91 |
public Component getTreeCellRendererComponent(JTree tree, Object value, |
92 |
boolean selected, boolean expanded, boolean leaf, int row, |
93 |
boolean hasFocus) {
|
94 |
int[] rows = tree.getSelectionRows(); |
95 |
TreePath path = tree.getPathForRow(row);
|
96 |
if (path != null){ |
97 |
Object node = path.getLastPathComponent();
|
98 |
if ((node != null) && (node instanceof CheckBoxNode)){ |
99 |
CheckBoxNode selectedNode = (CheckBoxNode)node; |
100 |
if (selectedNode.getParent() == null){ |
101 |
tree.expandRow(0);
|
102 |
} |
103 |
if (selected){
|
104 |
selectedNode.setBackground(UIManager.getColor("Tree.selectionBackground")); |
105 |
if (hasFocus){
|
106 |
if (!selectedNode.getFeatureField().isGeometry()){
|
107 |
treetable.setApplicable(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 |
} |