Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / WFSSelectAttributesPanel.java @ 9151

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

    
143
        public WFSSelectAttributesPanel(WFSParamsPanel parent){
144
                super();
145
                this.parent = parent;
146
                initialize();
147
        }
148

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

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

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

    
200
        public void refresh(WFSLayerNode feature){
201
                setFields(feature);                        
202
        }
203

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

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

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

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