Subversion Repositories eFlore/Applications.cel

Rev

Rev 681 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 681 Rev 708
Line 4... Line 4...
4
 
4
 
5
import java.util.Date;
5
import java.util.Date;
Line 6... Line 6...
6
import java.util.Iterator;
6
import java.util.Iterator;
7
 
-
 
8
import org.tela_botanica.client.CarnetEnLigneMediateur;
7
 
9
import org.tela_botanica.client.Util;
8
import org.tela_botanica.client.CarnetEnLigneMediateur;
10
import org.tela_botanica.client.interfaces.Rafraichissable;
9
import org.tela_botanica.client.interfaces.Rafraichissable;
11
import org.tela_botanica.client.modeles.Configuration;
10
import org.tela_botanica.client.modeles.Configuration;
12
import org.tela_botanica.client.modeles.EntiteGeographiqueObservation;
11
import org.tela_botanica.client.modeles.EntiteGeographiqueObservation;
13
import org.tela_botanica.client.modeles.ListeObservation;
12
import org.tela_botanica.client.modeles.ListeObservation;
-
 
13
import org.tela_botanica.client.modeles.ListeReferentielCommune;
14
import org.tela_botanica.client.modeles.ListeReferentielCommune;
14
import org.tela_botanica.client.modeles.ListeReferentielNom;
15
import org.tela_botanica.client.modeles.ListeReferentielNom;
15
import org.tela_botanica.client.modeles.ListeReferentielPerso;
16
import org.tela_botanica.client.modeles.Observation;
16
import org.tela_botanica.client.modeles.Observation;
-
 
17
import org.tela_botanica.client.modeles.ReferentielCommune;
17
import org.tela_botanica.client.modeles.ReferentielCommune;
18
import org.tela_botanica.client.modeles.ReferentielNom;
-
 
19
import org.tela_botanica.client.modeles.ListeReferentielPerso.TypesReferentiels;
Line 18... Line 20...
18
import org.tela_botanica.client.modeles.ReferentielNom;
20
import org.tela_botanica.client.observation.ObservationMediateur;
19
import org.tela_botanica.client.observation.ObservationMediateur;
21
import org.tela_botanica.client.util.Util;
20
 
22
 
21
import com.google.gwt.core.client.GWT;
23
import com.google.gwt.core.client.GWT;
Line 85... Line 87...
85
	private ObservationMediateur	observationMediateur		= null;
87
	private ObservationMediateur	observationMediateur		= null;
Line 86... Line 88...
86
	
88
	
Line 87... Line 89...
87
	FormPanel panneauFormulaire = null;
89
	FormPanel panneauFormulaire = null;
88
 
90
 
89
	private DateField date = null;
91
	private DateField date = null;
90
	private TextField lieudit = null;
92
	private ComboBox lieudit = null;
91
	private TextField station = null;
93
	private ComboBox station = null;
92
	private TextField milieu = null;
94
	private ComboBox milieu = null;
93
	private TextField comment = null;
95
	private TextField comment = null;
94
	private ComboBox  commune = null;
96
	private ComboBox  commune = null;
95
	private String departement = null;
97
	private String departement = null;
Line 144... Line 146...
144
	private String formatDate = null ;
146
	private String formatDate = null ;
145
	private Button boutonOK = new Button("Créer");
147
	private Button boutonOK = new Button("Créer");
146
	private Button boutonAnnuler = new Button("Réinitialiser");
148
	private Button boutonAnnuler = new Button("Réinitialiser");
Line 147... Line 149...
147
 
149
 
-
 
150
	private boolean selectionCommune=false;
-
 
151
	private boolean selectionStation=false;
-
 
152
	private boolean selectionLieuDit=false;
148
	private boolean selectionCommune=false;
153
	private boolean selectionMilieu=false;
Line 149... Line 154...
149
	private boolean selectionEspece=false;
154
	private boolean selectionEspece=false;
150
	
155
	
Line 225... Line 230...
225
 
230
 
Line 226... Line 231...
226
	protected boolean rechercheCommuneEnCours = false;
231
	protected boolean rechercheCommuneEnCours = false;
Line -... Line 232...
-
 
232
 
-
 
233
	private Timer tCoord;
227
 
234
	
228
	private Timer tCoord;
235
	final String resultTplRefPerso = "<div class=\"search-item-commune\">{element_referentiel}</div>";  
229
	
236
	
