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