Statistics
| Revision:

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

History | View | Annotate | Download (5.09 KB)

1
package com.iver.cit.gvsig.gui.panels.attributesTree;
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
import org.gvsig.remoteClient.gml.schemas.IXMLType;
15
import org.gvsig.remoteClient.gml.schemas.XMLComplexType;
16
import org.gvsig.remoteClient.gml.schemas.XMLElement;
17

    
18

    
19

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