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 5436 jorpiell
package com.iver.cit.gvsig.gui.panels;
2
3 9153 ppiqueras
import java.beans.PropertyChangeEvent;
4
import java.beans.PropertyChangeListener;
5 5436 jorpiell
import java.util.Vector;
6
7
import javax.swing.JPanel;
8
import javax.swing.JScrollPane;
9
10 8765 jjdelcerro
import org.gvsig.remoteClient.gml.schemas.XMLElement;
11 5436 jorpiell
12
import com.iver.andami.PluginServices;
13
import com.iver.cit.gvsig.fmap.layers.WFSLayerNode;
14 8765 jjdelcerro
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 5436 jorpiell
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 9575 ppiqueras
 * Revision 1.7.2.5  2007-01-08 09:52:11  ppiqueras
63
 * Corridos bugs + nueva funcionalidad.
64 8765 jjdelcerro
 *
65 9575 ppiqueras
 * 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 9153 ppiqueras
 * 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 8765 jjdelcerro
 * 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 7355 jorpiell
 * 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 7032 jorpiell
 * Reducido el tama?o de los botones
103
 *
104
 * Revision 1.6  2006/07/24 07:30:33  jorpiell
105 6506 jorpiell
 * 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 6501 jaume
 * improved appearance
109
 *
110
 * Revision 1.4  2006/06/21 12:35:45  jorpiell
111 5948 jorpiell
 * 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 5856 jorpiell
 * 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 5472 jorpiell
 * 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 5436 jorpiell
 * 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 9575 ppiqueras
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
137 5436 jorpiell
 */
138
public class WFSSelectAttributesPanel extends JPanel {
139
        private static final long serialVersionUID = 3073243334672620143L;
140 9575 ppiqueras
        private JScrollPane fieldsScroll = null;
141
        private AttributesTreeTable fieldsTreeTable = null;
142 8765 jjdelcerro
        private AttributesTreeTableModel model = null;
143 5948 jorpiell
        private WFSParamsPanel parent = null;
144 8765 jjdelcerro
        private JPanel treeTablePanel = null;
145 9575 ppiqueras
        private boolean fieldsSelectedOfSameLayerHasChanged;
146 6501 jaume
147 5948 jorpiell
        public WFSSelectAttributesPanel(WFSParamsPanel parent){
148 5436 jorpiell
                super();
149 5948 jorpiell
                this.parent = parent;
150 5436 jorpiell
                initialize();
151
        }
152 6501 jaume
153 5436 jorpiell
        public void initialize(){
154
                this.setLayout(null);
155 8765 jjdelcerro
                this.setBounds(10, 5, 481, 427);
156
                this.add(getTreeTablePanel(), null);
157 9575 ppiqueras
                fieldsSelectedOfSameLayerHasChanged = false;
158 5436 jorpiell
        }
159 6501 jaume
160 5436 jorpiell
        /**
161 6501 jaume
         * This method initializes jScrollPane3
162
         *
163
         * @return javax.swing.JScrollPane
164
         */
165 9575 ppiqueras
        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 5436 jorpiell
                }
172 9575 ppiqueras
                return fieldsScroll;
173 5436 jorpiell
        }
174 6501 jaume
175 5436 jorpiell
        /**
176 6501 jaume
         * This method initializes lstTemps
177
         *
178
         * @return javax.swing.JList
179
         */
180 8765 jjdelcerro
        public AttributesTreeTable getAttributesTreeTable() {
181 9575 ppiqueras
                if (fieldsTreeTable == null) {
182 8765 jjdelcerro
                        model = new TreeTableModelWithCheckBoxes();
183 9575 ppiqueras
                        fieldsTreeTable = new AttributesTreeTable(model,this);
184
                        fieldsTreeTable.setLocation(new java.awt.Point(7,4));
185
                        fieldsTreeTable.setSize(new java.awt.Dimension(482,302));
186 9153 ppiqueras
187 9575 ppiqueras
                        // If user has changed the fields selection in the same layer
188
                        fieldsTreeTable.addPropertyChangeListener(new PropertyChangeListener() {
189 9153 ppiqueras
                                /*
190
                                 *  (non-Javadoc)
191
                                 * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
192
                                 */
193
                                public void propertyChange(PropertyChangeEvent evt) {
194 9575 ppiqueras
                                        // 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 9153 ppiqueras
                                }
203
                        });
204 5436 jorpiell
                }
205 9575 ppiqueras
                return fieldsTreeTable;
206 5436 jorpiell
        }
207 6501 jaume
208 5856 jorpiell
        public void refresh(WFSLayerNode feature){
209 8765 jjdelcerro
                setFields(feature);
210 5856 jorpiell
        }
211 6501 jaume
212 5436 jorpiell
        /**
213 6501 jaume
         *
214 5436 jorpiell
         * @param feature
215
         */
216 5856 jorpiell
        private void setFields(WFSLayerNode feature){
217 6501 jaume
                Vector fields = feature.getFields();
218 18320 jpiera
                if (fields.size() > 0){
219
                        model = new TreeTableModelWithCheckBoxes(fields.get(0));
220
                        fieldsTreeTable.setModel(model);
221
                }
222 5436 jorpiell
        }
223 8765 jjdelcerro
224 5948 jorpiell
        public void setSelectedFields(WFSLayerNode feature){
225
                Vector selectedFields = feature.getSelectedFields();
226 9575 ppiqueras
                fieldsTreeTable.setSelectedFields(selectedFields);
227 8765 jjdelcerro
        }
228 6501 jaume
229 5436 jorpiell
        /**
230 8765 jjdelcerro
         *
231
         * @return the selected fields.
232 5436 jorpiell
         */
233 8765 jjdelcerro
        public XMLElement[] getSelectedFields(){
234 9575 ppiqueras
                return fieldsTreeTable.getSelectedElements();
235 5436 jorpiell
        }
236 6501 jaume
237 5436 jorpiell
        /**
238 8765 jjdelcerro
         * This method initializes treeTablePanel
239
         *
240
         * @return javax.swing.JPanel
241 5436 jorpiell
         */
242 8765 jjdelcerro
        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 9575 ppiqueras
                        treeTablePanel.add(getFieldsScroll(), null);
249 8765 jjdelcerro
                        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 5436 jorpiell
                }
254 8765 jjdelcerro
                return treeTablePanel;
255 5436 jorpiell
        }
256 8765 jjdelcerro
257 5436 jorpiell
        /**
258 9575 ppiqueras
         * Returns true if user has changed the selection of some field of the same layer; else returns false
259 9153 ppiqueras
         *
260
         * @return A boolean value
261
         */
262 9575 ppiqueras
        public boolean getFieldsSelectedOfSameLayerHasChanged() {
263
                return this.fieldsSelectedOfSameLayerHasChanged;
264 9153 ppiqueras
        }
265
266
        /**
267 8765 jjdelcerro
         * @param updated The updated to set.
268 5436 jorpiell
         */
269 8765 jjdelcerro
        public void setUpdated(boolean updated) {
270
                parent.isApplicable(updated);
271 5436 jorpiell
        }
272 9153 ppiqueras
273
        /**
274 9575 ppiqueras
         * Resets the value of the field 'fieldsSelectedOfSameLayerHasChanged'
275 9153 ppiqueras
         *
276
         * @return A boolean value
277
         */
278 9575 ppiqueras
        public void resetFieldsSelectedOfSameLayerHasChanged() {
279
                this.fieldsSelectedOfSameLayerHasChanged = false;
280 9153 ppiqueras
        }
281 5472 jorpiell
}  //  @jve:decl-index=0:visual-constraint="10,22"