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