Statistics
| Revision:

root / branches / v10 / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / WFSSelectAttributesPanel.java @ 9153

History | View | Annotate | Download (9.04 KB)

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

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

    
8
import javax.swing.JFrame;
9
import javax.swing.JPanel;
10
import javax.swing.JScrollPane;
11

    
12
import org.gvsig.remoteClient.gml.factories.XMLElementsFactory;
13
import org.gvsig.remoteClient.gml.schemas.IXMLType;
14
import org.gvsig.remoteClient.gml.schemas.XMLComplexType;
15
import org.gvsig.remoteClient.gml.schemas.XMLElement;
16
import org.gvsig.remoteClient.gml.schemas.XMLSchemaParser;
17

    
18
import com.iver.andami.PluginServices;
19
import com.iver.cit.gvsig.fmap.layers.WFSLayerNode;
20
import com.iver.cit.gvsig.gui.panels.attributesTree.AttributesTreeTable;
21
import com.iver.cit.gvsig.gui.panels.attributesTree.AttributesTreeTableModel;
22
import com.iver.cit.gvsig.gui.panels.attributesTree.TreeTableModelWithCheckBoxes;
23

    
24
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
25
 *
26
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
27
 *
28
 * This program is free software; you can redistribute it and/or
29
 * modify it under the terms of the GNU General Public License
30
 * as published by the Free Software Foundation; either version 2
31
 * of the License, or (at your option) any later version.
32
 *
33
 * This program is distributed in the hope that it will be useful,
34
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
35
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
36
 * GNU General Public License for more details.
37
 *
38
 * You should have received a copy of the GNU General Public License
39
 * along with this program; if not, write to the Free Software
40
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
41
 *
42
 * For more information, contact:
43
 *
44
 *  Generalitat Valenciana
45
 *   Conselleria d'Infraestructures i Transport
46
 *   Av. Blasco Ib??ez, 50
47
 *   46010 VALENCIA
48
 *   SPAIN
49
 *
50
 *      +34 963862235
51
 *   gvsig@gva.es
52
 *      www.gvsig.gva.es
53
 *
54
 *    or
55
 *
56
 *   IVER T.I. S.A
57
 *   Salamanca 50
58
 *   46005 Valencia
59
 *   Spain
60
 *
61
 *   +34 963163400
62
 *   dac@iver.es
63
 */
64
/* CVS MESSAGES:
65
 *
66
 * $Id: WFSSelectAttributesPanel.java 9153 2006-12-04 09:39:34Z ppiqueras $
67
 * $Log$
68
 * Revision 1.7.2.4  2006-12-04 09:39:34  ppiqueras
69
 * 1 Bug corregido
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
 */
137
public class WFSSelectAttributesPanel extends JPanel {
138
        private static final long serialVersionUID = 3073243334672620143L;
139
        private JScrollPane attributesScroll = null;
140
        private AttributesTreeTable attributesTreeTable = null;
141
        private AttributesTreeTableModel model = null;
142
        private WFSParamsPanel parent = null;
143
        private JPanel treeTablePanel = null;
144
        private boolean attributesSelectedOfSameLayerHasChanged;
145

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

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

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

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

    
203
        public void refresh(WFSLayerNode feature){
204
                setFields(feature);                        
205
        }
206

    
207
        /**
208
         *
209
         * @param feature
210
         */
211
        private void setFields(WFSLayerNode feature){
212
                Vector fields = feature.getFields();
213
                model = new TreeTableModelWithCheckBoxes(fields.get(0));
214
                attributesTreeTable.setModel(model);
215
        }
216
        
217
        public void setSelectedFields(WFSLayerNode feature){
218
                Vector selectedFields = feature.getSelectedFields();
219
                attributesTreeTable.setSelectedFields(selectedFields);
220
        }                
221

    
222
        /**
223
         *
224
         * @return the selected fields.
225
         */
226
        public XMLElement[] getSelectedFields(){
227
                return attributesTreeTable.getSelectedElements();
228
        }
229

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

    
266
        /**
267
         * Resets the value of the attribute 'attributesSelectedOfSameLayerHasChanged'
268
         * 
269
         * @return A boolean value
270
         */
271
        public void resetAttributesSelectedOfSameLayerHasChanged() {
272
                this.attributesSelectedOfSameLayerHasChanged = false;
273
        }
274
}  //  @jve:decl-index=0:visual-constraint="10,22"