Statistics
| Revision:

root / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / WFSParamsPanel.java @ 4911

History | View | Annotate | Download (9.77 KB)

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

    
3
import java.awt.event.FocusEvent;
4
import java.awt.event.FocusListener;
5
import java.util.prefs.Preferences;
6

    
7
import javax.swing.JCheckBox;
8
import javax.swing.JLabel;
9
import javax.swing.JPanel;
10
import javax.swing.JScrollPane;
11
import javax.swing.JTabbedPane;
12
import javax.swing.JTextField;
13

    
14
import com.iver.andami.PluginServices;
15
import com.iver.cit.gvsig.fmap.drivers.wfs.FMapWFSDriver;
16
import com.iver.cit.gvsig.fmap.layers.FLayer;
17
import com.iver.cit.gvsig.fmap.layers.WFSLayerNode;
18
import com.iver.cit.gvsig.gui.WizardPanel;
19
import com.iver.cit.gvsig.gui.wizards.WFSWizardData;
20
import com.iver.cit.gvsig.gui.wizards.WizardListenerSupport;
21

    
22
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
23
 *
24
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
25
 *
26
 * This program is free software; you can redistribute it and/or
27
 * modify it under the terms of the GNU General Public License
28
 * as published by the Free Software Foundation; either version 2
29
 * of the License, or (at your option) any later version.
30
 *
31
 * This program is distributed in the hope that it will be useful,
32
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
33
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
34
 * GNU General Public License for more details.
35
 *
36
 * You should have received a copy of the GNU General Public License
37
 * along with this program; if not, write to the Free Software
38
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
39
 *
40
 * For more information, contact:
41
 *
42
 *  Generalitat Valenciana
43
 *   Conselleria d'Infraestructures i Transport
44
 *   Av. Blasco Ib??ez, 50
45
 *   46010 VALENCIA
46
 *   SPAIN
47
 *
48
 *      +34 963862235
49
 *   gvsig@gva.es
50
 *      www.gvsig.gva.es
51
 *
52
 *    or
53
 *
54
 *   IVER T.I. S.A
55
 *   Salamanca 50
56
 *   46005 Valencia
57
 *   Spain
58
 *
59
 *   +34 963163400
60
 *   dac@iver.es
61
 */
62
/* CVS MESSAGES:
63
 *
64
 * $Id: WFSParamsPanel.java 4911 2006-04-20 16:38:24Z jorpiell $
65
 * $Log$
66
 * Revision 1.2  2006-04-20 16:38:24  jorpiell
67
 * 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().
68
 *
69
 * Revision 1.1  2006/04/19 12:50:16  jorpiell
70
 * Primer commit de la aplicaci?n. Se puede hacer un getCapabilities y ver el mensaje de vienvenida del servidor
71
 *
72
 *
73
 */
74
/**
75
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
76
 */