230
	/**
237
	/**
231
	 * Constructeur sans argument (privé car ne doit pas être utilisé)
238
	 * Constructeur sans argument (privé car ne doit pas être utilisé)
Line 301... Line 308...
301
		tip2.applyTo(basculerverscarto.getElement());
308
		tip2.applyTo(basculerverscarto.getElement());
Line 302... Line 309...
302
		
309
		
303
		//Sur une meme ligne, ajout de plusieurs champs
310
		//Sur une meme ligne, ajout de plusieurs champs
Line 304... Line 311...
304
		htmlCommunePanel = new MultiFieldPanel(); 
311
		htmlCommunePanel = new MultiFieldPanel(); 
305
		
312
		
306
		int largeurCommune = Window.getClientWidth()/4; 
313
		int largeurCommune = Window.getClientWidth()/4;
Line 307... Line 314...
307
		htmlCommunePanel.addToRow(commune, largeurCommune); 
314
		htmlCommunePanel.addToRow(commune, largeurCommune);
308
		htmlCommunePanel.addToRow(basculerverscarto, 160); 
315
		htmlCommunePanel.addToRow(basculerverscarto, 160); 
Line 309... Line 316...
309
 
316
 
Line 310... Line 317...
310
		htmlCommunePanel.setBorder(false);
317
		htmlCommunePanel.setBorder(false);
-
 
318
		htmlCommunePanel.setId("x-commune-panel"); 
-
 
319
 
-
 
320
		panneauPremierColonne.add(htmlCommunePanel);
-
 
321
 
-
 
322
	    station = new ComboBox("Station", "station");  
-
 
323
	    station.setTpl(resultTplRefPerso);
-
 
324
	    station.setMode(ComboBox.REMOTE);
311
		htmlCommunePanel.setId("x-commune-panel"); 
325
		// commune.setPageSize(10); // Ne fonctionne pas 
Line 312... Line 326...
312
 
326
	    station.setItemSelector("div.search-item-commune");
Line 313... Line 327...
313
		panneauPremierColonne.add(htmlCommunePanel);
327
	    station.setTypeAhead(true);  
Line 451... Line 465...
451
		espece.setHideTrigger(true);
465
		espece.setHideTrigger(true);
452
		//espece.setTabIndex(6);
466
		//espece.setTabIndex(6);
Line 453... Line 467...
453
 
467
 
Line 454... Line 468...
454
	    panneauPremierColonne.add(espece, new AnchorLayoutData("95%"));   
468
	    panneauPremierColonne.add(espece, new AnchorLayoutData("95%"));   
-
 
469
	    
-
 
470
	    lieudit = new ComboBox("Lieu-dit", "lieudit");  
-
 
471
	    lieudit.setTpl(resultTplRefPerso);
-
 
472
	    lieudit.setMode(ComboBox.REMOTE);
-
 
473
	    lieudit.setItemSelector("div.search-item-commune");
-
 
474
	    lieudit.setTypeAhead(true);  
455
	    
475
	    lieudit.setLoadingText("Recherche...");  
456
	    lieudit = new TextField("Lieu-dit", "lieudit");  
-
 
457
	    lieudit.setAllowBlank(true);
476
	    lieudit.setHideTrigger(true);
Line 458... Line 477...
458
	    //lieudit.setTabIndex(2);
477
	    lieudit.setAllowBlank(true);
-
 
478
	    panneauSecondeColonne.add(lieudit,  new AnchorLayoutData("95%"));  
-
 
479
	       
-
 
480
	
-
 
481
	    milieu = new ComboBox("Milieu", "milieu");   
-
 
482
	    milieu.setTpl(resultTplRefPerso);
-
 
483
	    milieu.setMode(ComboBox.REMOTE);
459
	    panneauSecondeColonne.add(lieudit,  new AnchorLayoutData("95%"));  
484
	    milieu.setItemSelector("div.search-item-commune");
460
	       
-
 
461
	
485
	    milieu.setTypeAhead(true);  
Line 462... Line 486...
462
	    milieu = new TextField("Milieu", "milieu");  
486
	    milieu.setLoadingText("Recherche...");  
463
	    milieu.setAllowBlank(true);
487
	    milieu.setHideTrigger(true);
464
	    //milieu.setTabIndex(4);
488
	    milieu.setAllowBlank(true);
Line 667... Line 691...
667
				public void onSelect(DatePicker dataPicker, Date date) {
691
				public void onSelect(DatePicker dataPicker, Date date) {
668
					dateModifiee = true;
692
					dateModifiee = true;
669
				}
693
				}
670
		    });
694
		    });
Line -... Line 695...
-
 
695
		    
-
 
696
		    ListenerConfig listenerConfigAutocompletion=new ListenerConfig();
-
 
697
		    listenerConfigAutocompletion.setDelay(200);
-
 
698
		    listenerConfigAutocompletion.setStopPropagation(false);
-
 
699
		    listenerConfigAutocompletion.setStopEvent(false);
-
 
700
		    
-
 
701
		    station.addListener(new ComboBoxListenerAdapter() {  
-
 
702
	             public void onSelect(ComboBox comboBox, Record record, int index) {  
-
 
703
	            	 station.setValue(record.getAsString("element_referentiel"));
-
 
704
	                 selectionStation=true;
-
 
705
	                 station.collapse();
-
 
706
	             }  
-
 
707
	             
-
 
708
	             public void onExpand(ComboBox comboBox) {
-
 
709
	            	 comboBox.focus();
-
 
710
	             }
-
 
711
	         });  
671
		    
712
		    
Line 672... Line 713...
672
		    station.addKeyPressListener(new EventCallback() {
713
		    station.addKeyPressListener(new EventCallback() {
673
 
714
 
674
				public void execute(EventObject e) {
715
				public void execute(EventObject e) {
Line 688... Line 729...
688
		    	        case KEY_SHIFT:
729
		    	        case KEY_SHIFT:
689
		    	        case KEY_TAB:
730
		    	        case KEY_TAB:
690
		    	        case KEY_UP:
731
		    	        case KEY_UP:
691
		    	      break;
732
		    	      break;
Line 692... Line 733...
692
		    	      
733
		    	      
-
 
734
	  	    	      case KEY_ENTER:	
-
 
735
	  	    	    	if (selectionStation) {
-
 
736
	  	    	    		stationModifiee= true;
-
 
737
	  	    	    		selectionStation=false;
-
 
738
	   	    	    	}
693
	  	    	      case KEY_ENTER:	  	    	    	  
739
	   	    	    	else {
-
 
740
	  	    	    		validerSaisie(Champs.STATION); 	
694
	  	    	    		validerSaisie(Champs.STATION); 	    	    		 
741
	  	    	    	}
Line 695... Line 742...
695
	  	    	    	  break;
742
	  	    	    break;
-
 
743
	  	    	       
696
	  	    	       
744
	  	    	      default:
697
	  	    	      default:
745
	  	    	    	  obtenirReferentielStation();
698
	  	    	    	  stationModifiee = true;
746
	  	    	    	  stationModifiee = true;
699
					}
747
					}
Line 700... Line 748...
700
				}
748
				}
701
		    });
749
		    },listenerConfigAutocompletion);
Line 769... Line 817...
769
		     		}
817
		     		}
Line 770... Line 818...
770
		    	 
818
		    	 
Line 771... Line 819...
771
		    		},    listenerConfigEspece
819
		    		},    listenerConfigEspece
-
 
820
		    	
-
 
821
			);
-
 
822
			
-
 
823
			// Listener completion lieudit 
-
 
824
			lieudit.addListener(new ComboBoxListenerAdapter() {  
-
 
825
	             public void onSelect(ComboBox comboBox, Record record, int index) {  
-
 
826
	            	 lieudit.setValue(record.getAsString("element_referentiel"));
-
 
827
	                 selectionLieuDit=true;
-
 
828
	                 lieudit.collapse();
Line 772... Line 829...
772
		    	
829
	             }  
Line 773... Line 830...
773
			);
830
	         });  
774
		    
831
		    
Line 792... Line 849...
792
	  	    	      case KEY_TAB:
849
	  	    	      case KEY_TAB:
793
	  	    	      case KEY_UP:
850
	  	    	      case KEY_UP:
Line 794... Line 851...
794
  	    	    	
851
  	    	    	
Line 795... Line 852...
795
  	    	        break;
852
  	    	        break;
-
 
853
					
-
 
854
	  	    	    case KEY_ENTER:	
-
 
855
	  	    	    	if (selectionLieuDit) {
-
 
856
	  	    	    		lieuDitModifie= true;
-
 
857
	  	    	    		selectionLieuDit=false;
796
					
858
	   	    	    	}
-
 
859
	   	    	    	else {
797
	  	    	      case KEY_ENTER:	  	    	    	  
860
	  	    	    		validerSaisie(Champs.LIEUDIT); 	
Line 798... Line 861...
798
	  	    	    		validerSaisie(Champs.LIEUDIT); 	    	    		 
861
	  	    	    	}
799
	  	    	    	  break;
862
	  	    	    break;
-
 
863
	  	    	       
800
	  	    	       
864
	  	    	      default:
801
	  	    	      default:
865
	  					lieuDitModifie = true;
-
 
866
	  	    	      	obtenirReferentielLieuDit();
-
 
867
					}
-
 
868
				}
-
 
869
		    },listenerConfigAutocompletion);
-
 
870
			
-
 
871
			// Listener completion lieudit 
-
 
872
			milieu.addListener(new ComboBoxListenerAdapter() {  
-
 
873
	             public void onSelect(ComboBox comboBox, Record record, int index) {  
-
 
874
	            	 milieu.setValue(record.getAsString("element_referentiel"));
802
	  					lieuDitModifie = true;
875
	                 selectionMilieu=true;
Line 803... Line 876...
803
					}
876
	                 milieu.collapse();
Line 804... Line 877...
804
				}
877
	             }  
805
		    });
878
	         }); 
Line 824... Line 897...
824
	  	    	      case KEY_TAB:
897
	  	    	      case KEY_TAB:
825
	  	    	      case KEY_UP:
898
	  	    	      case KEY_UP:
Line 826... Line 899...
826
	  	    	    	
899
	  	    	    	
Line 827... Line 900...
827
	  	    	        break;
900
	  	    	        break;
-
 
901
	  	    	      
-
 
902
		  	    	    case KEY_ENTER:	
-
 
903
		  	    	    	if (selectionMilieu) {
-
 
904
		  	    	    		milieuModifie= true;
-
 
905
		  	    	    		selectionMilieu=false;
828
	  	    	      
906
		   	    	    	}
-
 
907
		   	    	    	else {
829
	  	    	      case KEY_ENTER:	  	    	    	  
908
		  	    	    		validerSaisie(Champs.MILIEU); 	
Line 830... Line 909...
830
	  	    	    		validerSaisie(Champs.MILIEU); 	    	    		 
909
		  	    	    	}
831
	  	    	    	  break;
910
		  	    	    break;
-
 
911
	  	    	       
832
	  	    	       
912
	  	    	      default:
833
	  	    	      default:
913
	  					milieuModifie = true;
834
	  					milieuModifie = true;
914
	  	    	      	obtenirListeReferentielMilieu();
Line 835... Line 915...
835
					}
915
					}
Line 836... Line 916...
836
				}
916
				}
837
		    });
917
		    },listenerConfigAutocompletion);
Line 980... Line 1060...
980
				commune.focus();
1060
				commune.focus();
981
			}
1061
			}
982
		});	
1062
		});	
Line 983... Line 1063...
983
			
1063
			
984
	}
1064
	}
985
	
1065
 
986
	/**
1066
	/**
987
	 * Validation de la saisie 
1067
	 * Validation de la saisie 
Line 988... Line 1068...
988
	 */
