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