Statistics
| Revision:

svn-gvsig-desktop / import / extWFS2 / src / com / iver / cit / gvsig / gui / panels / WFSSelectAttributesPanel.java @ 18320

History | View | Annotate | Download (9.13 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.attributesTree.AttributesTreeTable;
15
import com.iver.cit.gvsig.gui.panels.attributesTree.AttributesTreeTableModel;
16
import com.iver.cit.gvsig.gui.panels.attributesTree.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: WFSSelectAttributesPanel.java 18320 2008-01-25 13:16:03Z jpiera $
61
 * $Log$
62
 * Revision 1.7.2.5  2007-01-08 09:52:11  ppiqueras
63
 * Corridos bugs + nueva funcionalidad.
64
 *
65
 * Revision 1.5  2006/12/26 09:19:52  ppiqueras
66
 * 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).
67
 *
68
 * Revision 1.17  2006/12/15 13:58:25  ppiqueras
69
 * Eliminado un import que sobraba, y reorganizado c?digo
70
 *
71
 * Revision 1.16  2006/12/04 08:59:47  ppiqueras
72
 * Algunos bugs corregidos. A cambio hay 2 bugs relacionados que todav?a no han sido corregidos (ver PHPCollab) (los tiene asignados Jorge).
73
 *
74
 * Revision 1.15  2006/11/01 17:29:08  jorpiell
75
 * 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
76
 *
77
 * Revision 1.14  2006/10/31 09:39:18  jorpiell
78
 * Cambiado el tama?o del panel
79
 *
80
 * Revision 1.13  2006/10/27 11:33:19  jorpiell
81
 * A?adida la treetable con los check box para seleccionar los atributos
82
 *
83
 * Revision 1.12  2006/10/24 07:58:14  jorpiell
84
 * Eliminado el parametro booleano que hac?a que apareciesen mas de una columna en el tree table
85
 *
86
 * Revision 1.11  2006/10/24 07:27:56  jorpiell
87
 * Algunos cambios en el modelo que usa la tabla
88
 *
89
 * Revision 1.10  2006/10/10 12:55:06  jorpiell
90
 * Se ha a?adido el soporte de features complejas
91
 *
92
 * Revision 1.9  2006/10/02 09:09:45  jorpiell
93
 * Cambios del 10 copiados al head
94
 *
95
 * Revision 1.7.2.1  2006/09/19 12:28:11  jorpiell
96
 * Ya no se depende de geotools
97
 *
98
 * Revision 1.8  2006/09/18 12:07:31  jorpiell
99
 * Se ha sustituido geotools por el driver de remoteservices
100
 *
101
 * Revision 1.7  2006/09/05 13:01:31  jorpiell
102
 * Reducido el tama?o de los botones
103
 *
104
 * Revision 1.6  2006/07/24 07:30:33  jorpiell
105
 * Se han eliminado las partes duplicadas y se est? usando el parser de GML de FMAP.
106
 *
107
 * Revision 1.5  2006/07/21 11:50:31  jaume
108
 * improved appearance
109
 *
110
 * Revision 1.4  2006/06/21 12:35:45  jorpiell
111
 * 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
112
 *
113
 * Revision 1.3  2006/06/15 07:50:58  jorpiell
114
 * A?adida la funcionalidad de reproyectar y hechos algunos cambios en la interfaz
115
 *
116
 * Revision 1.2  2006/05/26 06:29:42  jorpiell
117
 * Se ha cambiado el tama?o de los botones. Adem?s, al seleccionar todos los atributos se seleccionan en orden.
118
 *
119
 * Revision 1.1  2006/05/25 10:30:13  jorpiell
120
 * Esta clase se ha renombrado. WFSFields era algo confusa
121
 *
122
 * Revision 1.3  2006/05/23 08:09:39  jorpiell
123
 * 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
124
 *
125
 * Revision 1.2  2006/05/19 12:57:08  jorpiell
126
 * Modificados algunos paneles
127
 *
128
 * Revision 1.1  2006/04/20 16:38:24  jorpiell
129
 * 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().
130
 *
131
 *
132
 */
