root / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / WFSParamsPanel.java @ 30497
History | View | Annotate | Download (24.1 KB)
1 |
package com.iver.cit.gvsig.gui.panels; |
---|---|
2 |
|
3 |
import java.awt.Container; |
4 |
import java.awt.geom.Rectangle2D; |
5 |
import java.util.HashMap; |
6 |
|
7 |
import javax.swing.JOptionPane; |
8 |
import javax.swing.JTabbedPane; |
9 |
|
10 |
import org.gvsig.gui.beans.panelGroup.PanelGroupManager; |
11 |
import org.gvsig.gui.beans.panelGroup.exceptions.EmptyPanelGroupException; |
12 |
import org.gvsig.gui.beans.panelGroup.exceptions.EmptyPanelGroupGUIException; |
13 |
import org.gvsig.gui.beans.panelGroup.exceptions.ListCouldntAddPanelException; |
14 |
import org.gvsig.gui.beans.panelGroup.loaders.IPanelGroupLoader; |
15 |
import org.gvsig.gui.beans.panelGroup.panels.AbstractPanel; |
16 |
import org.gvsig.gui.beans.panelGroup.panels.IPanel; |
17 |
import org.gvsig.gui.beans.panelGroup.tabbedPanel.TabbedPanel; |
18 |
import org.gvsig.remoteClient.wfs.WFSStatus; |
19 |
|
20 |
import com.iver.andami.PluginServices; |
21 |
import com.iver.cit.gvsig.fmap.drivers.wfs.FMapWFSDriver; |
22 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
23 |
import com.iver.cit.gvsig.fmap.layers.FLyrWFS; |
24 |
import com.iver.cit.gvsig.fmap.layers.WFSLayerNode; |
25 |
import com.iver.cit.gvsig.gui.ILayerPanel; |
26 |
import com.iver.cit.gvsig.gui.WizardPanel; |
27 |
import com.iver.cit.gvsig.gui.wizards.WFSWizard; |
28 |
import com.iver.cit.gvsig.gui.wizards.WFSWizardData; |
29 |
|
30 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
31 |
*
|
32 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
33 |
*
|
34 |
* This program is free software; you can redistribute it and/or
|
35 |
* modify it under the terms of the GNU General Public License
|
36 |
* as published by the Free Software Foundation; either version 2
|
37 |
* of the License, or (at your option) any later version.
|
38 |
*
|
39 |
* This program is distributed in the hope that it will be useful,
|
40 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
41 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
42 |
* GNU General Public License for more details.
|
43 |
*
|
44 |
* You should have received a copy of the GNU General Public License
|
45 |
* along with this program; if not, write to the Free Software
|
46 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
47 |
*
|
48 |
* For more information, contact:
|
49 |
*
|
50 |
* Generalitat Valenciana
|
51 |
* Conselleria d'Infraestructures i Transport
|
52 |
* Av. Blasco Ib??ez, 50
|
53 |
* 46010 VALENCIA
|
54 |
* SPAIN
|
55 |
*
|
56 |
* +34 963862235
|
57 |
* gvsig@gva.es
|
58 |
* www.gvsig.gva.es
|
59 |
*
|
60 |
* or
|
61 |
*
|
62 |
* IVER T.I. S.A
|
63 |
* Salamanca 50
|
64 |
* 46005 Valencia
|
65 |
* Spain
|
66 |
*
|
67 |
* +34 963163400
|
68 |
* dac@iver.es
|
69 |
*/
|
70 |
/* CVS MESSAGES:
|
71 |
*
|
72 |
* $Id: WFSParamsPanel.java 17736 2008-01-02 16:53:48Z ppiqueras $
|
73 |
* $Log$
|
74 |
* Revision 1.42 2007-09-19 16:14:50 jaume
|
75 |
* removed unnecessary imports
|
76 |
*
|
77 |
* Revision 1.41 2007/06/26 09:33:54 jorpiell
|
78 |
* Information tab refreshed
|
79 |
*
|
80 |
* Revision 1.40 2007/04/11 12:08:55 ppiqueras
|
81 |
* Varios cambios:
|
82 |
* - Corregida etiqueta "Campo"
|
83 |
* - Cambiada actualizaci?n
|
84 |
* - Corregido bug: actualizar ?rea visible despu?s de pulsar "Aplicar" en la interfaz gr?fica.
|
85 |
*
|
86 |
* Revision 1.39 2007/03/15 13:33:44 ppiqueras
|
87 |
* Corregido bug de excepci?n que se lanzaba cuando se filtraba y no se pod?a cargar la capa.
|
88 |
*
|
89 |
* Revision 1.38 2007/03/05 13:49:42 ppiqueras
|
90 |
* 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.
|
91 |
*
|
92 |
* Revision 1.37 2007/03/01 13:12:09 ppiqueras
|
93 |
* Mejorado el filtrado por ?rea.
|
94 |
*
|
95 |
* Revision 1.36 2007/02/22 12:30:59 ppiqueras
|
96 |
* - Eliminado m?todo que sobraba.
|
97 |
* - Mejorada la relaci?n con el panel del ?rea.
|
98 |
* - A?adido JOptionPanel de aviso que no se aplicar? ?rea porque es incorrecta.
|
99 |
*
|
100 |
* Revision 1.35 2007/02/20 11:31:11 ppiqueras
|
101 |
* Eliminados comentarios que sobraban.
|
102 |
*
|
103 |
* Revision 1.34 2007/02/19 11:44:42 jorpiell
|
104 |
* A?adidos los filtros por ?rea
|
105 |
*
|
106 |
* Revision 1.33 2007/02/16 13:36:53 ppiqueras
|
107 |
* Que el ?rea seleccionada en el panel WFSArea sea accesible una vez se va a aplicar.
|
108 |
*
|
109 |
* Revision 1.32 2007/02/12 11:37:00 ppiqueras
|
110 |
* A?adidos comentarios y m?todo para refrescar el MapControl de la pesta?a del ?rea.
|
111 |
*
|
112 |
* Revision 1.31 2007/02/09 14:12:39 jorpiell
|
113 |
* Soporte para WFS 1.1 y WFS-T
|
114 |
*
|
115 |
* Revision 1.30 2007/02/02 12:22:22 ppiqueras
|
116 |
* Corregido alg?n bug.
|
117 |
*
|
118 |
* Revision 1.29 2007/01/08 09:37:39 ppiqueras
|
119 |
* Eliminado comentario que sobraba
|
120 |
*
|
121 |
* Revision 1.28 2006/12/29 09:27:02 ppiqueras
|
122 |
* Corregidos varios bugs:
|
123 |
*
|
124 |
* - Se ejecuta 2 veces "Aplicar" o "Aceptar" en los filtros WFS.
|
125 |
* - Cuando se carga por primera vez una capa WFS, si se pone un
|
126 |
* filtro incorrecto, se ignora el filtro (cargando toda la informaci?n posible de la capa, y borrando el texto de filtrado).
|
127 |
*
|
128 |
* Revision 1.27 2006/12/26 09:19:40 ppiqueras
|
129 |
* 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).
|
130 |
*
|
131 |
* Revision 1.26 2006/12/20 14:22:06 ppiqueras
|
132 |
* A?adido comentario
|
133 |
*
|
134 |
* Revision 1.25 2006/12/15 13:59:36 ppiqueras
|
135 |
* -Permite que se almacenen y/o recojan todos los campos y valores conocidos de la capa actual.
|
136 |
*
|
137 |
* -Adem?s, control frentre a consultas de filtro err?neas, (esto a medias a?n).
|
138 |
*
|
139 |
* - Alg?n comentario m?s.
|
140 |
*
|
141 |
* Revision 1.24 2006/12/12 10:24:45 ppiqueras
|
142 |
* 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'.
|
143 |
*
|
144 |
* Revision 1.23 2006/12/11 11:02:24 ppiqueras
|
145 |
* Corregido bug -> que se mantenga la frase de filtrado
|
146 |
*
|
147 |
* Revision 1.22 2006/12/04 08:59:47 ppiqueras
|
148 |
* Algunos bugs corregidos. A cambio hay 2 bugs relacionados que todav?a no han sido corregidos (ver PHPCollab) (los tiene asignados Jorge).
|
149 |
*
|
150 |
* Revision 1.21 2006/11/28 08:05:13 jorpiell
|
151 |
* Se escribe la query en la pesta?a del filtro
|
152 |
*
|
153 |
* Revision 1.20 2006/11/14 13:45:49 ppiqueras
|
154 |
* A?adida peque?a funcionalidad:
|
155 |
* 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.
|
156 |
*
|
157 |
* Revision 1.19 2006/10/27 12:10:02 ppiqueras
|
158 |
* Nueva funcionalidad
|
159 |
*
|
160 |
* Revision 1.16 2006/10/23 07:37:04 jorpiell
|
161 |
* Ya funciona el filterEncoding
|
162 |
*
|
163 |
* Revision 1.14 2006/10/13 13:05:32 ppiqueras
|
164 |
* Permite el refrescado de datos del panel de filtrado sobre capa WFS.
|
165 |
*
|
166 |
* Revision 1.13 2006/10/10 12:55:06 jorpiell
|
167 |
* Se ha a?adido el soporte de features complejas
|
168 |
*
|
169 |
* Revision 1.12 2006/10/02 09:17:48 jorpiell
|
170 |
* A?adido el setCRS a la capa
|
171 |
*
|
172 |
* Revision 1.11 2006/09/29 13:02:38 ppiqueras
|
173 |
* Filtro para WFS. De momento s?lo interfaz gr?fica.
|
174 |
*
|
175 |
* Revision 1.10 2006/07/21 11:50:31 jaume
|
176 |
* improved appearance
|
177 |
*
|
178 |
* Revision 1.9 2006/06/21 12:35:45 jorpiell
|
179 |
* 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
|
180 |
*
|
181 |
* Revision 1.8 2006/06/15 07:50:58 jorpiell
|
182 |
* A?adida la funcionalidad de reproyectar y hechos algunos cambios en la interfaz
|
183 |
*
|
184 |
* Revision 1.7 2006/05/25 16:22:47 jorpiell
|
185 |
* Se limpia el panel cada vez que se conecta con un servidor distinto
|
186 |
*
|
187 |
* Revision 1.6 2006/05/25 16:01:43 jorpiell
|
188 |
* Se ha a?adido la funcionalidad para eliminar el namespace de los tipos de atributos
|
189 |
*
|
190 |
* Revision 1.5 2006/05/25 10:31:06 jorpiell
|
191 |
* Como ha cambiado la forma de mostrar las capas (una tabla, en lugar de una lista), los paneles han tenido que ser modificados
|
192 |
*
|
193 |
* Revision 1.4 2006/05/23 08:09:39 jorpiell
|
194 |
* 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
|
195 |
*
|
196 |
* Revision 1.3 2006/05/19 12:57:08 jorpiell
|
197 |
* Modificados algunos paneles
|
198 |
*
|
199 |
* Revision 1.2 2006/04/20 16:38:24 jorpiell
|
200 |
* 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().
|
201 |
*
|
202 |
* Revision 1.1 2006/04/19 12:50:16 jorpiell
|
203 |
* Primer commit de la aplicaci?n. Se puede hacer un getCapabilities y ver el mensaje de vienvenida del servidor
|
204 |
*
|
205 |
*/
|
206 |
|
207 |
/**
|
208 |
* <p>Container of the WFS panels, that works as a {@linkplain TabbedPanel TabbedPanel}.</p>
|
209 |
*
|
210 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
|
211 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
212 |
*/
|
213 |
public class WFSParamsPanel extends TabbedPanel implements ILayerPanel { |
214 |
private static final long serialVersionUID = 150328995058481516L; |
215 |
|
216 |
private WFSWizardData wizardData;
|
217 |
|
218 |
// Tab positions
|
219 |
private int infoTabPosition = -1; |
220 |
private int featureTabPosition = -1; |
221 |
private int fieldsTabPosition = -1; |
222 |
private int optionsTabPosition = -1; |
223 |
private int filterTabPosition = -1; |
224 |
private int areaTabPosition = -1; |
225 |
|
226 |
// Tabs
|
227 |
private WFSInfoPanel infoPanel = null; |
228 |
private WFSSelectFeaturePanel featurePanel = null; |
229 |
private WFSSelectFieldsPanel fieldsPanel = null; |
230 |
private WFSOptionsPanel optionsPanel = null; |
231 |
private WFSFilterPanel filterPanel = null; |
232 |
private WFSAreaPanel areaPanel = null; |
233 |
|
234 |
static {
|
235 |
// Registers this class as a "PanelGroup" type
|
236 |
PanelGroupManager.getManager().registerPanelGroup(WFSParamsPanel.class); |
237 |
|
238 |
// Sets this class as the default "PanelGroup" type
|
239 |
PanelGroupManager.getManager().setDefaultType(WFSParamsPanel.class); |
240 |
} |
241 |
|
242 |
/**
|
243 |
* This method initializes jTabbedPane
|
244 |
*
|
245 |
* @return javax.swing.JTabbedPane
|
246 |
*/
|
247 |
public WFSParamsPanel(Object reference) { |
248 |
super(reference);
|
249 |
initialize(); |
250 |
} |
251 |
|
252 |
/*
|
253 |
* (non-Javadoc)
|
254 |
* @see org.gvsig.gui.beans.panelGroup.tabbedPanel.TabbedPanel#initialize()
|
255 |
*/
|
256 |
protected void initialize() { |
257 |
super.initialize();
|
258 |
|
259 |
this.setVisible(false); |
260 |
} |
261 |
|
262 |
/**
|
263 |
* Sets the focus to the next tab of the current one.
|
264 |
*/
|
265 |
public void goToNextTab() { |
266 |
int tabIndex = getSelectedIndex();
|
267 |
|
268 |
if ((tabIndex - 1) < getPanelInGUICount()) { |
269 |
int nextIndex = nextPageEnabled();
|
270 |
|
271 |
if (nextIndex > -1) |
272 |
setSelectedIndex(nextIndex); |
273 |
} |
274 |
} |
275 |
|
276 |
/**
|
277 |
* Sets the focus to the tab previous to the current one.
|
278 |
*/
|
279 |
public void goToPreviousTab(){ |
280 |
setSelectedIndex(previousEnabledPage()); |
281 |
} |
282 |
|
283 |
/**
|
284 |
* @see JTabbedPane#getSelectedIndex()
|
285 |
*/
|
286 |
public int getSelectedIndex(){ |
287 |
return this.getJTabbedPane().getSelectedIndex(); |
288 |
} |
289 |
|
290 |
/**
|
291 |
* @see JTabbedPane#setSelectedIndex(int)
|
292 |
*/
|
293 |
public void setSelectedIndex(int index) { |
294 |
this.getJTabbedPane().setSelectedIndex(index);
|
295 |
} |
296 |
|
297 |
/**
|
298 |
* This method initializes infoPanel
|
299 |
*
|
300 |
* @return the information panel
|
301 |
*/
|
302 |
public WFSInfoPanel getInfoPanel() {
|
303 |
if (infoPanel != null) |
304 |
return infoPanel;
|
305 |
|
306 |
if (infoTabPosition == -1) |
307 |
return null; |
308 |
|
309 |
return (infoPanel = (WFSInfoPanel) values().toArray()[infoTabPosition]);
|
310 |
} |
311 |
|
312 |
/**
|
313 |
* This method initializes featurePanel
|
314 |
*
|
315 |
* @return javax.swing.JPanel
|
316 |
*/
|
317 |
public WFSSelectFeaturePanel getFeaturesPanel() {
|
318 |
if (featurePanel != null) |
319 |
return featurePanel;
|
320 |
|
321 |
if (featureTabPosition == -1) |
322 |
return null; |
323 |
|
324 |
return (featurePanel = (WFSSelectFeaturePanel) values().toArray()[featureTabPosition]);
|
325 |
} |
326 |
|
327 |
/**
|
328 |
* This method initializes fieldsPanel
|
329 |
*
|
330 |
* @return javax.swing.JPanel
|
331 |
*/
|
332 |
public WFSSelectFieldsPanel getFieldsPanel() {
|
333 |
if (fieldsPanel != null) |
334 |
return fieldsPanel;
|
335 |
|
336 |
if (fieldsTabPosition == -1) |
337 |
return null; |
338 |
|
339 |
return (fieldsPanel = (WFSSelectFieldsPanel) values().toArray()[fieldsTabPosition]);
|
340 |
} |
341 |
|
342 |
/**
|
343 |
* This method initializes optionsPanel
|
344 |
*
|
345 |
* @return javax.swing.JPanel
|
346 |
*/
|
347 |
public WFSOptionsPanel getOptionsPanel() {
|
348 |
if (optionsPanel != null) |
349 |
return optionsPanel;
|
350 |
|
351 |
if (optionsTabPosition == -1) |
352 |
return null; |
353 |
|
354 |
return (optionsPanel = (WFSOptionsPanel) values().toArray()[optionsTabPosition]);
|
355 |
} |
356 |
|
357 |
/**
|
358 |
* This method initializes filterPanel
|
359 |
*
|
360 |
* @return javax.swing.JPanel
|
361 |
*/
|
362 |
public WFSFilterPanel getFilterPanel(){
|
363 |
if (filterPanel != null) |
364 |
return filterPanel;
|
365 |
|
366 |
if (filterTabPosition == -1) |
367 |
return null; |
368 |
|
369 |
return (filterPanel = (WFSFilterPanel) values().toArray()[filterTabPosition]);
|
370 |
} |
371 |
|
372 |
/**
|
373 |
* This method initializes areaPanel
|
374 |
*
|
375 |
* @return javax.swing.JPanel
|
376 |
*/
|
377 |
public WFSAreaPanel getAreaPanel() {
|
378 |
if (areaPanel != null) |
379 |
return areaPanel;
|
380 |
|
381 |
if (areaTabPosition == -1) |
382 |
return null; |
383 |
|
384 |
return (areaPanel = (WFSAreaPanel) values().toArray()[areaTabPosition]);
|
385 |
} |
386 |
|
387 |
/**
|
388 |
* Verifies that the selected parameters are enough to request the coverage to the server.
|
389 |
*
|
390 |
* @return boolean <code>true</code> if its correctly configured; otherwise returns <code>false</code>
|
391 |
*/
|
392 |
public boolean isCorretlyConfigured() { |
393 |
if (featureTabPosition == -1) { |
394 |
return false; |
395 |
} else {
|
396 |
return true; |
397 |
} |
398 |
} |
399 |
|
400 |
/**
|
401 |
* Enable or disable the default tabs
|
402 |
*/
|
403 |
public void enableDefaultTabs(boolean isEnabled) { |
404 |
if (fieldsTabPosition != -1) |
405 |
setEnabledAt(fieldsTabPosition, isEnabled); |
406 |
|
407 |
if (filterTabPosition != -1) |
408 |
setEnabledAt(filterTabPosition, isEnabled); |
409 |
|
410 |
if (areaTabPosition != -1) |
411 |
setEnabledAt(areaTabPosition, isEnabled); |
412 |
} |
413 |
|
414 |
/*
|
415 |
* (non-Javadoc)
|
416 |
* @see org.gvsig.gui.beans.panelGroup.tabbedPanel.TabbedPanel#loadPanel(org.gvsig.gui.beans.panelGroup.panels.IPanel)
|
417 |
*/
|
418 |
protected void loadPanel(IPanel panel) { |
419 |
super.loadPanel(panel);
|
420 |
|
421 |
if (((AbstractPanel)panel).getClass() == WFSInfoPanel.class) {
|
422 |
infoTabPosition = getPanelInGUICount() - 1;
|
423 |
return;
|
424 |
} |
425 |
|
426 |
if (((AbstractPanel)panel).getClass() == WFSSelectFeaturePanel.class) {
|
427 |
featureTabPosition = getPanelInGUICount() - 1;
|
428 |
return;
|
429 |
} |
430 |
|
431 |
if (((AbstractPanel)panel).getClass() == WFSSelectFieldsPanel.class) {
|
432 |
fieldsTabPosition = getPanelInGUICount() - 1;
|
433 |
return;
|
434 |
} |
435 |
|
436 |
if (((AbstractPanel)panel).getClass() == WFSOptionsPanel.class) {
|
437 |
optionsTabPosition = getPanelInGUICount() - 1;
|
438 |
return;
|
439 |
} |
440 |
|
441 |
if (((AbstractPanel)panel).getClass() == WFSFilterPanel.class) {
|
442 |
filterTabPosition = getPanelInGUICount() - 1;
|
443 |
return;
|
444 |
} |
445 |
|
446 |
if (((AbstractPanel)panel).getClass() == WFSAreaPanel.class) {
|
447 |
areaTabPosition = getPanelInGUICount() - 1;
|
448 |
return;
|
449 |
} |
450 |
} |
451 |
|
452 |
/**
|
453 |
* Refresh all the panels with the WFS capabilities information.
|
454 |
*/
|
455 |
public void refreshCapabilitiesInfo(){ |
456 |
WFSLayerNode selectedNode = getFeaturesPanel().getWFSLayerNode(); |
457 |
if (selectedNode != null) { |
458 |
selectedNode.setSelectedFields(getFieldsPanel().getSelectedFields()); |
459 |
} else {
|
460 |
getFeaturesPanel().refresh(null);
|
461 |
} |
462 |
wizardData.setUserName(getOptionsPanel().getUserName()); |
463 |
wizardData.setBuffer(getOptionsPanel().getBuffer()); |
464 |
wizardData.setTimeOut(getOptionsPanel().getTimeout()); |
465 |
|
466 |
getInfoPanel().refresh(selectedNode); |
467 |
} |
468 |
|
469 |
/**
|
470 |
* Gets the information used to add or load a WFS layer.
|
471 |
*
|
472 |
* @return information used to add or load a WFS layer
|
473 |
*/
|
474 |
public WFSWizardData getWizardData() {
|
475 |
return wizardData;
|
476 |
} |
477 |
|
478 |
/**
|
479 |
* Sets the information used to add or load a WFS layer.
|
480 |
*
|
481 |
* @param wizardData information used to add or load a WFS layer
|
482 |
*/
|
483 |
public void setWizardData(WFSWizardData wizardData) { |
484 |
this.wizardData = wizardData;
|
485 |
} |
486 |
|
487 |
/**
|
488 |
* Returns the next enabled tab's index, or -1 if there isn't any.
|
489 |
*
|
490 |
* @return The index or -1 if there is no one.
|
491 |
*/
|
492 |
public int nextPageEnabled() { |
493 |
int currentPage = getSelectedIndex();
|
494 |
int nPages = getPanelInGUICount();
|
495 |
|
496 |
if (currentPage == nPages)
|
497 |
return -1; |
498 |
|
499 |
for (int i = currentPage + 1; i < nPages; i++){ |
500 |
if (getJTabbedPane().isEnabledAt(i)){
|
501 |
return i;
|
502 |
} |
503 |
} |
504 |
|
505 |
return -1; |
506 |
} |
507 |
|
508 |
/**
|
509 |
* Returns the index of the current tab.
|
510 |
*
|
511 |
* @return index of the current tab
|
512 |
*/
|
513 |
public int currentPage() { |
514 |
return getSelectedIndex();
|
515 |
} |
516 |
|
517 |
/**
|
518 |
* Returns the index of the previous enabled tab.
|
519 |
*
|
520 |
* @return The index, or -1 if there is no one.
|
521 |
*/
|
522 |
public int previousEnabledPage() { |
523 |
int currentPage = getSelectedIndex();
|
524 |
|
525 |
if (currentPage == 0) |
526 |
return -1; |
527 |
|
528 |
for (int i = currentPage - 1; i > -1; i--) { |
529 |
if (isEnabledAt(i)) {
|
530 |
return i;
|
531 |
} |
532 |
} |
533 |
|
534 |
return -1; |
535 |
} |
536 |
|
537 |
/**
|
538 |
* Gets the WFS driver used to retrieve the information.
|
539 |
*
|
540 |
* @return the WFS driver used to retrieve the information
|
541 |
*/
|
542 |
public FMapWFSDriver getDriver() {
|
543 |
return wizardData.getDriver();
|
544 |
} |
545 |
|
546 |
/*
|
547 |
* (non-Javadoc)
|
548 |
* @see com.iver.cit.gvsig.gui.WizardPanel#initWizard()
|
549 |
*/
|
550 |
public void initWizard() { |
551 |
|
552 |
} |
553 |
|
554 |
/*
|
555 |
* (non-Javadoc)
|
556 |
* @see com.iver.cit.gvsig.gui.WizardPanel#execute()
|
557 |
*/
|
558 |
public void execute() { |
559 |
|
560 |
} |
561 |
|
562 |
/*
|
563 |
* (non-Javadoc)
|
564 |
* @see com.iver.cit.gvsig.gui.ILayerPanel#getLayer()
|
565 |
*/
|
566 |
public FLayer getLayer() {
|
567 |
FLyrWFS layer = new FLyrWFS();
|
568 |
|
569 |
layer.setName(getFeaturesPanel().getLayerName()); |
570 |
layer.setLayerName(getFeaturesPanel().getLayerName()); |
571 |
layer.setWfsLayerNode(getLayerNode()); |
572 |
layer.setFields(getFieldsPanel().getSelectedFields()); |
573 |
layer.setUserName(getOptionsPanel().getUserName()); |
574 |
layer.setPassword(getOptionsPanel().getPassword()); |
575 |
layer.setNumfeatures(getOptionsPanel().getBuffer()); |
576 |
layer.setTimeout(getOptionsPanel().getTimeout()); |
577 |
layer.setSrs(getOptionsPanel().getSRS()); |
578 |
layer.setNameSpace(getFieldsPanel().getNamespace()); |
579 |
|
580 |
// Sets the area (bounding box) filter
|
581 |
Rectangle2D bbox = getAreaPanel().getExtent();
|
582 |
|
583 |
if (getAreaPanel().hasUserDefinedAnArea()) {
|
584 |
// If user has written some invalid data in the coordinates text fields of the area tab
|
585 |
if ((bbox == null) && (getAreaPanel().areThereSomeCoordinatesWritten())) { |
586 |
// Notify to user that no filter area will be applied
|
587 |
JOptionPane.showMessageDialog(null, PluginServices.getText(null, "no_filter_area_will_be_applied_in_the_load_of_the_layer"), PluginServices.getText(null, "warning"), JOptionPane.WARNING_MESSAGE); |
588 |
} |
589 |
} |
590 |
|
591 |
layer.setBbox(bbox); |
592 |
String BboxPropertyName = getFieldsPanel().getGeometryFieldName();
|
593 |
|
594 |
layer.setBboxPropertyName(BboxPropertyName); |
595 |
|
596 |
// Set the filter subconsultation that layer is
|
597 |
layer.setFieldsQuery(getLayerNode().getFilter()); |
598 |
layer.setVisualFilterQuery(getFilterPanel().getFilterExpressionFromInterface()); |
599 |
layer.setWfsDriver(wizardData.getDriver()); |
600 |
return layer;
|
601 |
} |
602 |
|
603 |
/**
|
604 |
* @see WFSWizard#doClickOnNextButton()
|
605 |
*/
|
606 |
public void doClickOnNextButton() { |
607 |
Object obj = this.getParent(); |
608 |
|
609 |
if (obj == null) |
610 |
return;
|
611 |
|
612 |
// When we start to connect to a server -> the interface is the dialog WFSWizard
|
613 |
if (obj instanceof WFSWizard) |
614 |
((WFSWizard)this.getParent()).doClickOnNextButton();
|
615 |
else {
|
616 |
// When we are modifying a loaded layer -> the interface is the dialog WFSPropsDialog
|
617 |
this.advanceCurrentTab();
|
618 |
} |
619 |
} |
620 |
|
621 |
/**
|
622 |
* Selects the next tab
|
623 |
*/
|
624 |
public void advanceCurrentTab() { |
625 |
int currentTabIndex = this.getJTabbedPane().getSelectedIndex(); |
626 |
|
627 |
// Ensure we can select next tab
|
628 |
if ((currentTabIndex != -1) && (currentTabIndex < (values().size() -1))) |
629 |
setSelectedIndex(currentTabIndex + 1);
|
630 |
} |
631 |
|
632 |
/**
|
633 |
* Refreshes the data of the inner <code>WFSSelectFeaturePanel</code>.
|
634 |
*/
|
635 |
public void refreshWFSSelectFeaturePanel() { |
636 |
WFSSelectFeaturePanel panel = getFeaturesPanel(); |
637 |
|
638 |
if (panel != null) { |
639 |
panel.refresh(null);
|
640 |
} |
641 |
} |
642 |
|
643 |
/**
|
644 |
* Gets the node of the layer selected as a feature, with the selected fields and the filter defined.
|
645 |
*
|
646 |
* @return gets the node of the layer selected as a feature, with the selected fields and the filter defined
|
647 |
*/
|
648 |
private WFSLayerNode getLayerNode(){
|
649 |
WFSLayerNode layerNode = getFeaturesPanel().getWFSLayerNode(); |
650 |
layerNode.setSelectedFields(getFieldsPanel().getSelectedFields()); |
651 |
|
652 |
// If the query is incorrect -> no query (no filter)
|
653 |
String query = getFilterPanel().getQuery();
|
654 |
if (query == null) { |
655 |
layerNode.setFilter("");
|
656 |
|
657 |
// Removes filter expression from the JTextArea
|
658 |
getFilterPanel().removeFilterExpression(); |
659 |
|
660 |
// Notify to user that no filter will be applied
|
661 |
JOptionPane.showMessageDialog(null, PluginServices.getText(null, "no_filter_will_be_applied_in_the_load_of_the_layer"), PluginServices.getText(null, "warning"), JOptionPane.WARNING_MESSAGE); |
662 |
} |
663 |
else {
|
664 |
layerNode.setFilter(query); |
665 |
} |
666 |
|
667 |
return layerNode;
|
668 |
} |
669 |
|
670 |
/**
|
671 |
* Refresh all the panels every time that a different layer is selected. The info panel is refreshed every time the user
|
672 |
* makes a click on it.
|
673 |
*
|
674 |
* @param layer the selected layer
|
675 |
*/
|
676 |
public void refresh(WFSLayerNode layer){ |
677 |
boolean hasFields = false; |
678 |
|
679 |
if (layer!=null){ |
680 |
//Update the layer information
|
681 |
layer = (WFSLayerNode)wizardData.getFeatureInfo(layer.getName(), layer.getNameSpace()); |
682 |
|
683 |
// If there is no fields -> disable not necessary tabs
|
684 |
if (layer.getFields().size() == 0) { |
685 |
setApplicable(false);
|
686 |
hasFields = false;
|
687 |
}else{
|
688 |
getFieldsPanel().refresh(layer); |
689 |
getOptionsPanel().refresh(layer); |
690 |
getFilterPanel().refresh(layer); |
691 |
getAreaPanel().refresh(layer); |
692 |
hasFields = true;
|
693 |
} |
694 |
} |
695 |
|
696 |
enableDefaultTabs(hasFields); |
697 |
} |
698 |
|
699 |
/**
|
700 |
* Changes the <i>enable</i> status of the "<i>apply</i>" button
|
701 |
*
|
702 |
* @param isApplicable the <i>enable</i> status of the "<i>apply</i>" button
|
703 |
*/
|
704 |
public void setApplicable(boolean isApplicable){ |
705 |
setEnabledApplyButton(isApplicable); |
706 |
} |
707 |
|
708 |
/*
|
709 |
* (non-Javadoc)
|
710 |
* @see org.gvsig.gui.beans.buttonspanel.IButtonsPanel#setEnabledApplyButton(boolean)
|
711 |
*/
|
712 |
public void setEnabledApplyButton(boolean b) { |
713 |
super.setEnabledApplyButton(b);
|
714 |
|
715 |
Container parent = getParent();
|
716 |
|
717 |
if ((parent != null) && (parent instanceof WizardPanel)) |
718 |
((WizardPanel)parent).callStateChanged(b); |
719 |
} |
720 |
|
721 |
/*
|
722 |
* (non-Javadoc)
|
723 |
* @see org.gvsig.gui.beans.panelGroup.AbstractPanelGroup#loadPanels(org.gvsig.gui.beans.panelGroup.loaders.IPanelGroupLoader)
|
724 |
*/
|
725 |
public void loadPanels(IPanelGroupLoader loader) throws ListCouldntAddPanelException, EmptyPanelGroupException, EmptyPanelGroupGUIException { |
726 |
// This code will be executed when is creating the dialog of properties
|
727 |
if (getReference() != null) { |
728 |
FLyrWFS lyr = (FLyrWFS) getReference(); |
729 |
|
730 |
WFSWizardData dataSource = new WFSWizardData();
|
731 |
dataSource.setDriver(lyr.getWfsDriver()); |
732 |
|
733 |
setWizardData(dataSource); |
734 |
|
735 |
super.loadPanels(loader);
|
736 |
|
737 |
HashMap<String, Object> info = lyr.getProperties(); |
738 |
setSelectedFeature((WFSLayerNode)info.get("wfsLayerNode"));
|
739 |
setStatus((WFSStatus)info.get("status"));
|
740 |
setLayerName(lyr.getName()); |
741 |
setVisible(true);
|
742 |
refreshInfo(); |
743 |
|
744 |
return;
|
745 |
} |
746 |
|
747 |
// This will executed when is adding a new WFS layer:
|
748 |
super.loadPanels(loader);
|
749 |
} |
750 |
|
751 |
///// BEGIN: METHODS FOR INITIALIZE THIS PANEL AS A COMPONENT OF A PROPERTIES DIALOG /////
|
752 |
|
753 |
/**
|
754 |
* Sets the selected feature.
|
755 |
*
|
756 |
* @param layerNode node of the selected feature
|
757 |
*/
|
758 |
public void setSelectedFeature(WFSLayerNode layerNode){ |
759 |
getFeaturesPanel().setSelectedFeature(layerNode); |
760 |
getFieldsPanel().setSelectedFields(layerNode); |
761 |
getFilterPanel().refresh(layerNode); |
762 |
} |
763 |
|
764 |
/**
|
765 |
* Sets the status of the options and filter panels.
|
766 |
*
|
767 |
* @param status the status of the options and filter panels
|
768 |
*/
|
769 |
public void setStatus(WFSStatus status) { |
770 |
getOptionsPanel().setStatus(status); |
771 |
getFilterPanel().setFilterExpressionIntoInterface(status.getFilterVisualText()); |
772 |
} |
773 |
|
774 |
/**
|
775 |
* @see WFSSelectFeaturePanel#setLayerName(String)
|
776 |
*/
|
777 |
public void setLayerName(String name) { |
778 |
getFeaturesPanel().setLayerName(name); |
779 |
} |
780 |
|
781 |
/**
|
782 |
* Updates the information stored at the wizard's data and <i>info</i> panel.
|
783 |
*/
|
784 |
public void refreshInfo(){ |
785 |
WFSLayerNode selectedNode = getFeaturesPanel().getSelectedFeature(); |
786 |
|
787 |
if (selectedNode != null) { |
788 |
selectedNode.setSelectedFields(getFieldsPanel().getSelectedFields()); |
789 |
} |
790 |
|
791 |
wizardData.setUserName(getOptionsPanel().getUserName()); |
792 |
wizardData.setBuffer(getOptionsPanel().getBuffer()); |
793 |
wizardData.setTimeOut(getOptionsPanel().getTimeout()); |
794 |
getInfoPanel().refresh(selectedNode); |
795 |
} |
796 |
///// END: METHODS FOR INITIALIZE THIS PANEL AS A COMPONENT OF A PROPERTIES DIALOG /////
|
797 |
} |