Statistics
| Revision:

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

History | View | Annotate | Download (15.2 KB)

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

    
3
import java.awt.Dimension;
4
import java.util.Map;
5

    
6
import javax.swing.JTabbedPane;
7

    
8
import org.gvsig.gui.beans.panelGroup.PanelGroupManager;
9
import org.gvsig.gui.beans.panelGroup.tabbedPanel.TabbedPanel;
10

    
11
import com.iver.andami.messages.NotificationManager;
12
import com.iver.cit.gvsig.fmap.drivers.wfs.FMapWFSDriver;
13
import com.iver.cit.gvsig.fmap.layers.FLayer;
14
import com.iver.cit.gvsig.fmap.layers.WFSLayerNode;
15
import com.iver.cit.gvsig.gui.WizardPanel;
16
import com.iver.cit.gvsig.gui.wizards.WFSWizard;
17
import com.iver.cit.gvsig.gui.wizards.WFSWizardData;
18
import com.iver.cit.gvsig.gui.wizards.WizardListener;
19
import com.iver.cit.gvsig.gui.wizards.WizardListenerSupport;
20

    
21
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
22
 *
23
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
24
 *
25
 * This program is free software; you can redistribute it and/or
26
 * modify it under the terms of the GNU General Public License
27
 * as published by the Free Software Foundation; either version 2
28
 * of the License, or (at your option) any later version.
29
 *
30
 * This program is distributed in the hope that it will be useful,
31
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
33
 * GNU General Public License for more details.
34
 *
35
 * You should have received a copy of the GNU General Public License
36
 * along with this program; if not, write to the Free Software
37
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
38
 *
39
 * For more information, contact:
40
 *
41
 *  Generalitat Valenciana
42
 *   Conselleria d'Infraestructures i Transport
43
 *   Av. Blasco Ib??ez, 50
44
 *   46010 VALENCIA
45
 *   SPAIN
46
 *
47
 *      +34 963862235
48
 *   gvsig@gva.es
49
 *      www.gvsig.gva.es
50
 *
51
 *    or
52
 *
53
 *   IVER T.I. S.A
54
 *   Salamanca 50
55
 *   46005 Valencia
56
 *   Spain
57
 *
58
 *   +34 963163400
59
 *   dac@iver.es
60
 */
