Revision 9387 trunk/extensions/extWFS2/src/com/iver/cit/gvsig/gui/dialogs/WFSPropsDialog.java

View differences:

WFSPropsDialog.java
78 78
 *
79 79
 * $Id$
80 80
 * $Log$
81
 * Revision 1.19  2006-12-19 08:27:29  jorpiell
81
 * Revision 1.20  2006-12-20 14:21:22  ppiqueras
82
 * Corregido bug que no actualice vista si el filtro no es correcto
83
 *
84
 * Revision 1.19  2006/12/19 08:27:29  jorpiell
82 85
 * Problem decreasing the selected attributes number solved
83 86
 *
84 87
 * Revision 1.18  2006/12/18 08:48:38  jorpiell
......
339 342
		 public void actionPerformed(ActionEvent e) {
340 343
			 if ((e.getActionCommand() == "CANCEL") || (!getBtnApply().isEnabled())){
341 344
				 close();
342
			 }else{					
343
				 String layerName = fLayer.getName();
344
				 VectorialLegend legend = (VectorialLegend)((FLyrVect)fLayer).getLegend();
345
				 FMapWFSDriver driver = wfsParamsTabbedPane.getDriver();						
346
				 try {
347
					 fLayer = wfsParamsTabbedPane.getLayer();
348
					 URL host = new URL(wfsParamsTabbedPane.getData().getHost());
349
					 String onlineResource = wfsParamsTabbedPane.getData().getOnlineResource();
350
					 fLayer = new FLyrWFSFactory().getFLyrWFS(fLayer,host,onlineResource,driver,true);
351
					 if (fLayer != null){
352
						 ((FLyrWFS)fLayer).setLegend(legend);
353
						 // Update all fields and values known about the current layer loaded (and selected)
354
						 ((FLyrWFS)fLayer).setAllFieldsAndValuesKnown(wfsParamsTabbedPane.getAllFieldsAndValuesKnownOfCurrentLayer());
345
			 }else{
346
				 String layerName = null;
347
				 
348
				 // Don't update if the filter is incorrect
349
				 if (wfsParamsTabbedPane.getFilterQuery() != null) {
350
					 layerName = fLayer.getName();
351
				 	 View activeView = (View) PluginServices.getMDIManager().getActiveWindow();
352
				 	 VectorialLegend legend = (VectorialLegend)((FLyrVect)fLayer).getLegend();
353
				 	 FMapWFSDriver driver = wfsParamsTabbedPane.getDriver();						
354
				 	 try {
355
				 		 fLayer = wfsParamsTabbedPane.getLayer();
356
				 		 URL host = new URL(wfsParamsTabbedPane.getData().getHost());
357
				 		 String onlineResource = wfsParamsTabbedPane.getData().getOnlineResource();
358
				 		 fLayer = new FLyrWFSFactory().getFLyrWFS(fLayer,host,onlineResource,driver,true);
359
				 		 if (fLayer != null){
360
				 			 ((FLyrWFS)fLayer).setLegend(legend);
361
							
362
				 			 // Update all fields and values known about the current layer loaded (and selected)
363
				 			 ((FLyrWFS)fLayer).setAllFieldsAndValuesKnown(wfsParamsTabbedPane.getAllFieldsAndValuesKnownOfCurrentLayer());
364
				 		 }
365
					 } catch (MalformedURLException e1) {
366
						 e1.printStackTrace();
367
					 } catch (FieldNotFoundException e1) {
368
						 e1.printStackTrace();
369
					 } catch (DriverException e1) {
370
						 e1.printStackTrace();
355 371
					 }
356
				} catch (MalformedURLException e1) {
357
					// TODO Auto-generated catch block
358
					e1.printStackTrace();
359
				} catch (FieldNotFoundException e1) {
360
					// TODO Auto-generated catch block
361
					e1.printStackTrace();
362
				} catch (DriverException e1) {
363
					// TODO Auto-generated catch block
364
					e1.printStackTrace();
365
				}
366
				
367
				if (e.getActionCommand() == "APPLY"){
372
				 }
373
				 
374
				 if (e.getActionCommand() == "APPLY"){
368 375
					// We can't 'apply' if there is a filter query and it's incorrect
369 376
					if (wfsParamsTabbedPane.getFilterQuery() != null) {					
370
						View vista = (View) PluginServices.getMDIManager().getActiveWindow();
371
						MapControl mapCtrl = vista.getMapControl();					 
372
						mapCtrl.getMapContext().getLayers().replaceLayer(layerName, fLayer);					 
373
						mapCtrl.getMapContext().invalidate();
374
						applied = true;
375
						getBtnApply().setEnabled(!applied);
376
						refreshLayouts();		
377
						// If we load another layer, or the same but we've selected others attributes -> notify it to he WFSFilter panel
378
						if (getWFSFilterPanelIsAsTabForWFSLayersLoad() || (wfsParamsTabbedPane.getAttributesSelectedOfSameLayerHasChanged())) {
379
							setWFSFilterPanelIsAsTabForWFSLayersLoad(false);
380
							wfsParamsTabbedPane.resetAttributesSelectedOfSameLayerHasChanged(); // reset that attribute
381
						}
382
						
383
						// Update values associated to the current selected field
384
						wfsParamsTabbedPane.updateWFSFilterFieldValues();						
385
					}
386
				}				
377
						 View vista = (View) PluginServices.getMDIManager().getActiveWindow();
378
						 MapControl mapCtrl = vista.getMapControl();
379
						 mapCtrl.getMapContext().getLayers().replaceLayer(layerName, fLayer);
380
						 mapCtrl.getMapContext().invalidate();
381
						 applied = true;
382
						 getBtnApply().setEnabled(!applied);
383
						 refreshLayouts();
384
						 // If we load another layer, or the same but we've selected others attributes -> notify it to he WFSFilter panel
385
						 if (getWFSFilterPanelIsAsTabForWFSLayersLoad() || (wfsParamsTabbedPane.getAttributesSelectedOfSameLayerHasChanged())) {
386
							 setWFSFilterPanelIsAsTabForWFSLayersLoad(false);
387
							 wfsParamsTabbedPane.resetAttributesSelectedOfSameLayerHasChanged(); // reset that attribute
388
					 	 }
389
							 
390
						 // Update values associated to the current selected field
391
						 wfsParamsTabbedPane.updateWFSFilterFieldValues();
392
					 }
393
				 }
394
				
387 395
				 if (e.getActionCommand() == "OK") {
388 396
					// We can't 'apply' if there is a filter query and it's incorrect
389 397
					if (wfsParamsTabbedPane.getFilterQuery() != null) {	
......
403 411
					}
404 412
				 }
405 413
			 }
406
		 }	 
414
		 }
415

  
416
		 private boolean loadLayer(FLayer flayer){
417
			 try {
418
				 ((FLyrWFS)fLayer).load();
419
				
420
				 if (((FLyrWFS)fLayer).getNumfeatures() == ((FLyrWFS)fLayer).getWfsDriver().getRowCount())  {
421
					 JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),
422
							 PluginServices.getText(this,"maxFeatures_aviso"));	
423
				 }
424
			 } catch (Exception e1) {
425
				 e1.printStackTrace();
426
				 JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),
427
						 PluginServices.getText(this,"cantLoad"));
428
				 return false;
429
			 }
430
			 return true;
431
		 }			 
432
		 
407 433
	 }
408 434
	 
409 435
	/**

Also available in: Unified diff