1068
	 */
Line 1106... Line 1186...
1106
	
1186
	
Line 1107... Line 1187...
1107
				espece.setStore(store);
1187
				espece.setStore(store);
Line -... Line 1188...
-
 
1188
				
-
 
1189
			}
-
 
1190
			
-
 
1191
			if(nouvelleDonnees instanceof ListeReferentielPerso)
-
 
1192
			{
-
 
1193
				
-
 
1194
				ListeReferentielPerso referentielPerso = (ListeReferentielPerso)nouvelleDonnees;
-
 
1195
				
-
 
1196
				int i = 0;
-
 
1197
				Object[][] refData = new Object[referentielPerso.size()][1];
-
 
1198
				
-
 
1199
				// on la parse et on récupère les informations quiç nous interessent
-
 
1200
				for (Iterator it = referentielPerso.keySet().iterator(); it.hasNext();) 
-
 
1201
				{
-
 
1202
					String ref= referentielPerso.get(it.next());
-
 
1203
					refData[i][0]= ref;
-
 
1204
					
-
 
1205
					i++;
-
 
1206
				}
-
 
1207
				
-
 
1208
				
-
 
1209
				//creation du store
-
 
1210
				FieldDef defStation = new StringFieldDef("element_referentiel");
-
 
1211
				FieldDef[] defTab = {defStation};
-
 
1212
				
-
 
1213
				RecordDef rd = new RecordDef(defTab);
-
 
1214
				
-
 
1215
				final MemoryProxy dataProxy = new MemoryProxy(refData);
-
 
1216
				final ArrayReader reader = new ArrayReader(rd);		
-
 
1217
								
-
 
1218
				Store store=new Store(dataProxy,reader);	
-
 
1219
				
-
 
1220
				switch (referentielPerso.getTypeReferentiel()) {
-
 
1221
								
-
 
1222
					case REFERENTIEL_STATION:				
-
 
1223
						station.setStore(store);
-
 
1224
						store.load();
-
 
1225
						
-
 
1226
					break;
-
 
1227
					
-
 
1228
					case REFERENTIEL_LIEU_DIT:					
-
 
1229
						lieudit.setStore(store);
-
 
1230
						store.load();
-
 
1231
					break;
-
 
1232
					
-
 
1233
					case REFERENTIEL_MILIEU:			
-
 
1234
						milieu.setStore(store);
-
 
1235
						store.load();
-
 
1236
					break;
-
 
1237
	
-
 
1238
					default:
-
 
1239
					break;
1108
				
1240
				}
Line 1109... Line 1241...
1109
			}
