Statistics
| Revision:

root / org.gvsig.wfs.app / trunk / org.gvsig.wfs.app / org.gvsig.wfs.app.mainplugin / src / main / java / org / gvsig / wfs / gui / panels / fieldstree / CheckBoxNode.java @ 10

History | View | Annotate | Download (4.61 KB)

1
package org.gvsig.wfs.gui.panels.fieldstree;
2

    
3
import java.awt.Color;
4
import java.util.Vector;
5

    
6
import org.gvsig.remoteclient.wfs.WFSFeature;
7
import org.gvsig.remoteclient.wfs.WFSFeatureField;
8

    
9

    
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.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 WFSFeatureField featureField = null;
77
    private String featureFieldName = null;
78
    private CheckBoxNode parent = null;
79
    private Vector children = new Vector();        
80

    
81
    public CheckBoxNode(WFSFeatureField featureField,CheckBoxNode parent){
82
        super();
83
        this.parent = parent;
84
        initialize(featureField);
85
        this.setSelected(true);
86
    }
87

    
88
    private void initialize(WFSFeature feature){     
89
        this.setBackground(Color.WHITE);
90
        featureFieldName = (fillNameWithBlancs(feature.getName()));
91
        this.setText(featureFieldName);
92
        for (int i=0 ; i< feature.getFieldSize() ; i++){
93
            children.add(new CheckBoxNode(feature.getFieldAt(i),this));                 
94
        }
95
    }
96

    
97
    private void initialize(WFSFeatureField featureField){                
98
        this.setBackground(Color.WHITE);
99
         featureFieldName = (fillNameWithBlancs(featureField.getName()));
100
         this.setText(featureFieldName);
101
        this.featureField = featureField;
102
        for (int i=0 ; i< featureField.getFieldSize() ; i++){
103
            children.add(new CheckBoxNode(featureField.getFieldAt(i),this));                                        
104
        }
105
        if(featureField.isGeometry()){
106
            this.setSelected(true);        
107

    
108
        }
109
    }
110

    
111
    /**
112
     * Return the max size for the combo labels
113
     * @return
114
     */
115
    public static int getTextLength(){
116
        return 200;
117
    }
118

    
119
    /**
120
     * Fill the string with blancs
121
     * @param name
122
     * @return
123
     */
124
    public static String fillNameWithBlancs(String name){
125
        String withBlancs = name;
126
        for (int i=name.length() ; i<getTextLength() ; i++){
127
            name = name + " ";
128
        }
129
        return name;
130
    }
131

    
132
    /**
133
     * @return Returns the element.
134
     */
135
    public WFSFeatureField getFeatureField() {
136
        return featureField;
137
    }
138

    
139
    /**
140
     * @return Returns the children.
141
     */
142
    public Vector getChildren() {
143
        return children;
144
    }
145

    
146
    public String toString(){
147
        return featureFieldName;
148
    }
149

    
150
    /**
151
     * @return Returns the parent.
152
     */
153
    public CheckBoxNode getParentNode() {
154
        return parent;
155
    }
156
}