77
public class WFSParamsPanel extends WizardPanel{
78
                
79
        private JTabbedPane jTabbedPane = null;  //  @jve:decl-index=0:visual-constraint="37,30"
80
        private WFSSelectFeaturePanel featurePanel = null;
81
        private WFSSelectFieldsPanel fieldsPanel = null;
82
        private WFSOptionsPanel optionsPanel = null;
83
        private WFSWizardData data;
84
        private WizardListenerSupport listenerSupport;
85
        public        static Preferences fPrefs = Preferences.userRoot().node( "gvsig.wcs-wizard" );
86
        private WFSInfoPanel infoPanel;
87
        private int indInfo;
88
        private int indFeature;
89
        private int indFields;
90
        private int indOptions;
91

    
92
        /**
93
         * This method initializes jTabbedPane        
94
         *         
95
         * @return javax.swing.JTabbedPane        
96
         */    
97
        
98
        public WFSParamsPanel(){
99
                super();
100
                initialize();
101
        }
102
        /**
103
         * Returns the tab amount that the WFSParamsPanel currently have
104
         * 
105
         * Devuelve el n?mero de solapas que tiene actualmente el WFSParamsPanel
106
         * 
107
         * @return int
108
         */
109
        public int getNumTabs(){
110
                 return getJTabbedPane().getTabCount();
111
        }
112
        
113
        private void initialize() {
114
                this.setLayout(null);
115
                this.setVisible(false);
116
                this.setBounds(10, 5, 481, 427);
117
                this.add(getJTabbedPane(), null);
118
        }
119
        
120
        /**
121
         * Sets the focus to the tab next to the current one.
122
         * 
123
         * Enfoca a la solapa siguiente a la actualmente enfocada del TabbedPane
124
         *
125
         */
126
        public void avanzaTab(){
127
            int currentPage = currentPage();
128
            int nPages = getNumTabs();
129
                if (nPages -1 > currentPage){
130
                        getJTabbedPane().setSelectedIndex(nextPageEnabled());
131
                }
132
        }
133
        
134
        /**
135
         * Sets the focus to the tab previous to the current one. 
136
         * 
137
         * Enfoca a la solapa anterior a la actualmente enfocada del TabbedPane
138
         * 
139
         */
140
        public void retrocedeTab(){
141
                this.getJTabbedPane().setSelectedIndex(previousEnabledPage());
142

    
143
        }
144
        
145
        /**
146
         * Returns the current tab index.
147
         * 
148
         * Devuelve el n?mero de solapa en que se encuentra
149
         * 
150
         * @return
151
         */
152
        public int getIndiceSolapaActual(){
153
                return this.getJTabbedPane().getSelectedIndex();
154
        }
155
        
156
        private JTabbedPane getJTabbedPane() {
157
                if (jTabbedPane == null) {
158
                        jTabbedPane = new JTabbedPane();
159
                        jTabbedPane.setSize(476, 422);
160
                        jTabbedPane.addTab(PluginServices.getText(this, "info"), null, getInfoPanel());
161
                        jTabbedPane.addTab(PluginServices.getText(this, "feature"), null, getPanelFeatures(), null);
162
                        jTabbedPane.addTab(PluginServices.getText(this, "fields"),null, getPanelFields(), null);
163
                        indFields = jTabbedPane.getTabCount()-1;
164
                        jTabbedPane.setEnabledAt(indFields, false);
165
                        jTabbedPane.addTab(PluginServices.getText(this, "options"),null, getOptionsPanel(), null);
166
                }
167
                return jTabbedPane;
168
        }
169
        
170
        private WFSInfoPanel getInfoPanel() {
171
                if (infoPanel==null) {
172
                        infoPanel = new WFSInfoPanel();
173
                        infoPanel.addFocusListener(new FocusListener() {
174
                                public void focusGained(java.awt.event.FocusEvent e) {
175
//                                        refreshInfo();
176
                                }
177

    
178
                                public void focusLost(FocusEvent e) {
179
                                        
180
                                }
181
                        });
182
                }
183
                return infoPanel;
184
        }
185
        
186
        /**
187
         * 
188
         * @return the selected list
189
         */
190
        private Object getSelectedFeature() {
191
                return featurePanel.getSelectedFeature();
192
        }        
193
        
194
        
195
        /**
196
         * This method initializes panelFeatures        
197
         *         
198
         * @return javax.swing.JPanel        
199
         */    
200
        private JPanel getPanelFeatures() {
201
                if (featurePanel == null) {
202
                        featurePanel = new WFSSelectFeaturePanel(this);
203
                        featurePanel.setLayout(null);
204
                }
205
                return featurePanel;
206
        }
207
        
208
        /**
209
         * This method initializes fieldsPanel        
210
         *         
211
         * @return javax.swing.JPanel        
212
         */    
213
        private JPanel getPanelFields(){
214
                if (fieldsPanel == null) {
215
                        fieldsPanel = new WFSSelectFieldsPanel();
216
                        fieldsPanel.setLayout(null);
217
                }
218
                return fieldsPanel;
219
        }
220
        
221
        
222
        
223
        /**
224
         * This method initializes fieldsPanel        
225
         *         
226
         * @return javax.swing.JPanel        
227
         */    
228
        private JPanel getOptionsPanel(){
229
                if (optionsPanel == null) {
230
                        optionsPanel = new WFSOptionsPanel();
231
                        optionsPanel.setLayout(null);
232
                }
233
                return optionsPanel;
234
        }
235
        
236
        /**
237
         * Verifies that the selected parameters are enough to request the coverage
238
         * to the server.
239
         * 
240
         * Comprueba que los par?metros seleccionados son suficientes para pedir la
241
         * cobertura al servidor.
242
         * 
243
         * @return boolean
244
         */
245
        public boolean isCorretlyConfigured() {
246
                                
247
                
248
                /* 
249
                 * Seg?n el est?ndar WCS, si se especifica bounding box el par?metro TIME
250
                 * no es necesario. ?ste es el caso de gvSIG, que siempre especifica BBOX
251
                 * As? que, en teor?a, no deber?amos comprobar si se ha seleccionado algo
252
                 * o no. Pero en las pruebas, el servidor que us?bamos respond?a con una
253
                 * cobertura en blanco (negro) as? que se ha optado por evitar que se pueda
254
                 * consultar sin ninguna posici?n para el tiempo (siempre que la cobertura
255
                 * especifique posiciones para el tiempo).
256
                 * 
257
                 * En cualquier caso con comentarizar la l?nea basta.
258
                 */
259

    
260
                
261
                return true;
262
        }                
263

    
264

    
265
        /**
266
         * Cleans up the wizard's components but the server's layers list.
267
         * 
268
         * Limpia todos los componentes del wizard excepto la lista de capas del
269
         * servidor.
270
         */
271
        public void cleanupWizard() {
272
                
273
        }
274
        
275
        /**
276
         * Refreshes the wizard components data each time a feature
277
         * is selected.
278
         * 
279
         * Actualiza los datos de los componentes del wizard cada vez 
280
         * que se selecciona una feature diferente.
281
         * 
282
         * @param feature
283
         * Selected feature
284
         */
285
        public void refreshData(WFSLayerNode feature){
286
                infoPanel.refresh(data,feature);
287
                feature = (WFSLayerNode)data.getFeatureInfo(feature.getName());
288
                fieldsPanel.setFields(feature);
289
                jTabbedPane.setEnabledAt(indFields,true);                
290
        }
291

    
292
        /**
293
         * Sets the object that holds the wizard data.
294
         * 
295
         * Establece el objeto que contiene los datos del wizard.
296
         * 
297
         * @param data
298
         */
299
        public void setWizardData(WFSWizardData data) {
300
                this.data = data;
301
                featurePanel.setWizardData(data);
302
                infoPanel.refresh(data,null);
303
        }
304
        
305
        /**
306
         * Sets the wizard's data source
307
         * 
308
         * Establece el origen de los datos del wizard
309
         * @param dataSource
310
         */
311
        public void setDataSource(WFSWizardData dataSource) {
312
                this.data = dataSource;
313
                
314
        }
315
        
316
        
317
    /**
318
     * Returns the next enabled tab's index.
319
     * 
320
     * Devuelve el ?ndicie de la siguiente pesta?a habilitada del wizard o -1 si no hay
321
     * ninguna.
322
     * 
323
     * @return The index or -1 if there is no one.
324
     */
325
    public int nextPageEnabled() {
326
        int currentPage = currentPage();
327
        int nPages = getNumTabs();
328
        if (currentPage == nPages)
329
                return -1;
330
        for (int i=currentPage+1; i<nPages; i++){
331
            if (getJTabbedPane().isEnabledAt(i)){
332
                return i;
333
            }
334
        }
335
        return -1;
336
    }
337
    
338
    /**
339
     * Returns the index of the current tab.
340
     * 
341
     * Devuelve el ?ndice de la p?gina actual del wizard.
342
     * 
343
     * @return
344
     */
345
    public int currentPage() {
346
        return getJTabbedPane().getSelectedIndex();
347
    }
348
    
349
    /**
350
     * Returns the index of the previous enabled tab.
351
     * 
352
     * Devuelve el ?ndice de la anterior p?gina habilitada del wizard o -1 si no hay
353
     * ninguna.
354
     * 
355
     * @return The index, or -1 if there is no one.
356
     */
357
    public int previousEnabledPage() {
358
        int currentPage = currentPage();
359
        int j=0;
360
        if (currentPage == 0)
361
            j= -1;
362
        for (int i = currentPage-1; i>-1; i--){
363
            if (getJTabbedPane().isEnabledAt(i)){
364
                j= i;
365
                    break;
366
            }
367
        }
368
        return j;
369
    }
370

    
371
        public FMapWFSDriver getDriver() {
372
                return data.getDriver();
373
        }
374
        
375
        public void initWizard() { }
376
        public void execute() { }
377
        public FLayer getLayer() { return null;        }
378
        public void setListenerSupport(WizardListenerSupport support) {
379
                listenerSupport = support;
380
        }
381

    
382
}