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