1241
			}
1110
			
1242
			
1111
			// On recoit une observation dont on veut afficher le detail 
1243
			// On recoit une observation dont on veut afficher le detail 
Line 1255... Line 1387...
1255
	  esp=esp.replaceAll("%","");
1387
	  esp=esp.replaceAll("%","");
Line 1256... Line 1388...
1256
		
1388
		
Line 1257... Line 1389...
1257
	  observationMediateur.obtenirListeReferentielNom(this,esp);
1389
	  observationMediateur.obtenirListeReferentielNom(this,esp);
-
 
1390
	 
-
 
1391
	}
-
 
1392
	
-
 
1393
	
-
 
1394
	protected void obtenirReferentielStation() {		
-
 
1395
		observationMediateur.obtenirListeReferentielPerso(this,TypesReferentiels.REFERENTIEL_STATION,station.getText());
-
 
1396
	}
-
 
1397
	
-
 
1398
 
-
 
1399
	protected void obtenirListeReferentielMilieu() {
-
 
1400
		observationMediateur.obtenirListeReferentielPerso(this,TypesReferentiels.REFERENTIEL_MILIEU,milieu.getText());
-
 
1401
	}
-
 
1402
 
-
 
1403
	protected void obtenirReferentielLieuDit() {
Line 1258... Line 1404...
1258
	 
1404
		observationMediateur.obtenirListeReferentielPerso(this,TypesReferentiels.REFERENTIEL_LIEU_DIT,lieudit.getText());
Line 1259... Line 1405...
1259
	}
