Statistics
| Revision:

root / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / fieldsTree / CheckBoxNode.java @ 9461

History | View | Annotate | Download (5.6 KB)

1
package com.iver.cit.gvsig.gui.panels.fieldsTree;
2

    
3
import java.awt.BorderLayout;
4
import java.awt.Color;
5
import java.awt.Dimension;
6
import java.awt.FlowLayout;
7
import java.util.Vector;
8

    
9
import javax.swing.BoxLayout;
10
import javax.swing.JCheckBox;
11
import javax.swing.JLabel;
12
import javax.swing.JPanel;
13

    
14

    
15
import org.gvsig.remoteClient.gml.schemas.XMLElement;
16
import org.gvsig.remoteClient.gml.types.IXMLType;
17
import org.gvsig.remoteClient.gml.types.XMLComplexType;
18

    
19

    
20

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