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