root / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / fieldsTree / CheckBoxNode.java @ 13881
History | View | Annotate | Download (5.48 KB)
1 |
package com.iver.cit.gvsig.gui.panels.fieldsTree; |
---|---|
2 |
|
3 |
import java.awt.Color; |
4 |
import java.util.Vector; |
5 |
|
6 |
import org.gvsig.remoteClient.gml.schemas.XMLElement; |
7 |
import org.gvsig.remoteClient.gml.types.IXMLType; |
8 |
import org.gvsig.remoteClient.gml.types.XMLComplexType; |
9 |
|
10 |
|
11 |
|
12 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
13 |
*
|
14 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
15 |
*
|
16 |
* This program is free software; you can redistribute it and/or
|
17 |
* modify it under the terms of the GNU General Public License
|
18 |
* as published by the Free Software Foundation; either version 2
|
19 |
* of the License, or (at your option) any later version.
|
20 |
*
|
21 |
* This program is distributed in the hope that it will be useful,
|
22 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
23 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
24 |
* GNU General Public License for more details.
|
25 |
*
|
26 |
* You should have received a copy of the GNU General Public License
|
27 |
* along with this program; if not, write to the Free Software
|
28 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
29 |
*
|
30 |
* For more information, contact:
|
31 |
*
|
32 |
* Generalitat Valenciana
|
33 |
* Conselleria d'Infraestructures i Transport
|
34 |
* Av. Blasco Ib??ez, 50
|
35 |
* 46010 VALENCIA
|
36 |
* SPAIN
|
37 |
*
|
38 |
* +34 963862235
|
39 |
* gvsig@gva.es
|
40 |
* www.gvsig.gva.es
|
41 |
*
|
42 |
* or
|
43 |
*
|
44 |
* IVER T.I. S.A
|
45 |
* Salamanca 50
|
46 |
* 46005 Valencia
|
47 |
* Spain
|
48 |
*
|
49 |
* +34 963163400
|
50 |
* dac@iver.es
|
51 |
*/
|
52 |
/* CVS MESSAGES:
|
53 |
*
|
54 |
* $Id$
|
55 |
* $Log$
|
56 |
* Revision 1.3 2007-09-19 16:14:50 jaume
|
57 |
* removed unnecessary imports
|
58 |
*
|
59 |
* Revision 1.2 2006/12/26 10:25:37 ppiqueras
|
60 |
* Corregidas las dependencias con las nuevas ubicaciones de clases: IXMLType, XMLElement, IXMLComplexType, etc. (en libRemoteServices)
|
61 |
*
|
62 |
* Revision 1.1 2006/12/26 09:12:48 ppiqueras
|
63 |
* 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).
|
64 |
*
|
65 |
* Revision 1.2 2006/10/31 12:24:04 jorpiell
|
66 |
* Comprobado el caso en el que los atributos no tienen tipo
|
67 |
*
|
68 |
* Revision 1.1 2006/10/27 11:33:19 jorpiell
|
69 |
* A?adida la treetable con los check box para seleccionar los atributos
|
70 |
*
|
71 |
*
|
72 |
*/
|
73 |
/**
|
74 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
75 |
*/
|
76 |
public class CheckBoxNode extends TetraStateCheckBox{ |
77 |
private XMLElement element = null; |
78 |
private CheckBoxNode parent = null; |
79 |
private Vector children = new Vector(); |
80 |
|
81 |
public CheckBoxNode(XMLElement element,CheckBoxNode parent){
|
82 |
super();
|
83 |
this.parent = parent;
|
84 |
initialize(element); |
85 |
} |
86 |
|
87 |
private void initialize(XMLElement element){ |
88 |
this.setBackground(Color.WHITE); |
89 |
this.setText(fillNameWithBlancs(element.getName()));
|
90 |
this.element = element;
|
91 |
if (element.getEntityType() != null){ |
92 |
if (element.getEntityType().getType() == IXMLType.COMPLEX){
|
93 |
Vector subElements = ((XMLComplexType)element.getEntityType()).getAttributes();
|
94 |
for (int i=0 ; i<subElements.size() ; i++){ |
95 |
XMLElement child = (XMLElement)subElements.get(i); |
96 |
children.add(new CheckBoxNode(child,this)); |
97 |
} |
98 |
}else if(element.getEntityType().getType() == IXMLType.GML_GEOMETRY){ |
99 |
this.setSelected(true); |
100 |
} |
101 |
} |
102 |
} |
103 |
|
104 |
/**
|
105 |
* Return the max size for the combo labels
|
106 |
* @return
|
107 |
*/
|
108 |
public static int getTextLength(){ |
109 |
return 200; |
110 |
} |
111 |
|
112 |
/**
|
113 |
* Fill the string with blancs
|
114 |
* @param name
|
115 |
* @return
|
116 |
*/
|
117 |
public static String fillNameWithBlancs(String name){ |
118 |
String withBlancs = name;
|
119 |
for (int i=name.length() ; i<getTextLength() ; i++){ |
120 |
name = name + " ";
|
121 |
} |
122 |
return name;
|
123 |
} |
124 |
|
125 |
/**
|
126 |
* @return Returns the element.
|
127 |
*/
|
128 |
public XMLElement getElement() {
|
129 |
return element;
|
130 |
} |
131 |
|
132 |
/**
|
133 |
* @return Returns the children.
|
134 |
*/
|
135 |
public Vector getChildren() { |
136 |
return children;
|
137 |
} |
138 |
|
139 |
public String toString(){ |
140 |
return getElement().getName();
|
141 |
} |
142 |
|
143 |
/**
|
144 |
* @return Returns the parent.
|
145 |
*/
|
146 |
public CheckBoxNode getParentNode() {
|
147 |
return parent;
|
148 |
} |
149 |
} |
150 |
//public class CheckBoxNode extends JPanel{
|
151 |
//private XMLElement element = null;
|
152 |
//private CheckBoxNode parent = null;
|
153 |
//private Vector children = new Vector();
|
154 |
//private TetraStateCheckBox checkBox = null;
|
155 |
//
|
156 |
//public CheckBoxNode(XMLElement element,CheckBoxNode parent){
|
157 |
//super();
|
158 |
//this.parent = parent;
|
159 |
//initialize(element);
|
160 |
//}
|
161 |
//
|
162 |
//private void initialize(XMLElement element){
|
163 |
//this.setSize(new Dimension(300,400));
|
164 |
//checkBox = new TetraStateCheckBox();
|
165 |
//this.add(checkBox);
|
166 |
//this.add(new JLabel(element.getName()));
|
167 |
//this.setBackground(Color.BLUE);
|
168 |
//this.element = element;
|
169 |
//if (element.getEntityType().getType() == IXMLType.COMPLEX){
|
170 |
//Vector subElements = ((XMLComplexType)element.getEntityType()).getAttributes();
|
171 |
//for (int i=0 ; i<subElements.size() ; i++){
|
172 |
//XMLElement child = (XMLElement)subElements.get(i);
|
173 |
//children.add(new CheckBoxNode(child,this));
|
174 |
//}
|
175 |
//}
|
176 |
//}
|
177 |
//
|
178 |
//public boolean isSelected(){
|
179 |
//return checkBox.isSelected();
|
180 |
//}
|
181 |
//
|
182 |
//public void setSelected(boolean selected){
|
183 |
//checkBox.setSelected(selected);
|
184 |
//}
|
185 |
//
|
186 |
//public void setColor(int color){
|
187 |
//checkBox.setColor(color);
|
188 |
//}
|
189 |
//
|
190 |
///**
|
191 |
//* @return Returns the element.
|
192 |
//*/
|
193 |
//public XMLElement getElement() {
|
194 |
//return element;
|
195 |
//}
|
196 |
//
|
197 |
///**
|
198 |
//* @return Returns the children.
|
199 |
//*/
|
200 |
//public Vector getChildren() {
|
201 |
//return children;
|
202 |
//}
|
203 |
//
|
204 |
//public String toString(){
|
205 |
//return getElement().getName();
|
206 |
//}
|
207 |
//
|
208 |
///**
|
209 |
//* @return Returns the parent.
|
210 |
//*/
|
211 |
//public CheckBoxNode getParentNode() {
|
212 |
//return parent;
|
213 |
//}
|
214 |
//}
|