Revision 10626 trunk/extensions/extWFS2/src/com/iver/cit/gvsig/gui/dialogs/WFSPropsDialog.java
WFSPropsDialog.java | ||
---|---|---|
17 | 17 |
import com.iver.andami.PluginServices; |
18 | 18 |
import com.iver.andami.ui.mdiManager.IWindow; |
19 | 19 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
20 |
import com.iver.cit.gvsig.fmap.DriverException; |
|
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; |
|
21 | 30 |
import com.iver.cit.gvsig.fmap.MapControl; |
31 |
import com.iver.cit.gvsig.fmap.drivers.WFSLayerException; |
|
22 | 32 |
import com.iver.cit.gvsig.fmap.drivers.wfs.FMapWFSDriver; |
23 | 33 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
24 | 34 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
... | ... | |
78 | 88 |
* |
79 | 89 |
* $Id$ |
80 | 90 |
* $Log$ |
81 |
* Revision 1.33 2007-03-01 13:11:27 ppiqueras |
|
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 |
|
82 | 95 |
* Cambios menores. |
83 | 96 |
* |
84 | 97 |
* Revision 1.32 2007/02/22 12:24:19 ppiqueras |
... | ... | |
197 | 210 |
private CommandListener m_actionListener = null; |
198 | 211 |
private JPanel buttonsPanel = null; |
199 | 212 |
boolean applied = false; |
213 |
|
|
214 |
|
|
200 | 215 |
|
201 | 216 |
/** |
202 | 217 |
* Default constructor with a Layer as parameter |
... | ... | |
214 | 229 |
* @param layer A layer |
215 | 230 |
*/ |
216 | 231 |
private void initialize(FLayer layer) { |
217 |
setLayout(null);
|
|
232 |
setLayout(null); |
|
218 | 233 |
setFLayer(layer); |
219 | 234 |
wfsParamsTabbedPane = getParamsPanel(((FLyrWFS) layer).getProperties()); |
220 | 235 |
wfsParamsTabbedPane.addWizardListener(new WizardListener(){ |
... | ... | |
225 | 240 |
|
226 | 241 |
public void error(Exception e) { |
227 | 242 |
} |
228 |
|
|
243 |
|
|
229 | 244 |
}) ; |
230 | 245 |
//wfsParamsTabbedPane.disableDisagregatedLayers(); |
231 | 246 |
this.add(wfsParamsTabbedPane); |
232 | 247 |
this.add(getButtonsPanel(), null); |
233 | 248 |
} |
249 |
|
|
234 | 250 |
|
235 | 251 |
/** |
236 | 252 |
* Buttons OK, Apply, Cancel |
... | ... | |
242 | 258 |
m_actionListener = new CommandListener(this); |
243 | 259 |
buttonsPanel = new JPanel(); |
244 | 260 |
buttonsPanel.setBounds(5, wfsParamsTabbedPane.getHeight(), 471, 40); |
245 |
buttonsPanel.setLayout(null);
|
|
261 |
buttonsPanel.setLayout(null); |
|
246 | 262 |
buttonsPanel.setName("buttonPanel"); |
247 |
|
|
263 |
|
|
248 | 264 |
buttonsPanel.add(getBtnOk(), null); |
249 | 265 |
buttonsPanel.add(getBtnApply(), null); |
250 | 266 |
buttonsPanel.add(getBtnCancel(), null); |
251 | 267 |
} |
252 | 268 |
return buttonsPanel; |
253 | 269 |
} |
254 |
|
|
255 |
|
|
270 |
|
|
271 |
|
|
256 | 272 |
/** |
257 | 273 |
* With getParamsPanel we have access to the map config TabbedPane. |
258 | 274 |
* If this panel doesn't exist yet (which can occur when an existing project is |
259 | 275 |
* recovered) it is been automatically constructed by connecting to the server, |
260 | 276 |
* reloading the necessary data, filling up the content and setting the selected |
261 | 277 |
* values that were selected when the projet was saved. |
262 |
*
|
|
263 |
*
|
|
278 |
* |
|
279 |
* |
|
264 | 280 |
* Since a connection to the server is needed when rebuiliding the panel, this |
265 | 281 |
* causes a delay for the panel's showing up or a nullPointer error if there is |
266 | 282 |
* no path to the server. |
267 |
*
|
|
268 |
*
|
|
283 |
* |
|
284 |
* |
|
269 | 285 |
* Con getParamsPanel tenemos acceso a juego de pesta?as de configuraci?n |
270 | 286 |
* del mapa. Si este panel todav?a no existe (como puede ser cuando |
271 | 287 |
* recuperamos un proyecto guardado) ?ste se crea autom?ticamente conectando |
272 | 288 |
* al servidor, recuperando los datos necesarios, rellenando el contenido y |
273 | 289 |
* dejando seleccionados los valores que estaban seleccionados cuando se |
274 | 290 |
* guard� el proyecto. |
275 |
*
|
|
276 |
*
|
|
291 |
* |
|
292 |
* |
|
277 | 293 |
* Como para reconstruirse requiere una conexi�n con el servidor esto causa |
278 | 294 |
* un retardo en la aparici�n en el toc o un error de nullPointer si no |
279 | 295 |
* hay conexi�n hasta el servidor. |
280 |
*
|
|
281 |
*
|
|
296 |
* |
|
297 |
* |
|
282 | 298 |
* @return WMSParamsPanel |
283 | 299 |
*/ |
284 | 300 |
public WFSParamsPanel getParamsPanel(HashMap info) { |
... | ... | |
296 | 312 |
toc.setStatus((WFSStatus)info.get("status")); |
297 | 313 |
toc.setVisible(true); |
298 | 314 |
applied = false; |
299 |
return toc;
|
|
315 |
return toc; |
|
300 | 316 |
} |
301 |
return null;
|
|
317 |
return null; |
|
302 | 318 |
} |
319 |
|
|
320 |
|
|
303 | 321 |
|
304 | 322 |
/* |
305 | 323 |
* (non-Javadoc) |
... | ... | |
344 | 362 |
} |
345 | 363 |
return btnOk; |
346 | 364 |
} |
365 |
|
|
347 | 366 |
|
348 | 367 |
/** |
349 | 368 |
* JButton Apply |
... | ... | |
361 | 380 |
} |
362 | 381 |
return btnApply; |
363 | 382 |
} |
383 |
|
|
364 | 384 |
|
365 | 385 |
/** |
366 | 386 |
* JButton Cancel |
... | ... | |
378 | 398 |
return btnCancel; |
379 | 399 |
} |
380 | 400 |
|
401 |
|
|
381 | 402 |
/** |
382 | 403 |
* Closes this panel |
383 | 404 |
*/ |
384 | 405 |
public void close() { |
385 |
PluginServices.getMDIManager().closeWindow(this);
|
|
406 |
PluginServices.getMDIManager().closeWindow(this); |
|
386 | 407 |
} |
387 |
|
|
408 |
|
|
388 | 409 |
/** |
389 | 410 |
* Merge two FLayers in one |
390 | 411 |
* @param group1 |
... | ... | |
392 | 413 |
* @return |
393 | 414 |
*/ |
394 | 415 |
private FLayers mergeFLayers(FLayers group1, FLayers group2) |
395 |
{
|
|
416 |
{ |
|
396 | 417 |
FLayer layer; |
397 | 418 |
for(int i = 0; i < group2.getLayersCount(); i++) |
398 | 419 |
{ |
... | ... | |
401 | 422 |
group1.addLayer( layer ); |
402 | 423 |
} |
403 | 424 |
} |
404 |
|
|
425 |
|
|
405 | 426 |
return group1; |
406 | 427 |
} |
428 |
|
|
407 | 429 |
|
408 | 430 |
/** |
409 | 431 |
* @see ActionListener |
... | ... | |
427 | 449 |
close(); |
428 | 450 |
return; |
429 | 451 |
} |
452 |
try { |
|
430 | 453 |
|
431 | 454 |
View activeView = (View) PluginServices.getMDIManager().getActiveWindow(); |
432 | 455 |
String layerName = null; |
433 | 456 |
|
434 | 457 |
if (e.getActionCommand() == "APPLY") { |
435 | 458 |
// We can't 'apply' if there is a filter query and it's incorrect |
436 |
if (wfsParamsTabbedPane.getFilterQuery() != null) {
|
|
437 |
|
|
459 |
if (wfsParamsTabbedPane.getFilterQuery() != null) { |
|
460 |
|
|
438 | 461 |
if ((layerName = prepareFlyrWFSLayer()) != null) { |
439 | 462 |
MapControl mapCtrl = activeView.getMapControl(); |
440 | 463 |
mapCtrl.getMapContext().getLayers().replaceLayer(layerName, fLayer); |
464 |
|
|
441 | 465 |
mapCtrl.getMapContext().invalidate(); |
442 | 466 |
} |
443 | 467 |
|
... | ... | |
449 | 473 |
setWFSFilterPanelIsAsTabForWFSLayersLoad(false); |
450 | 474 |
wfsParamsTabbedPane.resetFieldsSelectedOfSameLayerHasChanged(); // reset that field |
451 | 475 |
} |
476 |
|
|
452 | 477 |
|
453 | 478 |
// Update values associated to the current selected field |
454 | 479 |
wfsParamsTabbedPane.updateWFSFilterFieldValues(); |
455 | 480 |
} |
456 | 481 |
return; |
457 | 482 |
} |
458 |
|
|
483 |
|
|
459 | 484 |
if (e.getActionCommand() == "OK") { |
460 | 485 |
// We can't 'apply' if there is a filter query and it's incorrect |
461 |
if (wfsParamsTabbedPane.getFilterQuery() != null) {
|
|
486 |
if (wfsParamsTabbedPane.getFilterQuery() != null) { |
|
462 | 487 |
if (!applied) { |
463 | 488 |
if (getBtnApply().isEnabled()){ |
464 |
|
|
489 |
|
|
465 | 490 |
if ((layerName = prepareFlyrWFSLayer()) != null) |
466 | 491 |
{ |
467 | 492 |
View vista = (View) PluginServices.getMDIManager().getActiveWindow(); |
... | ... | |
471 | 496 |
refreshLayouts(); |
472 | 497 |
} |
473 | 498 |
} |
474 |
}
|
|
499 |
} |
|
475 | 500 |
close(); |
476 |
|
|
501 |
|
|
477 | 502 |
// Update all fields and values known about the current layer loaded (and selected) |
478 | 503 |
((FLyrWFS)fLayer).setAllFieldsAndValuesKnown(wfsParamsTabbedPane.getAllFieldsAndValuesKnownOfCurrentLayer()); |
479 | 504 |
} |
505 |
|
|
480 | 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 |
|
|
481 | 542 |
} |
482 | 543 |
|
483 | 544 |
/** |
484 | 545 |
* Updates data in the current layer of current active view |
485 |
*
|
|
546 |
* |
|
486 | 547 |
* @param currentView The current active view |
487 | 548 |
* @return Te name of the layer |
488 | 549 |
*/ |
... | ... | |
490 | 551 |
// layerName = fLayer.getName(); |
491 | 552 |
// View activeView = (View) PluginServices.getMDIManager().getActiveWindow(); |
492 | 553 |
VectorialLegend legend = (VectorialLegend)((FLyrVect)fLayer).getLegend(); |
493 |
FMapWFSDriver driver = wfsParamsTabbedPane.getDriver();
|
|
554 |
FMapWFSDriver driver = wfsParamsTabbedPane.getDriver(); |
|
494 | 555 |
try { |
495 | 556 |
fLayer = wfsParamsTabbedPane.getLayer(); |
496 | 557 |
|
... | ... | |
499 | 560 |
String onlineResource = wfsParamsTabbedPane.getData().getOnlineResource(); |
500 | 561 |
fLayer = new FLyrWFSFactory().getFLyrWFS(fLayer,host,onlineResource,driver,true); |
501 | 562 |
((FLyrWFS)fLayer).setLegend(legend); |
502 |
|
|
563 |
|
|
503 | 564 |
// Update all fields and values known about the current layer loaded (and selected) |
504 | 565 |
((FLyrWFS)fLayer).setAllFieldsAndValuesKnown(wfsParamsTabbedPane.getAllFieldsAndValuesKnownOfCurrentLayer()); |
505 |
|
|
566 |
|
|
506 | 567 |
return fLayer.getName(); |
507 | 568 |
} |
508 | 569 |
} catch (MalformedURLException e1) { |
509 | 570 |
e1.printStackTrace(); |
510 |
} catch (FieldNotFoundException e1) { |
|
511 |
e1.printStackTrace(); |
|
512 |
} catch (DriverException e1) { |
|
513 |
e1.printStackTrace(); |
|
571 |
} catch (LegendLayerException e) { |
|
572 |
// TODO Auto-generated catch block |
|
573 |
e.printStackTrace(); |
|
514 | 574 |
} |
515 |
|
|
575 |
|
|
516 | 576 |
return null; |
517 | 577 |
} |
518 | 578 |
|
519 |
/** |
|
520 |
* Loads a layer |
|
521 |
*/ |
|
522 | 579 |
private boolean loadLayer(FLayer flayer) { |
523 |
try { |
|
524 |
((FLyrWFS)fLayer).load(); |
|
525 |
|
|
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 |
|
|
526 | 590 |
if (((FLyrWFS)fLayer).getNumfeatures() == ((FLyrWFS)fLayer).getWfsDriver().getRowCount()) { |
527 | 591 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
528 |
PluginServices.getText(this,"maxFeatures_aviso"));
|
|
592 |
PluginServices.getText(this,"maxFeatures_aviso")); |
|
529 | 593 |
} |
530 |
} catch (Exception e1) { |
|
531 |
e1.printStackTrace(); |
|
532 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
|
533 |
PluginServices.getText(this,"cantLoad")); |
|
534 |
return false; |
|
535 |
} |
|
536 | 594 |
return true; |
537 | 595 |
} |
538 | 596 |
} |
539 |
|
|
597 |
|
|
540 | 598 |
/** |
541 | 599 |
* @see WFSFilterPanel#setWFSFilterPanelIsAsTabForWFSLayersLoad(boolean) |
542 | 600 |
*/ |
543 | 601 |
public void setWFSFilterPanelIsAsTabForWFSLayersLoad(boolean b) { |
544 | 602 |
this.wfsParamsTabbedPane.setWFSFilterPanelIsAsTabForWFSLayersLoad(b); |
545 | 603 |
} |
546 |
|
|
604 |
|
|
547 | 605 |
/** |
548 | 606 |
* @see WFSFilterPanel#getWFSFilterPanelIsAsTabForWFSLayersLoad() |
549 | 607 |
*/ |
550 | 608 |
public boolean getWFSFilterPanelIsAsTabForWFSLayersLoad() { |
551 | 609 |
return this.wfsParamsTabbedPane.getWFSFilterPanelIsAsTabForWFSLayersLoad(); |
552 | 610 |
} |
553 |
|
|
611 |
|
|
554 | 612 |
/** |
555 | 613 |
* Sets all fielsd and values known of current layer to WFSFilterPanel |
556 | 614 |
*/ |
557 | 615 |
public void updateAllFieldsAndValuesKnownOfCurrentLayerToWFSFilterPanel() { |
558 | 616 |
this.wfsParamsTabbedPane.setAllFieldsAndValuesKnownOfCurrentLayer(((FLyrWFS)this.getFLayer()).getAllFieldsAndValuesKnown()); |
559 | 617 |
} |
560 |
|
|
618 |
|
|
561 | 619 |
/** |
562 | 620 |
* Refresh the layouts |
563 | 621 |
*/ |
564 |
private void refreshLayouts(){
|
|
622 |
private void refreshLayouts(){ |
|
565 | 623 |
IWindow[] windows = PluginServices.getMDIManager().getAllWindows(); |
566 | 624 |
for (int i=0 ; i<windows.length ; i++){ |
567 | 625 |
if (windows[i] instanceof Layout){ |
Also available in: Unified diff