61
/* CVS MESSAGES:
62
 *
63
 * $Id: WFSParamsPanel.java 17593 2007-12-18 13:08:46Z jpiera $
64
 * $Log$
65
 * Revision 1.42  2007-09-19 16:14:50  jaume
66
 * removed unnecessary imports
67
 *
68
 * Revision 1.41  2007/06/26 09:33:54  jorpiell
69
 * Information tab refreshed
70
 *
71
 * Revision 1.40  2007/04/11 12:08:55  ppiqueras
72
 * Varios cambios:
73
 * - Corregida etiqueta "Campo"
74
 * - Cambiada actualizaci?n
75
 * - Corregido bug: actualizar ?rea visible despu?s de pulsar "Aplicar" en la interfaz gr?fica.
76
 *
77
 * Revision 1.39  2007/03/15 13:33:44  ppiqueras
78
 * Corregido bug de excepci?n que se lanzaba cuando se filtraba y no se pod?a cargar la capa.
79
 *
80
 * Revision 1.38  2007/03/05 13:49:42  ppiqueras
81
 * Si una capa WFS no tiene campos (y por tanto no tiene un campo obligatorio de tipo geometr?a), que avise al usuario y no permita que se intente cargar dicha capa.
82
 *
83
 * Revision 1.37  2007/03/01 13:12:09  ppiqueras
84
 * Mejorado el filtrado por ?rea.
85
 *
86
 * Revision 1.36  2007/02/22 12:30:59  ppiqueras
87
 * - Eliminado m?todo que sobraba.
88
 * - Mejorada la relaci?n con el panel del ?rea.
89
 * - A?adido JOptionPanel de aviso que no se aplicar? ?rea porque es incorrecta.
90
 *
91
 * Revision 1.35  2007/02/20 11:31:11  ppiqueras
92
 * Eliminados comentarios que sobraban.
93
 *
94
 * Revision 1.34  2007/02/19 11:44:42  jorpiell
95
 * A?adidos los filtros por ?rea
96
 *
97
 * Revision 1.33  2007/02/16 13:36:53  ppiqueras
98
 * Que el ?rea seleccionada en el panel WFSArea sea accesible una vez se va a aplicar.
99
 *
100
 * Revision 1.32  2007/02/12 11:37:00  ppiqueras
101
 * A?adidos comentarios y m?todo para refrescar el MapControl de la pesta?a del ?rea.
102
 *
103
 * Revision 1.31  2007/02/09 14:12:39  jorpiell
104
 * Soporte para WFS 1.1 y WFS-T
105
 *
106
 * Revision 1.30  2007/02/02 12:22:22  ppiqueras
107
 * Corregido alg?n bug.
108
 *
109
 * Revision 1.29  2007/01/08 09:37:39  ppiqueras
110
 * Eliminado comentario que sobraba
111
 *
112
 * Revision 1.28  2006/12/29 09:27:02  ppiqueras
113
 * Corregidos varios bugs:
114
 *
115
 * - Se ejecuta 2 veces "Aplicar" o "Aceptar" en los filtros WFS.
116
 * - Cuando se carga por primera vez una capa WFS, si se pone un
117
 * filtro incorrecto, se ignora el filtro (cargando toda la informaci?n posible de la capa, y borrando el texto de filtrado).
118
 *
119
 * Revision 1.27  2006/12/26 09:19:40  ppiqueras
120
 * 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).
121
 *
122
 * Revision 1.26  2006/12/20 14:22:06  ppiqueras
123
 * A?adido comentario
124
 *
125
 * Revision 1.25  2006/12/15 13:59:36  ppiqueras
126
 * -Permite que se almacenen y/o recojan todos los campos y valores conocidos de la capa actual.
127
 *
128
 * -Adem?s, control frentre a consultas de filtro err?neas, (esto a medias a?n).
129
 *
130
 * - Alg?n comentario m?s.
131
 *
132
 * Revision 1.24  2006/12/12 10:24:45  ppiqueras
133
 * Nueva funcionalidad: Pulsando doble 'click' sobre una capa de un servidor, se carga (igual que antes), pero adem?s se avanza a la siguiente pesta?a sin tener que pulsar el bot?n 'Siguiente'.
134
 *
135
 * Revision 1.23  2006/12/11 11:02:24  ppiqueras
136
 * Corregido bug -> que se mantenga la frase de filtrado
137
 *
138
 * Revision 1.22  2006/12/04 08:59:47  ppiqueras
139
 * Algunos bugs corregidos. A cambio hay 2 bugs relacionados que todav?a no han sido corregidos (ver PHPCollab) (los tiene asignados Jorge).
140
 *
141
 * Revision 1.21  2006/11/28 08:05:13  jorpiell
142
 * Se escribe la query en la pesta?a del filtro
143
 *
144
 * Revision 1.20  2006/11/14 13:45:49  ppiqueras
145
 * A?adida peque?a funcionalidad:
146
 * Cuando se pulsa el bot?n "Aplicar", (al seleccionar un nuevo filtro), si el ?rbol de campos posee alguno seleccionado, actualiza los valores (con los nuevos), asociados a ?ste campo seleccionado.
147
 *
148
 * Revision 1.19  2006/10/27 12:10:02  ppiqueras
149
 * Nueva funcionalidad
150
 *
151
 * Revision 1.16  2006/10/23 07:37:04  jorpiell
152
 * Ya funciona el filterEncoding
153
 *
154
 * Revision 1.14  2006/10/13 13:05:32  ppiqueras
155
 * Permite el refrescado de datos del panel de filtrado sobre capa WFS.
156
 *
157
 * Revision 1.13  2006/10/10 12:55:06  jorpiell
158
 * Se ha a?adido el soporte de features complejas
159
 *
160
 * Revision 1.12  2006/10/02 09:17:48  jorpiell
161
 * A?adido el setCRS a la capa
162
 *
163
 * Revision 1.11  2006/09/29 13:02:38  ppiqueras
164
 * Filtro para WFS. De momento s?lo interfaz gr?fica.
165
 *
166
 * Revision 1.10  2006/07/21 11:50:31  jaume
167
 * improved appearance
168
 *
169
 * Revision 1.9  2006/06/21 12:35:45  jorpiell
170
 * 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
171
 *
172
 * Revision 1.8  2006/06/15 07:50:58  jorpiell
173
 * A?adida la funcionalidad de reproyectar y hechos algunos cambios en la interfaz
174
 *
175
 * Revision 1.7  2006/05/25 16:22:47  jorpiell
176
 * Se limpia el panel cada vez que se conecta con un servidor distinto
177
 *
178
 * Revision 1.6  2006/05/25 16:01:43  jorpiell
179
 * Se ha a?adido la funcionalidad para eliminar el namespace de los tipos de atributos
180
 *
181
 * Revision 1.5  2006/05/25 10:31:06  jorpiell
182
 * Como ha cambiado la forma de mostrar las capas (una tabla, en lugar de una lista), los paneles han tenido que ser modificados
183
 *
184
 * Revision 1.4  2006/05/23 08:09:39  jorpiell
185
 * 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
186
 *
187
 * Revision 1.3  2006/05/19 12:57:08  jorpiell
188
 * Modificados algunos paneles
189
 *
190
 * Revision 1.2  2006/04/20 16:38:24  jorpiell
191
 * 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().
192
 *
193
 * Revision 1.1  2006/04/19 12:50:16  jorpiell
194
 * Primer commit de la aplicaci?n. Se puede hacer un getCapabilities y ver el mensaje de vienvenida del servidor
195
 *
196
 *
197
 */