1405
	}
Line 1889... Line 2035...
1889
	public boolean communeInitialisee() {
2035
	public boolean communeInitialisee() {
1890
		return communeModifiee;
2036
		return communeModifiee;
1891
	}
2037
	}
Line 1892... Line 2038...
1892
	
2038
	
1893
	public void redimensionnerFormulaire() {
-
 
1894
		doLayout();
2039
	public void redimensionnerFormulaire() {
1895
		//htmlCommunePanel.setWidth(panneauPremierColonne.getWidth() - 10);
2040
		//htmlCommunePanel.setWidth(panneauPremierColonne.getWidth() - 10);
1896
		afficherFormulaireLatLon.setWidth(panneauIntermediaire.getWidth()+"px");
2041
		afficherFormulaireLatLon.setWidth(panneauIntermediaire.getWidth()+"px");
1897
		panneauPremierColonne.doLayout();
2042
		panneauPremierColonne.doLayout();
1898
		panneauSecondeColonne.doLayout();
2043
		panneauSecondeColonne.doLayout();
-
 
2044
		panneauIntermediaire.doLayout();
-
 
2045
		
-
 
2046
		/*if(panneauPremierColonne.getWidth() < 450 ) {
-
 
2047
			basculerverscarto.setHTML("<a id=\"lien_carto\" href=\"#\" tabindex=\"2\">Localiser</a>");
-
 
2048
			commune.setWidth(180);
-
 
2049
			basculerverscarto.setWidth("60px");
-
 
2050
			htmlCommunePanel.doLayout();
-
 
2051
		} else {
-
 
2052
			basculerverscarto.setHTML("<a id=\"lien_carto\" href=\"#\" tabindex=\"2\">Localiser la commune</a>");
-
 
2053
			commune.setWidth(290);
-
 
2054
			basculerverscarto.setWidth("160px");
-
 
2055
			htmlCommunePanel.doLayout();
-
 
2056
		}*/
-
 
2057
		
1899
		panneauIntermediaire.doLayout();
2058
		doLayout();
1900
	}
2059
	}