Statistics
| Revision:

root / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / WFSSelectFieldsPanel.java @ 11134

History | View | Annotate | Download (9.64 KB)

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

    
3
import java.beans.PropertyChangeEvent;
4
import java.beans.PropertyChangeListener;
5
import java.util.Vector;
6

    
7
import javax.swing.JPanel;
8
import javax.swing.JScrollPane;
9

    
10
import org.gvsig.remoteClient.gml.schemas.XMLElement;
11

    
12
import com.iver.andami.PluginServices;
13
import com.iver.cit.gvsig.fmap.layers.WFSLayerNode;
14
import com.iver.cit.gvsig.gui.panels.fieldsTree.FieldsTreeTable;
15
import com.iver.cit.gvsig.gui.panels.fieldsTree.FieldsTreeTableModel;
16
import com.iver.cit.gvsig.gui.panels.fieldsTree.TreeTableModelWithCheckBoxes;
17

    
18
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
19
 *
20
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
21
 *
22
 * This program is free software; you can redistribute it and/or
23
 * modify it under the terms of the GNU General Public License
24
 * as published by the Free Software Foundation; either version 2
25
 * of the License, or (at your option) any later version.
26
 *
27
 * This program is distributed in the hope that it will be useful,
28
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
30
 * GNU General Public License for more details.
31
 *
32
 * You should have received a copy of the GNU General Public License
33
 * along with this program; if not, write to the Free Software
34
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
35
 *
36
 * For more information, contact:
37
 *
38
 *  Generalitat Valenciana
39
 *   Conselleria d'Infraestructures i Transport
40
 *   Av. Blasco Ib??ez, 50
41
 *   46010 VALENCIA
42
 *   SPAIN
43
 *
44
 *      +34 963862235
45
 *   gvsig@gva.es
46
 *      www.gvsig.gva.es
47
 *
48
 *    or
49
 *
50
 *   IVER T.I. S.A
51
 *   Salamanca 50
52
 *   46005 Valencia
53
 *   Spain
54
 *
55
 *   +34 963163400
56
 *   dac@iver.es
57
 */