198
/**
199
 * A JPanel with a JTabbedPane with JPanels for WFS
200
 * 
201
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
202
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
203
 */
204
public class WFSParamsPanel extends WizardPanel{
205
        private TabbedPanel jTabbedPane = null; 
206
        private WizardListenerSupport listenerSupport;
207
        private WFSParamsPanelData data = null;
208
        //Tab positions
209
        private int infoTabPosition = 0;
210
        private int featureTabPosition = 1;
211
        private int fieldsTabPosition = 2;
212
        private int optionsPosition = 3;
213
        private int filterTabPosition = 4;
214
        private int areaTabPosition = 5;
215
        
216
        /**
217
         * This method initializes jTabbedPane
218
         *
219
         * @return javax.swing.JTabbedPane
220
         */
221

    
222
        public WFSParamsPanel(){
223
                super();
224
                initialize();
225
        }
226

    
227
        /**
228
         * Initilaize the Panel
229
         */
230
        private void initialize() {
231
                this.data = new WFSParamsPanelData(this);
232
                this.setLayout(null);
233
                this.setVisible(false);
234
                this.setPreferredSize(new Dimension(510, 427));
235
                this.add(getJTabbedPane(), null);
236
                setListenerSupport(new WizardListenerSupport());
237
        }
238
                        
239
        /**
240
         * Returns the tab amount that the WFSParamsPanel currently have
241
         *
242
         * Devuelve el n?mero de solapas que tiene actualmente el WFSParamsPanel
243
         *
244
         * @return int
245
         */
246
        public int getNumTabs(){
247
                return getJTabbedPane().getPanelInGUICount();
248
        }
249

    
250
        /**
251
         * Sets the focus to the tab next to the current one.
252
         *
253
         * Enfoca a la solapa siguiente a la actualmente enfocada del TabbedPane
254
         *
255
         */
256
        public void avanzaTab(){
257
                int currentPage = currentPage();
258
                int nPages = getNumTabs();
259
                if (nPages -1 > currentPage){
260
                        getJTabbedPane().setSelectedIndex(nextPageEnabled());
261
                }                
262
        }
263

    
264
        /**
265
         * Sets the focus to the tab previous to the current one.
266
         *
267
         * Enfoca a la solapa anterior a la actualmente enfocada del TabbedPane
268
         *
269
         */
270
        public void retrocedeTab(){
271
                this.getJTabbedPane().setSelectedIndex(previousEnabledPage());
272
        }
273

    
274
        /**
275
         * @see JTabbedPane#getSelectedIndex()
276
         */
277
        public int getSelectedIndex(){
278
                return this.getJTabbedPane().getSelectedIndex();
279
        }
280

    
281
        /**
282
         * @see JTabbedPane#setSelectedIndex(int)
283
         */
284
        public void setSelectedIndex(int index) {
285
                this.getJTabbedPane().setSelectedIndex(index);
286
        }
287

    
288
        public TabbedPanel getJTabbedPane() {
289
                if (jTabbedPane == null) {
290
                        try{
291
                                PanelGroupManager manager = PanelGroupManager.getManager();
292
                                manager.registerPanelGroup(TabbedPanel.class);
293
                                manager.setDefaultType(TabbedPanel.class);
294
                                jTabbedPane = (TabbedPanel) manager.getPanelGroup(null);
295
                                jTabbedPane.addPanel(getInfoPanel());
296
                                jTabbedPane.addPanel(getFeaturesPanel());
297
                                jTabbedPane.addPanel(getFieldsPanel());
298
                                jTabbedPane.addPanel(getOptionsPanel());
299
                                jTabbedPane.addPanel(getFilterPanel());
300
                                jTabbedPane.addPanel(getAreaPanel());
301
                                jTabbedPane.setBounds(4, 4, 502, 415);        
302
                        }catch (Exception e){                                
303
                                e.printStackTrace();
304
                                NotificationManager.addError(e);
305
                        }                        
306
                }
307
                return jTabbedPane;
308
        }
309

    
310
        /**
311
         * @return the information panel
312
         */
313
        private WFSInfoPanel getInfoPanel() {
314
                return data.getInfoPanel();
315
        }
316
        
317
        /**
318
         * This method initializes panelFeatures
319
         *
320
         * @return javax.swing.JPanel
321
         */
322
        private WFSSelectFeaturePanel getFeaturesPanel() {
323
                return data.getFeaturePanel();
324
        }
325

    
326
        /**
327
         * This method initializes fieldsPanel
328
         *
329
         * @return javax.swing.JPanel
330
         */
331
        private WFSSelectFieldsPanel getFieldsPanel(){
332
                return data.getFieldsPanel();
333
        }
334
        
335
        /**
336
         * This method initializes fieldsPanel
337
         *
338
         * @return javax.swing.JPanel
339
         */
340
        private WFSOptionsPanel getOptionsPanel(){
341
                return data.getOptionsPanel();
342
        }
343

    
344

    
345
        /**
346
         * This method initializes filterPanel
347
         * 
348
         * @return javax.swing.JPanel
349
         */
350
        private WFSFilterPanel getFilterPanel(){
351
                return data.getFilterPanel();
352
        }
353

    
354
        /**
355
         * This method initializes areaPanel
356
         * 
357
         * @return javax.swing.JPanel
358
         */
359
        private WFSAreaPanel getAreaPanel(){
360
                return data.getAreaPanel();
361
        }
362

    
363
        /**
364
         * Verifies that the selected parameters are enough to request the coverage
365
         * to the server.
366
         * @return boolean
367
         */
368
        public boolean isCorretlyConfigured() {
369
                return data.isCorretlyConfigured();
370
        }
371

    
372
        /**
373
         * Enable or disable the default tabs
374
         */
375
        public void enableDefaultTabs(boolean isEnabled) {
376
                jTabbedPane.setEnabledAt(fieldsTabPosition, isEnabled);
377
                jTabbedPane.setEnabledAt(filterTabPosition, isEnabled);
378
                jTabbedPane.setEnabledAt(areaTabPosition, isEnabled);
379
        }
380

    
381
        /**
382
         * Refresh all the panels with the WFS capabilities 
383
         * information
384
         */
385
        public void refreshCapabilitiesInfo(){
386
                data.refreshCapabilitiesInfo();
387
        }                
388
        
389
        /**
390
         * Sets the object that holds the wizard data.
391
         *
392
         * Establece el objeto que contiene los datos del wizard.
393
         *
394
         * @param data
395
         */
396
        public void setWizardData(WFSWizardData wizardData) {
397
                this.data.setWizardData(wizardData);
398
        }
399

    
400
        /**
401
         * Returns the next enabled tab's index.
402
         *
403
         * Devuelve el ?ndicie de la siguiente pesta?a habilitada del wizard o -1 si no hay
404
         * ninguna.
405
         *
406
         * @return The index or -1 if there is no one.
407
         */
408
        public int nextPageEnabled() {
409
                int currentPage = currentPage();
410
                int nPages = getNumTabs();
411
                if (currentPage == nPages)
412
                        return -1;
413
                for (int i=currentPage+1; i<nPages; i++){
414
                        if (getJTabbedPane().isEnabledAt(i)){
415
                                return i;
416
                        }
417
                }
418
                return -1;
419
        }
420

    
421
        /**
422
         * Returns the index of the current tab.
423
         *
424
         * Devuelve el ?ndice de la p?gina actual del wizard.
425
         *
426
         * @return
427
         */
428
        public int currentPage() {
429
                return getJTabbedPane().getSelectedIndex();
430
        }
431

    
432
        /**
433
         * Returns the index of the previous enabled tab.
434
         *
435
         * Devuelve el ?ndice de la anterior p?gina habilitada del wizard o -1 si no hay
436
         * ninguna.
437
         *
438
         * @return The index, or -1 if there is no one.
439
         */
440
        public int previousEnabledPage() {
441
                int currentPage = currentPage();
442
                int j=0;
443
                if (currentPage == 0)
444
                        j= -1;
445
                for (int i = currentPage-1; i>-1; i--){
446
                        if (getJTabbedPane().isEnabledAt(i)){
447
                                j= i;
448
                                break;
449
                        }
450
                }
451
                return j;
452
        }
453

    
454
        /**
455
         * @return the WFS driver used to retrieve the
456
         * information
457
         */
458
        public FMapWFSDriver getDriver() {
459
                return data.getDriver();
460
        }
461

    
462
        /*
463
         *  (non-Javadoc)
464
         * @see com.iver.cit.gvsig.gui.WizardPanel#initWizard()
465
         */
466
        public void initWizard() {
467

    
468
        }
469

    
470
        /*
471
         *  (non-Javadoc)
472
         * @see com.iver.cit.gvsig.gui.WizardPanel#execute()
473
         */
474
        public void execute() {
475

    
476
        }
477

    
478
        /*
479
         *  (non-Javadoc)
480
         * @see com.iver.cit.gvsig.gui.ILayerPanel#getLayer()
481
         */
482
        public FLayer getLayer() {
483
                return data.getLayer();
484
        }
485

    
486
        /*
487
         * (non-Javadoc)
488
         * @see com.iver.cit.gvsig.gui.WizardPanel#addWizardListener(com.iver.cit.gvsig.gui.wizards.WizardListener)
489
         */
490
        public void addWizardListener(WizardListener listener) {
491
                listenerSupport.addWizardListener(listener);
492
        }
493

    
494
        public void isApplicable(boolean applicable){
495
                listenerSupport.callStateChanged(applicable);
496
        }        
497

    
498
        /**
499
         * @see WFSWizard#doClickOnNextButton()
500
         */
501
        public void doClickOnNextButton() {
502
                Object obj = this.getParent();
503

    
504
                // When we start to connect to a server -> the interface is the dialog WFSWizard
505
                if (obj instanceof WFSWizard)
506
                        ((WFSWizard)this.getParent()).doClickOnNextButton();
507
                else {
508
                        // When we are modifying a loaded layer -> the interface is the dialog WFSPropsDialog
509
//                        if (obj instanceof WFSPropsDialog)
510
//                                this.advanceCurrentTab();
511
                }
512
        }
513

    
514
        /**
515
         * Selects the next tab
516
         */
517
        public void advanceCurrentTab() {
518
                int currentTabIndex = this.getJTabbedPane().getSelectedIndex();
519

    
520
                // Ensure we can select next tab
521
                if ((currentTabIndex != -1) && (currentTabIndex < (this.getJTabbedPane().values().size() -1)))
522
                        this.getJTabbedPane().setSelectedIndex(currentTabIndex + 1);
523
        }
524

    
525
        /**
526
         * @return the listenerSupport
527
         */
528
        public WizardListenerSupport getListenerSupport() {
529
                return listenerSupport;
530
        }                
531

    
532
        /**
533
         * Sets the listenerSupport
534
         * @param support
535
         */
536
        public void setListenerSupport(WizardListenerSupport support) {
537
                listenerSupport = support;
538
        }
539
}