root / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / dialogs / WFSPropsDialog.java @ 11129
History | View | Annotate | Download (20.5 KB)
1 |
package com.iver.cit.gvsig.gui.dialogs; |
---|---|
2 |
|
3 |
import java.awt.Component; |
4 |
import java.awt.event.ActionEvent; |
5 |
import java.awt.event.ActionListener; |
6 |
import java.net.MalformedURLException; |
7 |
import java.net.URL; |
8 |
import java.util.HashMap; |
9 |
|
10 |
import javax.swing.JButton; |
11 |
import javax.swing.JOptionPane; |
12 |
import javax.swing.JPanel; |
13 |
|
14 |
import org.gvsig.remoteClient.wfs.WFSStatus; |
15 |
|
16 |
import com.hardcode.gdbms.engine.instruction.FieldNotFoundException; |
17 |
import com.iver.andami.PluginServices; |
18 |
import com.iver.andami.ui.mdiManager.IWindow; |
19 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
20 |
import com.iver.cit.gvsig.exceptions.layers.ConnectionErrorLayerException; |
21 |
import com.iver.cit.gvsig.exceptions.layers.DriverLayerException; |
22 |
import com.iver.cit.gvsig.exceptions.layers.LegendLayerException; |
23 |
import com.iver.cit.gvsig.exceptions.layers.LoadLayerException; |
24 |
import com.iver.cit.gvsig.exceptions.layers.NameLayerException; |
25 |
import com.iver.cit.gvsig.exceptions.layers.ProjectionLayerException; |
26 |
import com.iver.cit.gvsig.exceptions.layers.TypeLayerException; |
27 |
import com.iver.cit.gvsig.exceptions.layers.URLLayerException; |
28 |
import com.iver.cit.gvsig.exceptions.layers.UnsupportedVersionLayerException; |
29 |
import com.iver.cit.gvsig.exceptions.layers.XMLLayerException; |
30 |
import com.iver.cit.gvsig.fmap.MapControl; |
31 |
import com.iver.cit.gvsig.fmap.drivers.WFSLayerException; |
32 |
import com.iver.cit.gvsig.fmap.drivers.wfs.FMapWFSDriver; |
33 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
34 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
35 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
36 |
import com.iver.cit.gvsig.fmap.layers.FLyrWFS; |
37 |
import com.iver.cit.gvsig.fmap.layers.FLyrWFSFactory; |
38 |
import com.iver.cit.gvsig.fmap.layers.WFSLayerNode; |
39 |
import com.iver.cit.gvsig.fmap.rendering.VectorialLegend; |
40 |
import com.iver.cit.gvsig.gui.panels.WFSAreaPanel; |
41 |
import com.iver.cit.gvsig.gui.panels.WFSParamsPanel; |
42 |
import com.iver.cit.gvsig.gui.wizards.WFSWizardData; |
43 |
import com.iver.cit.gvsig.gui.wizards.WizardListener; |
44 |
import com.iver.cit.gvsig.gui.wizards.WizardListenerSupport; |
45 |
import com.iver.cit.gvsig.project.documents.layout.gui.Layout; |
46 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
47 |
|
48 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
49 |
*
|
50 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
51 |
*
|
52 |
* This program is free software; you can redistribute it and/or
|
53 |
* modify it under the terms of the GNU General Public License
|
54 |
* as published by the Free Software Foundation; either version 2
|
55 |
* of the License, or (at your option) any later version.
|
56 |
*
|
57 |
* This program is distributed in the hope that it will be useful,
|
58 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
59 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
60 |
* GNU General Public License for more details.
|
61 |
*
|
62 |
* You should have received a copy of the GNU General Public License
|
63 |
* along with this program; if not, write to the Free Software
|
64 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
65 |
*
|
66 |
* For more information, contact:
|
67 |
*
|
68 |
* Generalitat Valenciana
|
69 |
* Conselleria d'Infraestructures i Transport
|
70 |
* Av. Blasco Ib??ez, 50
|
71 |
* 46010 VALENCIA
|
72 |
* SPAIN
|
73 |
*
|
74 |
* +34 963862235
|
75 |
* gvsig@gva.es
|
76 |
* www.gvsig.gva.es
|
77 |
*
|
78 |
* or
|
79 |
*
|
80 |
* IVER T.I. S.A
|
81 |
* Salamanca 50
|
82 |
* 46005 Valencia
|
83 |
* Spain
|
84 |
*
|
85 |
* +34 963163400
|
86 |
* dac@iver.es
|
87 |
*/
|
88 |
/* CVS MESSAGES:
|
89 |
*
|
90 |
* $Id: WFSPropsDialog.java 11129 2007-04-11 11:55:47Z ppiqueras $
|
91 |
* $Log$
|
92 |
* Revision 1.36 2007-04-11 11:55:47 ppiqueras
|
93 |
* Corregido bug: actualizaci?n de ?rea visual despues de pulsar "Aplicar"
|
94 |
*
|
95 |
* Revision 1.35 2007/03/15 13:32:22 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.34 2007/03/06 16:55:54 caballero
|
99 |
* Exceptions
|
100 |
*
|
101 |
* Revision 1.33 2007/03/01 13:11:27 ppiqueras
|
102 |
* Cambios menores.
|
103 |
*
|
104 |
* Revision 1.32 2007/02/22 12:24:19 ppiqueras
|
105 |
* Eliminadas l?neas que sobraban.
|
106 |
*
|
107 |
* Revision 1.31 2007/02/20 11:31:11 ppiqueras
|
108 |
* Eliminados comentarios que sobraban.
|
109 |
*
|
110 |
* Revision 1.30 2007/02/16 13:36:53 ppiqueras
|
111 |
* Que el ?rea seleccionada en el panel WFSArea sea accesible una vez se va a aplicar.
|
112 |
*
|
113 |
* Revision 1.29 2007/02/12 11:36:43 ppiqueras
|
114 |
* A?adidos comentarios y m?todo para refrescar el MapControl de la pesta?a del ?rea.
|
115 |
*
|
116 |
* Revision 1.28 2007/02/02 12:35:29 ppiqueras
|
117 |
* Mejora de la eficiencia y robustez del c?digo para alg?n m?todo.
|
118 |
*
|
119 |
* Revision 1.27 2007/01/18 12:38:35 jorpiell
|
120 |
* el fullRefresh ha cambiado del mapcontext al mapcontrol
|
121 |
*
|
122 |
* Revision 1.26 2006/12/29 12:29:50 ppiqueras
|
123 |
* Eliminados comentarios que sobraban.
|
124 |
*
|
125 |
* Revision 1.25 2006/12/29 12:28:29 ppiqueras
|
126 |
* El anterior commit: refactorizaci?n unos m?todos.
|
127 |
* El commit actual: eliminado c?digo comentado que sobraba.
|
128 |
*
|
129 |
* Revision 1.24 2006/12/29 09:24:50 ppiqueras
|
130 |
* Cambios sin importancia.
|
131 |
*
|
132 |
* Revision 1.23 2006/12/26 10:26:03 ppiqueras
|
133 |
* Corregida dependencia con Layer de appgvsig
|
134 |
*
|
135 |
* Revision 1.22 2006/12/26 09:26:51 ppiqueras
|
136 |
* 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).
|
137 |
*
|
138 |
* Revision 1.20 2006/12/20 14:21:22 ppiqueras
|
139 |
* Corregido bug que no actualice vista si el filtro no es correcto
|
140 |
*
|
141 |
* Revision 1.19 2006/12/19 08:27:29 jorpiell
|
142 |
* Problem decreasing the selected attributes number solved
|
143 |
*
|
144 |
* Revision 1.18 2006/12/18 08:48:38 jorpiell
|
145 |
* The props panel uses the same layer driver insteaf of create a nes driver each time
|
146 |
*
|
147 |
* Revision 1.17 2006/12/15 13:57:08 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 |
* Revision 1.16 2006/12/13 14:00:24 ppiqueras
|
153 |
* A?adido un comentario a una l?nea de instrucciones
|
154 |
*
|
155 |
* Revision 1.15 2006/12/04 08:59:47 ppiqueras
|
156 |
* Algunos bugs corregidos. A cambio hay 2 bugs relacionados que todav?a no han sido corregidos (ver PHPCollab) (los tiene asignados Jorge).
|
157 |
*
|
158 |
* Revision 1.14 2006/11/28 08:05:31 jorpiell
|
159 |
* Se refrescan los mapas despu?s de aplicar un filtro
|
160 |
*
|
161 |
* Revision 1.13 2006/11/16 16:57:49 jorpiell
|
162 |
* Se copia la laeyenda de la capa anterior antes de eliminarla
|
163 |
*
|
164 |
* Revision 1.12 2006/11/14 13:45:49 ppiqueras
|
165 |
* A?adida peque?a funcionalidad:
|
166 |
* 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.
|
167 |
*
|
168 |
* Revision 1.11 2006/10/31 09:40:49 jorpiell
|
169 |
* Se ha creado una factoria para crear la capa. De ese modo no se repite c?digo desde le panel de propiedades y desde el panel de la capa
|
170 |
*
|
171 |
* Revision 1.9 2006/10/23 08:47:12 jorpiell
|
172 |
* Refactorizado un m?todo
|
173 |
*
|
174 |
* Revision 1.8 2006/10/23 08:29:06 ppiqueras
|
175 |
* Algunos cambios
|
176 |
*
|
177 |
* Revision 1.6 2006/10/02 09:09:45 jorpiell
|
178 |
* Cambios del 10 copiados al head
|
179 |
*
|
180 |
* Revision 1.4.2.3 2006/09/27 11:12:15 jorpiell
|
181 |
* Hay que comprobar que se han devuelto un n?mero de features menor que el n?mero m?ximo permitido
|
182 |
*
|
183 |
* Revision 1.4.2.2 2006/09/27 09:15:01 jorpiell
|
184 |
* Ya no se hace otra petici?n al pulsar sobre el bot?n aceptar.
|
185 |
*
|
186 |
* Revision 1.4.2.1 2006/09/19 12:28:11 jorpiell
|
187 |
* Ya no se depende de geotools
|
188 |
*
|
189 |
*
|
190 |
* Revision 1.4 2006/08/30 07:42:29 jorpiell
|
191 |
* Se le asigna a la capa creada una proyecci?n concreta. Si esto no se hace, al exportar a postigis se produce un error.
|
192 |
*
|
193 |
* Revision 1.3 2006/08/29 07:56:12 cesar
|
194 |
* Rename the *View* family of classes to *Window* (ie: SingletonView to SingletonWindow, ViewInfo to WindowInfo, etc)
|
195 |
*
|
196 |
* Revision 1.2 2006/08/29 07:13:40 cesar
|
197 |
* Rename class com.iver.andami.ui.mdiManager.View to com.iver.andami.ui.mdiManager.IWindow
|
198 |
*
|
199 |
* Revision 1.1 2006/06/21 12:35:45 jorpiell
|
200 |
* 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
|
201 |
*
|
202 |
*
|
203 |
*/
|
204 |
/**
|
205 |
* Panel with tabs for change properties of a WFS layer
|
206 |
*
|
207 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
208 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
209 |
*/
|
210 |
public class WFSPropsDialog extends JPanel implements IWindow { |
211 |
private WFSParamsPanel wfsParamsTabbedPane = null; |
212 |
private WindowInfo m_ViewInfo = null; |
213 |
private FLayer fLayer = null; |
214 |
private JButton btnApply = null; |
215 |
private JButton btnOk = null; |
216 |
private JButton btnCancel = null; |
217 |
private CommandListener m_actionListener = null; |
218 |
private JPanel buttonsPanel = null; |
219 |
boolean applied = false; |
220 |
|
221 |
|
222 |
|
223 |
/**
|
224 |
* Default constructor with a Layer as parameter
|
225 |
*
|
226 |
* @param layer A layer
|
227 |
*/
|
228 |
public WFSPropsDialog(FLayer layer) {
|
229 |
super();
|
230 |
initialize(layer); |
231 |
} |
232 |
|
233 |
/**
|
234 |
* Initializes this component
|
235 |
*
|
236 |
* @param layer A layer
|
237 |
*/
|
238 |
private void initialize(FLayer layer) { |
239 |
setLayout(null);
|
240 |
setFLayer(layer); |
241 |
wfsParamsTabbedPane = getParamsPanel(((FLyrWFS) layer).getProperties()); |
242 |
wfsParamsTabbedPane.addWizardListener(new WizardListener(){
|
243 |
public void wizardStateChanged(boolean finishable) { |
244 |
getBtnOk().setEnabled(finishable); |
245 |
getBtnApply().setEnabled(finishable); |
246 |
} |
247 |
|
248 |
public void error(Exception e) { |
249 |
} |
250 |
}); |
251 |
|
252 |
//wfsParamsTabbedPane.disableDisagregatedLayers();
|
253 |
this.add(wfsParamsTabbedPane);
|
254 |
this.add(getButtonsPanel(), null); |
255 |
} |
256 |
|
257 |
|
258 |
/**
|
259 |
* Buttons OK, Apply, Cancel
|
260 |
*
|
261 |
* @return A panel with that buttons
|
262 |
*/
|
263 |
public JPanel getButtonsPanel() { |
264 |
if (buttonsPanel == null) { |
265 |
m_actionListener = new CommandListener(this); |
266 |
buttonsPanel = new JPanel(); |
267 |
buttonsPanel.setBounds(5, wfsParamsTabbedPane.getHeight(), 471, 40); |
268 |
buttonsPanel.setLayout(null);
|
269 |
buttonsPanel.setName("buttonPanel");
|
270 |
|
271 |
buttonsPanel.add(getBtnOk(), null);
|
272 |
buttonsPanel.add(getBtnApply(), null);
|
273 |
buttonsPanel.add(getBtnCancel(), null);
|
274 |
} |
275 |
return buttonsPanel;
|
276 |
} |
277 |
|
278 |
|
279 |
/**
|
280 |
* With getParamsPanel we have access to the map config TabbedPane.
|
281 |
* If this panel doesn't exist yet (which can occur when an existing project is
|
282 |
* recovered) it is been automatically constructed by connecting to the server,
|
283 |
* reloading the necessary data, filling up the content and setting the selected
|
284 |
* values that were selected when the projet was saved.
|
285 |
*
|
286 |
*
|
287 |
* Since a connection to the server is needed when rebuiliding the panel, this
|
288 |
* causes a delay for the panel's showing up or a nullPointer error if there is
|
289 |
* no path to the server.
|
290 |
*
|
291 |
*
|
292 |
* Con getParamsPanel tenemos acceso a juego de pesta?as de configuraci?n
|
293 |
* del mapa. Si este panel todav?a no existe (como puede ser cuando
|
294 |
* recuperamos un proyecto guardado) ?ste se crea autom?ticamente conectando
|
295 |
* al servidor, recuperando los datos necesarios, rellenando el contenido y
|
296 |
* dejando seleccionados los valores que estaban seleccionados cuando se
|
297 |
* guard? el proyecto.
|
298 |
*
|
299 |
*
|
300 |
* Como para reconstruirse requiere una conexi?n con el servidor esto causa
|
301 |
* un retardo en la aparici?n en el toc o un error de nullPointer si no
|
302 |
* hay conexi?n hasta el servidor.
|
303 |
*
|
304 |
*
|
305 |
* @return WMSParamsPanel
|
306 |
*/
|
307 |
public WFSParamsPanel getParamsPanel(HashMap info) { |
308 |
if (info!=null){ |
309 |
URL host = (URL) info.get("host"); |
310 |
WFSWizardData dataSource = new WFSWizardData();
|
311 |
//dataSource.setHost(host, false);
|
312 |
dataSource.setDriver(((FLyrWFS)fLayer).getWfsDriver()); |
313 |
WFSParamsPanel toc = new WFSParamsPanel();
|
314 |
toc.setWizardData(dataSource); |
315 |
toc.setListenerSupport(new WizardListenerSupport());
|
316 |
toc.setSelectedFeature((WFSLayerNode)info.get("wfsLayerNode"));
|
317 |
toc.setLayerName(fLayer.getName()); |
318 |
toc.refreshInfo((WFSLayerNode)info.get("wfsLayerNode"));
|
319 |
toc.setStatus((WFSStatus)info.get("status"));
|
320 |
toc.setVisible(true);
|
321 |
applied = false;
|
322 |
return toc;
|
323 |
} |
324 |
return null; |
325 |
} |
326 |
|
327 |
|
328 |
|
329 |
/*
|
330 |
* (non-Javadoc)
|
331 |
* @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo()
|
332 |
*/
|
333 |
public WindowInfo getWindowInfo() {
|
334 |
if (m_ViewInfo == null){ |
335 |
m_ViewInfo=new WindowInfo(WindowInfo.MODALDIALOG);
|
336 |
m_ViewInfo.setTitle(PluginServices.getText(this,"fit_WFS_layer")); |
337 |
m_ViewInfo.setWidth(wfsParamsTabbedPane.getWidth()+ 10);
|
338 |
m_ViewInfo.setHeight(wfsParamsTabbedPane.getHeight() + 40);
|
339 |
} |
340 |
return m_ViewInfo;
|
341 |
} |
342 |
|
343 |
/**
|
344 |
* @return Returns the fLayer.
|
345 |
*/
|
346 |
public FLayer getFLayer() {
|
347 |
return fLayer;
|
348 |
} |
349 |
|
350 |
/**
|
351 |
* @param layer The fLayer to set.
|
352 |
*/
|
353 |
public void setFLayer(FLayer layer) { |
354 |
fLayer = layer; |
355 |
} |
356 |
|
357 |
/**
|
358 |
* JButton OK
|
359 |
*
|
360 |
* @return javax.swing.JButton
|
361 |
*/
|
362 |
public JButton getBtnOk() { |
363 |
if (btnOk == null) { |
364 |
btnOk = new JButton("ok"); |
365 |
btnOk.setText(PluginServices.getText(this,"ok")); |
366 |
btnOk.setActionCommand("OK");
|
367 |
btnOk.addActionListener(m_actionListener); |
368 |
btnOk.setBounds(367, 9, 90, 25); |
369 |
} |
370 |
return btnOk;
|
371 |
} |
372 |
|
373 |
|
374 |
/**
|
375 |
* JButton Apply
|
376 |
*
|
377 |
* @return javax.swing.JButton
|
378 |
*/
|
379 |
public JButton getBtnApply() { |
380 |
if (btnApply == null) { |
381 |
btnApply = new JButton("apply"); |
382 |
btnApply.setText(PluginServices.getText(this,"apply")); |
383 |
btnApply.setEnabled(false);
|
384 |
btnApply.setActionCommand("APPLY");
|
385 |
btnApply.addActionListener(m_actionListener); |
386 |
btnApply.setBounds(267, 9, 90, 25); |
387 |
} |
388 |
return btnApply;
|
389 |
} |
390 |
|
391 |
|
392 |
/**
|
393 |
* JButton Cancel
|
394 |
*
|
395 |
* @return javax.swing.JButton
|
396 |
*/
|
397 |
public JButton getBtnCancel() { |
398 |
if (btnCancel == null) { |
399 |
btnCancel = new JButton("cancel"); |
400 |
btnCancel.setText(PluginServices.getText(this,"cancel")); |
401 |
btnCancel.setActionCommand("CANCEL");
|
402 |
btnCancel.addActionListener(m_actionListener); |
403 |
btnCancel.setBounds(137, 9, 90, 25); |
404 |
} |
405 |
return btnCancel;
|
406 |
} |
407 |
|
408 |
|
409 |
/**
|
410 |
* Closes this panel
|
411 |
*/
|
412 |
public void close() { |
413 |
PluginServices.getMDIManager().closeWindow(this);
|
414 |
} |
415 |
|
416 |
/**
|
417 |
* Merge two FLayers in one
|
418 |
* @param group1
|
419 |
* @param group2
|
420 |
* @return
|
421 |
*/
|
422 |
private FLayers mergeFLayers(FLayers group1, FLayers group2)
|
423 |
{ |
424 |
FLayer layer; |
425 |
for(int i = 0; i < group2.getLayersCount(); i++) |
426 |
{ |
427 |
layer = group2.getLayer( i ); |
428 |
if(group1.getLayer( layer.getName()) == null ){ |
429 |
group1.addLayer( layer ); |
430 |
} |
431 |
} |
432 |
|
433 |
return group1;
|
434 |
} |
435 |
|
436 |
|
437 |
/**
|
438 |
* @see ActionListener
|
439 |
*
|
440 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
441 |
*/
|
442 |
private class CommandListener implements ActionListener { |
443 |
/**
|
444 |
* Default constructor
|
445 |
*
|
446 |
* @param tp
|
447 |
*/
|
448 |
public CommandListener(WFSPropsDialog tp) {
|
449 |
} |
450 |
|
451 |
/* (non-Javadoc)
|
452 |
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
453 |
*/
|
454 |
public void actionPerformed(ActionEvent e) { |
455 |
if ((e.getActionCommand() == "CANCEL") || (!getBtnApply().isEnabled())) { |
456 |
close(); |
457 |
return;
|
458 |
} |
459 |
try {
|
460 |
|
461 |
View activeView = (View) PluginServices.getMDIManager().getActiveWindow(); |
462 |
String layerName = null; |
463 |
|
464 |
if (e.getActionCommand() == "APPLY") { |
465 |
// We can't 'apply' if there is a filter query and it's incorrect
|
466 |
if (wfsParamsTabbedPane.getFilterQuery() != null) { |
467 |
|
468 |
if ((layerName = prepareFlyrWFSLayer()) != null) { |
469 |
MapControl mapCtrl = activeView.getMapControl(); |
470 |
mapCtrl.getMapContext().getLayers().replaceLayer(layerName, fLayer); |
471 |
|
472 |
mapCtrl.getMapContext().invalidate(); |
473 |
} |
474 |
|
475 |
applied = true;
|
476 |
getBtnApply().setEnabled(!applied); |
477 |
refreshLayouts(); |
478 |
|
479 |
// Restores the private attribute of the area panel: hasUserDefinedAnArea
|
480 |
wfsParamsTabbedPane.setUserHasntDefinedAnArea(); |
481 |
|
482 |
// If we load another layer, or the same but we've selected others fields -> notify it to the WFSFilter panel
|
483 |
if (getWFSFilterPanelIsAsTabForWFSLayersLoad() || (wfsParamsTabbedPane.getFieldsSelectedOfSameLayerHasChanged())) {
|
484 |
setWFSFilterPanelIsAsTabForWFSLayersLoad(false);
|
485 |
wfsParamsTabbedPane.resetFieldsSelectedOfSameLayerHasChanged(); // reset that field
|
486 |
} |
487 |
|
488 |
// Update values associated to the current selected field
|
489 |
wfsParamsTabbedPane.updateWFSFilterFieldValues(); |
490 |
wfsParamsTabbedPane.updateWFSArea(); |
491 |
} |
492 |
return;
|
493 |
} |
494 |
|
495 |
if (e.getActionCommand() == "OK") { |
496 |
// We can't 'apply' if there is a filter query and it's incorrect
|
497 |
if (wfsParamsTabbedPane.getFilterQuery() != null) { |
498 |
if (!applied) {
|
499 |
if (getBtnApply().isEnabled()){
|
500 |
|
501 |
if ((layerName = prepareFlyrWFSLayer()) != null) |
502 |
{ |
503 |
View vista = (View) PluginServices.getMDIManager().getActiveWindow(); |
504 |
MapControl mapCtrl = vista.getMapControl(); |
505 |
mapCtrl.getMapContext().getLayers().replaceLayer(layerName, fLayer); |
506 |
mapCtrl.getMapContext().invalidate(); |
507 |
refreshLayouts(); |
508 |
|
509 |
// Restores the private attribute of the area panel: hasUserDefinedAnArea
|
510 |
wfsParamsTabbedPane.setUserHasntDefinedAnArea(); |
511 |
} |
512 |
} |
513 |
} |
514 |
close(); |
515 |
|
516 |
// Update all fields and values known about the current layer loaded (and selected)
|
517 |
((FLyrWFS)fLayer).setAllFieldsAndValuesKnown(wfsParamsTabbedPane.getAllFieldsAndValuesKnownOfCurrentLayer()); |
518 |
} |
519 |
|
520 |
} |
521 |
} catch (ConnectionErrorLayerException e1) {
|
522 |
e1.printStackTrace(); |
523 |
} catch (DriverLayerException e1) {
|
524 |
e1.printStackTrace(); |
525 |
} catch (LegendLayerException e1) {
|
526 |
e1.printStackTrace(); |
527 |
} catch (NameLayerException e1) {
|
528 |
e1.printStackTrace(); |
529 |
} catch (ProjectionLayerException e1) {
|
530 |
e1.printStackTrace(); |
531 |
} catch (TypeLayerException e1) {
|
532 |
e1.printStackTrace(); |
533 |
} catch (UnsupportedVersionLayerException e1) {
|
534 |
e1.printStackTrace(); |
535 |
} catch (URLLayerException e1) {
|
536 |
e1.printStackTrace(); |
537 |
} catch (XMLLayerException e1) {
|
538 |
e1.printStackTrace(); |
539 |
} catch (WFSLayerException e1) {
|
540 |
e1.printStackTrace(); |
541 |
} catch (LoadLayerException e1) {
|
542 |
e1.printStackTrace(); |
543 |
} |
544 |
} |
545 |
|
546 |
/**
|
547 |
* Updates data in the current layer of current active view
|
548 |
*
|
549 |
* @param currentView The current active view
|
550 |
* @return Te name of the layer
|
551 |
*/
|
552 |
private String prepareFlyrWFSLayer() { |
553 |
// layerName = fLayer.getName();
|
554 |
// View activeView = (View) PluginServices.getMDIManager().getActiveWindow();
|
555 |
VectorialLegend legend = (VectorialLegend)((FLyrVect)fLayer).getLegend(); |
556 |
FMapWFSDriver driver = wfsParamsTabbedPane.getDriver(); |
557 |
try {
|
558 |
fLayer = wfsParamsTabbedPane.getLayer(); |
559 |
|
560 |
if (fLayer != null) { |
561 |
URL host = new URL(wfsParamsTabbedPane.getData().getHost()); |
562 |
String onlineResource = wfsParamsTabbedPane.getData().getOnlineResource();
|
563 |
fLayer = new FLyrWFSFactory().getFLyrWFS(fLayer,host,onlineResource,driver,true); |
564 |
if (fLayer != null) { |
565 |
((FLyrWFS)fLayer).setLegend(legend); |
566 |
|
567 |
// Update all fields and values known about the current layer loaded (and selected)
|
568 |
((FLyrWFS)fLayer).setAllFieldsAndValuesKnown(wfsParamsTabbedPane.getAllFieldsAndValuesKnownOfCurrentLayer()); |
569 |
|
570 |
return fLayer.getName();
|
571 |
} |
572 |
} |
573 |
} catch (MalformedURLException e1) { |
574 |
e1.printStackTrace(); |
575 |
} catch (LegendLayerException e) {
|
576 |
e.printStackTrace(); |
577 |
} |
578 |
|
579 |
return null; |
580 |
} |
581 |
|
582 |
private boolean loadLayer(FLayer flayer) { |
583 |
try {
|
584 |
((FLyrWFS)fLayer).load(); |
585 |
} catch (LoadLayerException e) {
|
586 |
e.printStackTrace(); |
587 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
588 |
PluginServices.getText(this,"cantLoad")); |
589 |
return false; |
590 |
|
591 |
} |
592 |
|
593 |
if (((FLyrWFS)fLayer).getNumfeatures() == ((FLyrWFS)fLayer).getWfsDriver().getRowCount()) {
|
594 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
595 |
PluginServices.getText(this,"maxFeatures_aviso")); |
596 |
} |
597 |
return true; |
598 |
} |
599 |
} |
600 |
|
601 |
/**
|
602 |
* @see WFSFilterPanel#setWFSFilterPanelIsAsTabForWFSLayersLoad(boolean)
|
603 |
*/
|
604 |
public void setWFSFilterPanelIsAsTabForWFSLayersLoad(boolean b) { |
605 |
this.wfsParamsTabbedPane.setWFSFilterPanelIsAsTabForWFSLayersLoad(b);
|
606 |
} |
607 |
|
608 |
/**
|
609 |
* @see WFSFilterPanel#getWFSFilterPanelIsAsTabForWFSLayersLoad()
|
610 |
*/
|
611 |
public boolean getWFSFilterPanelIsAsTabForWFSLayersLoad() { |
612 |
return this.wfsParamsTabbedPane.getWFSFilterPanelIsAsTabForWFSLayersLoad(); |
613 |
} |
614 |
|
615 |
/**
|
616 |
* Sets all fielsd and values known of current layer to WFSFilterPanel
|
617 |
*/
|
618 |
public void updateAllFieldsAndValuesKnownOfCurrentLayerToWFSFilterPanel() { |
619 |
this.wfsParamsTabbedPane.setAllFieldsAndValuesKnownOfCurrentLayer(((FLyrWFS)this.getFLayer()).getAllFieldsAndValuesKnown()); |
620 |
} |
621 |
|
622 |
/**
|
623 |
* Refresh the layouts
|
624 |
*/
|
625 |
private void refreshLayouts(){ |
626 |
IWindow[] windows = PluginServices.getMDIManager().getAllWindows();
|
627 |
for (int i=0 ; i<windows.length ; i++){ |
628 |
if (windows[i] instanceof Layout){ |
629 |
((Layout)windows[i]).getLayoutContext().fullRefresh(); |
630 |
} |
631 |
} |
632 |
} |
633 |
|
634 |
/**
|
635 |
* @see WFSAreaPanel#updateWFSArea()
|
636 |
*/
|
637 |
public void updateWFSArea() { |
638 |
this.wfsParamsTabbedPane.updateWFSArea();
|
639 |
} |
640 |
} |
641 |
|