58
/* CVS MESSAGES:
59
 *
60
 * $Id$
61
 * $Log$
62
 * Revision 1.8  2007-04-11 12:10:08  ppiqueras
63
 * Corregido bug: si la capa no tiene campos, no permitir cargarla.
64
 *
65
 * Revision 1.7  2007/02/22 12:24:51  ppiqueras
66
 * A?adidas tool tip text.
67
 *
68
 * Revision 1.6  2007/02/19 11:44:42  jorpiell
69
 * A?adidos los filtros por ?rea
70
 *
71
 * Revision 1.5  2006/12/26 09:19:52  ppiqueras
72
 * 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).
73
 *
74
 * Revision 1.17  2006/12/15 13:58:25  ppiqueras
75
 * Eliminado un import que sobraba, y reorganizado c?digo
76
 *
77
 * Revision 1.16  2006/12/04 08:59:47  ppiqueras
78
 * Algunos bugs corregidos. A cambio hay 2 bugs relacionados que todav?a no han sido corregidos (ver PHPCollab) (los tiene asignados Jorge).
79
 *
80
 * Revision 1.15  2006/11/01 17:29:08  jorpiell
81
 * Se ha elimiado el nodo virtual de la raiz. Adem?s ya se cargan los valores de un campo complejo en la pesta?a del filtro
82
 *
83
 * Revision 1.14  2006/10/31 09:39:18  jorpiell
84
 * Cambiado el tama?o del panel
85
 *
86
 * Revision 1.13  2006/10/27 11:33:19  jorpiell
87
 * A?adida la treetable con los check box para seleccionar los atributos
88
 *
89
 * Revision 1.12  2006/10/24 07:58:14  jorpiell
90
 * Eliminado el parametro booleano que hac?a que apareciesen mas de una columna en el tree table
91
 *
92
 * Revision 1.11  2006/10/24 07:27:56  jorpiell
93
 * Algunos cambios en el modelo que usa la tabla
94
 *
95
 * Revision 1.10  2006/10/10 12:55:06  jorpiell
96
 * Se ha a?adido el soporte de features complejas
97
 *
98
 * Revision 1.9  2006/10/02 09:09:45  jorpiell
99
 * Cambios del 10 copiados al head
100
 *
101
 * Revision 1.7.2.1  2006/09/19 12:28:11  jorpiell
102
 * Ya no se depende de geotools
103
 *
104
 * Revision 1.8  2006/09/18 12:07:31  jorpiell
105
 * Se ha sustituido geotools por el driver de remoteservices
106
 *
107
 * Revision 1.7  2006/09/05 13:01:31  jorpiell
108
 * Reducido el tama?o de los botones
109
 *
110
 * Revision 1.6  2006/07/24 07:30:33  jorpiell
111
 * Se han eliminado las partes duplicadas y se est? usando el parser de GML de FMAP.
112
 *
113
 * Revision 1.5  2006/07/21 11:50:31  jaume
114
 * improved appearance
115
 *
116
 * Revision 1.4  2006/06/21 12:35:45  jorpiell
117
 * Se ha a?adido la ventana de propiedades. Esto implica a?adir listeners por todos los paneles. Adem?s no se muestra la geomatr?a en la lista de atributos y se muestran ?nicamnete los que se van a descargar
118
 *
119
 * Revision 1.3  2006/06/15 07:50:58  jorpiell
120
 * A?adida la funcionalidad de reproyectar y hechos algunos cambios en la interfaz
121
 *
122
 * Revision 1.2  2006/05/26 06:29:42  jorpiell
123
 * Se ha cambiado el tama?o de los botones. Adem?s, al seleccionar todos los atributos se seleccionan en orden.
124
 *
125
 * Revision 1.1  2006/05/25 10:30:13  jorpiell
126
 * Esta clase se ha renombrado. WFSFields era algo confusa
127
 *
128
 * Revision 1.3  2006/05/23 08:09:39  jorpiell
129
 * Se ha cambiado la forma en la que se leian los valores seleccionados en los paneles y se ha cambiado el comportamiento de los botones
130
 *
131
 * Revision 1.2  2006/05/19 12:57:08  jorpiell
132
 * Modificados algunos paneles
133
 *
134
 * Revision 1.1  2006/04/20 16:38:24  jorpiell
135
 * Ahora mismo ya se puede hacer un getCapabilities y un getDescribeType de la capa seleccionada para ver los atributos a dibujar. Queda implementar el panel de opciones y hacer el getFeature().
136
 *
137
 *
138
 */
139
/**
140
 * This panel shows the feature fields list
141
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
142
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
143
 */