133
/**
134
 * This panel shows the feature fields list
135
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
136
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
137
 */
138
public class WFSSelectAttributesPanel extends JPanel {
139
        private static final long serialVersionUID = 3073243334672620143L;
140
        private JScrollPane fieldsScroll = null;
141
        private AttributesTreeTable fieldsTreeTable = null;
142
        private AttributesTreeTableModel model = null;
143
        private WFSParamsPanel parent = null;
144
        private JPanel treeTablePanel = null;
145
        private boolean fieldsSelectedOfSameLayerHasChanged;
146

    
147
        public WFSSelectAttributesPanel(WFSParamsPanel parent){
148
                super();
149
                this.parent = parent;
150
                initialize();
151
        }
152

    
153
        public void initialize(){
154
                this.setLayout(null);
155
                this.setBounds(10, 5, 481, 427);                
156
                this.add(getTreeTablePanel(), null);
157
                fieldsSelectedOfSameLayerHasChanged = false;
158
        }
159

    
160
        /**
161
         * This method initializes jScrollPane3
162
         *
163
         * @return javax.swing.JScrollPane
164
         */
165
        private JScrollPane getFieldsScroll() {
166
                if (fieldsScroll == null) {
167
                        fieldsScroll = new JScrollPane();
168
                        fieldsScroll.setLocation(new java.awt.Point(6,20));
169
                        fieldsScroll.setSize(new java.awt.Dimension(470,349));
170
                        fieldsScroll.setViewportView(getAttributesTreeTable());
171
                }
172
                return fieldsScroll;
173
        }
174

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

    
208
        public void refresh(WFSLayerNode feature){
209
                setFields(feature);                        
210
        }
211

    
212
        /**
213
         *
214
         * @param feature
215
         */
216
        private void setFields(WFSLayerNode feature){
217
                Vector fields = feature.getFields();
218
                if (fields.size() > 0){
219
                        model = new TreeTableModelWithCheckBoxes(fields.get(0));
220
                        fieldsTreeTable.setModel(model);
221
                }
222
        }
223
        
224
        public void setSelectedFields(WFSLayerNode feature){
225
                Vector selectedFields = feature.getSelectedFields();
226
                fieldsTreeTable.setSelectedFields(selectedFields);
227
        }                
228

    
229
        /**
230
         *
231
         * @return the selected fields.
232
         */
233
        public XMLElement[] getSelectedFields(){
234
                return fieldsTreeTable.getSelectedElements();
235
        }
236

    
237
        /**
238
         * This method initializes treeTablePanel        
239
         *         
240
         * @return javax.swing.JPanel        
241
         */
242
        private JPanel getTreeTablePanel() {
243
                if (treeTablePanel == null) {
244
                        treeTablePanel = new JPanel();
245
                        treeTablePanel.setLayout(null);
246
                        treeTablePanel.setLocation(new java.awt.Point(7,4));
247
                        treeTablePanel.setSize(new java.awt.Dimension(482,375));
248
                        treeTablePanel.add(getFieldsScroll(), null);
249
                        treeTablePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
250
                                        null, PluginServices.getText(this, "select_fields"),
251
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
252
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
253
                }
254
                return treeTablePanel;
255
        }
256
        
257
        /**
258
         * Returns true if user has changed the selection of some field of the same layer; else returns false
259
         * 
260
         * @return A boolean value
261
         */
262
        public boolean getFieldsSelectedOfSameLayerHasChanged() {
263
                return this.fieldsSelectedOfSameLayerHasChanged;
264
        }
265
        
266
        /**
267
         * @param updated The updated to set.
268
         */
269
        public void setUpdated(boolean updated) {
270
                parent.isApplicable(updated);
271
        }
272

    
273
        /**
274
         * Resets the value of the field 'fieldsSelectedOfSameLayerHasChanged'
275
         * 
276
         * @return A boolean value
277
         */
278
        public void resetFieldsSelectedOfSameLayerHasChanged() {
279
                this.fieldsSelectedOfSameLayerHasChanged = false;
280
        }
281
}  //  @jve:decl-index=0:visual-constraint="10,22"