144
public class WFSSelectFieldsPanel extends JPanel {
145
        private static final long serialVersionUID = 3073243334672620143L;
146
        private JScrollPane fieldsScroll = null;
147
        private FieldsTreeTable fieldsTreeTable = null;
148
        private FieldsTreeTableModel model = null;
149
        private WFSParamsPanel parent = null;
150
        private JPanel treeTablePanel = null;
151
        private boolean fieldsSelectedOfSameLayerHasChanged;
152

    
153
        public WFSSelectFieldsPanel(WFSParamsPanel parent){
154
                super();
155
                this.parent = parent;
156
                initialize();
157
        }
158

    
159
        public void initialize(){
160
                this.setLayout(null);
161
                this.setBounds(10, 5, 481, 427);                
162
                this.add(getTreeTablePanel(), null);
163
                fieldsSelectedOfSameLayerHasChanged = false;
164
        }
165

    
166
        /**
167
         * This method initializes jScrollPane3
168
         *
169
         * @return javax.swing.JScrollPane
170
         */
171
        private JScrollPane getFieldsScroll() {
172
                if (fieldsScroll == null) {
173
                        fieldsScroll = new JScrollPane();
174
                        fieldsScroll.setLocation(new java.awt.Point(6,20));
175
                        fieldsScroll.setSize(new java.awt.Dimension(470,349));
176
                        fieldsScroll.setViewportView(getFieldsTreeTable());
177
                        fieldsScroll.setToolTipText(PluginServices.getText(treeTablePanel, "fields_Selection_Info"));
178
                }
179
                return fieldsScroll;
180
        }
181

    
182
        /**
183
         * This method initializes lstTemps
184
         *
185
         * @return javax.swing.JList
186
         */
187
        public FieldsTreeTable getFieldsTreeTable() {
188
                if (fieldsTreeTable == null) {
189
                        model = new TreeTableModelWithCheckBoxes();
190
                        fieldsTreeTable = new FieldsTreeTable(model,this);
191
                        fieldsTreeTable.setLocation(new java.awt.Point(7,4));
192
                        fieldsTreeTable.setSize(new java.awt.Dimension(482,302));
193
                        fieldsTreeTable.setToolTipText(PluginServices.getText(treeTablePanel, "fields_Selection_Info"));
194
                        
195
                        // If user has changed the fields selection in the same layer
196
                        fieldsTreeTable.addPropertyChangeListener(new PropertyChangeListener() {
197
                                /*
198
                                 *  (non-Javadoc)
199
                                 * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
200
                                 */
201
                                public void propertyChange(PropertyChangeEvent evt) {
202
                                        // If the selection of the fields of the layer has changed
203
                                        if (evt.getPropertyName().compareTo("tableCellEditor") == 0)
204
                                        {
205
                                                fieldsSelectedOfSameLayerHasChanged = true;                                                
206
                                        }                                        
207
                                        else if (evt.getPropertyName().compareTo("selectionModel") == 0) { // If the layer has changed
208
                                                fieldsSelectedOfSameLayerHasChanged = false;
209
                                        }
210
                                }
211
                        });
212
                }
213
                return fieldsTreeTable;
214
        }
215

    
216
        public void refresh(WFSLayerNode feature){
217
                setFields(feature);                        
218
        }
219

    
220
        /**
221
         *
222
         * @param feature
223
         */
224
        private void setFields(WFSLayerNode feature){
225
                Vector fields = feature.getFields();
226

    
227
                // If there are no fields
228
                if (fields.size() == 0) {
229
                        return;
230
                }
231

    
232
                model = new TreeTableModelWithCheckBoxes(fields.get(0));
233
                fieldsTreeTable.setModel(model);
234
        }
235
        
236
        public void setSelectedFields(WFSLayerNode feature){
237
                Vector selectedFields = feature.getSelectedFields();
238
                fieldsTreeTable.setSelectedFields(selectedFields);
239
        }
240
        
241
        /**
242
         * Gets the Geometry field name
243
         * @return
244
         */
245
        public String getGeometryFieldName(){
246
                return getFieldsTreeTable().getGeometryField();                
247
        }
248

    
249
        /**
250
         *
251
         * @return the selected fields.
252
         */
253
        public XMLElement[] getSelectedFields(){
254
                return fieldsTreeTable.getSelectedElements();
255
        }
256

    
257
        /**
258
         * This method initializes treeTablePanel        
259
         *         
260
         * @return javax.swing.JPanel        
261
         */
262
        private JPanel getTreeTablePanel() {
263
                if (treeTablePanel == null) {
264
                        treeTablePanel = new JPanel();
265
                        treeTablePanel.setLayout(null);
266
                        treeTablePanel.setLocation(new java.awt.Point(7,4));
267
                        treeTablePanel.setSize(new java.awt.Dimension(482,375));
268
                        treeTablePanel.add(getFieldsScroll(), null);
269
                        treeTablePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
270
                                        null, PluginServices.getText(this, "select_fields"),
271
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
272
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
273
                }
274
                return treeTablePanel;
275
        }
276
        
277
        /**
278
         * Returns true if user has changed the selection of some field of the same layer; else returns false
279
         * 
280
         * @return A boolean value
281
         */
282
        public boolean getFieldsSelectedOfSameLayerHasChanged() {
283
                return this.fieldsSelectedOfSameLayerHasChanged;
284
        }
285
        
286
        /**
287
         * @param updated The updated to set.
288
         */
289
        public void setUpdated(boolean updated) {
290
                parent.isApplicable(updated);
291
        }
292

    
293
        /**
294
         * Resets the value of the field 'fieldsSelectedOfSameLayerHasChanged'
295
         * 
296
         * @return A boolean value
297
         */
298
        public void resetFieldsSelectedOfSameLayerHasChanged() {
299
                this.fieldsSelectedOfSameLayerHasChanged = false;
300
        }
301
}  //  @jve:decl-index=0:visual-constraint="10,22"