Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 246 Rev 248
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
 
7
 
8
import org.tela_botanica.client.interfaces.Rafraichissable;
8
import org.tela_botanica.client.interfaces.Rafraichissable;
9
import org.tela_botanica.client.modeles.EntiteGeographiqueObservation;
9
import org.tela_botanica.client.modeles.ListeObservation;
10
import org.tela_botanica.client.modeles.ListeObservation;
10
import org.tela_botanica.client.modeles.ListeReferentielCommune;
11
import org.tela_botanica.client.modeles.ListeReferentielCommune;
11
import org.tela_botanica.client.modeles.ListeReferentielNom;
12
import org.tela_botanica.client.modeles.ListeReferentielNom;
12
import org.tela_botanica.client.modeles.Observation;
13
import org.tela_botanica.client.modeles.Observation;
13
import org.tela_botanica.client.modeles.ReferentielCommune;
14
import org.tela_botanica.client.modeles.ReferentielCommune;
Line 14... Line 15...
14
import org.tela_botanica.client.modeles.ReferentielNom;
15
import org.tela_botanica.client.modeles.ReferentielNom;
-
 
16
import org.tela_botanica.client.observation.ObservationMediateur;
15
import org.tela_botanica.client.observation.ObservationMediateur;
17
 
-
 
18
import com.google.gwt.core.client.JavaScriptObject;
16
 
19
import com.google.gwt.maps.client.geom.LatLng;
17
import com.google.gwt.core.client.JavaScriptObject;
20
import com.google.gwt.user.client.Window;
18
import com.google.gwt.user.client.Window;
21
import com.google.gwt.user.client.ui.HTML;
-
 
22
import com.gwtext.client.core.EventCallback;
19
import com.gwtext.client.core.EventCallback;
23
import com.gwtext.client.core.EventObject;
20
import com.gwtext.client.core.EventObject;
24
import com.gwtext.client.core.Ext;
21
import com.gwtext.client.core.Ext;
25
import com.gwtext.client.core.ExtElement;
22
import com.gwtext.client.core.ListenerConfig;
26
import com.gwtext.client.core.ListenerConfig;
23
import com.gwtext.client.core.Position;
27
import com.gwtext.client.core.Position;
Line 32... Line 36...
32
import com.gwtext.client.widgets.Button;
36
import com.gwtext.client.widgets.Button;
33
import com.gwtext.client.widgets.Component;
37
import com.gwtext.client.widgets.Component;
34
import com.gwtext.client.widgets.Container;
38
import com.gwtext.client.widgets.Container;
35
import com.gwtext.client.widgets.DatePicker;
39
import com.gwtext.client.widgets.DatePicker;
36
import com.gwtext.client.widgets.Panel;
40
import com.gwtext.client.widgets.Panel;
-
 
41
import com.gwtext.client.widgets.ToolTip;
37
import com.gwtext.client.widgets.Toolbar;
42
import com.gwtext.client.widgets.Toolbar;
38
import com.gwtext.client.widgets.Viewport;
43
import com.gwtext.client.widgets.Viewport;
39
import com.gwtext.client.widgets.event.BoxComponentListenerAdapter;
44
import com.gwtext.client.widgets.event.BoxComponentListenerAdapter;
40
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
45
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
41
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
46
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
Line 44... Line 49...
44
import com.gwtext.client.widgets.event.PanelListenerAdapter;
49
import com.gwtext.client.widgets.event.PanelListenerAdapter;
45
import com.gwtext.client.widgets.form.ComboBox;
50
import com.gwtext.client.widgets.form.ComboBox;
46
import com.gwtext.client.widgets.form.DateField;
51
import com.gwtext.client.widgets.form.DateField;
47
import com.gwtext.client.widgets.form.Field;
52
import com.gwtext.client.widgets.form.Field;
48
import com.gwtext.client.widgets.form.FormPanel;
53
import com.gwtext.client.widgets.form.FormPanel;
-
 
54
import com.gwtext.client.widgets.form.MultiFieldPanel;
49
import com.gwtext.client.widgets.form.TextArea;
55
import com.gwtext.client.widgets.form.TextArea;
50
import com.gwtext.client.widgets.form.TextField;
56
import com.gwtext.client.widgets.form.TextField;
51
import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter;
57
import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter;
-
 
58
import com.gwtext.client.widgets.form.event.TextFieldListenerAdapter;
52
import com.gwtext.client.widgets.layout.AnchorLayoutData;
59
import com.gwtext.client.widgets.layout.AnchorLayoutData;
53
import com.gwtext.client.widgets.layout.ColumnLayout;
60
import com.gwtext.client.widgets.layout.ColumnLayout;
54
import com.gwtext.client.widgets.layout.ColumnLayoutData;
61
import com.gwtext.client.widgets.layout.ColumnLayoutData;
55
import com.gwtext.client.widgets.layout.FormLayout;
62
import com.gwtext.client.widgets.layout.FormLayout;
56
import com.gwtext.client.widgets.layout.RowLayout;
63
import com.gwtext.client.widgets.layout.RowLayout;
Line 175... Line 182...
175
	private Panel panneauPremierColonne;
182
	private Panel panneauPremierColonne;
Line 176... Line 183...
176
 
183
 
Line 177... Line 184...
177
	private Panel panneauSecondeColonne;
184
	private Panel panneauSecondeColonne;
-
 
185
 
-
 
186
	private boolean masseModification =false ;
-
 
187
 
-
 
188
	private TextField longitude;
-
 
189
 
-
 
190
	private TextField latitude;
-
 
191
 
-
 
192
	private MultiFieldPanel coordPanel;
-
 
193
 
-
 
194
	private TextField coordonnees;
-
 
195
 
-
 
196
	private HTML accesformulaire;
-
 
197
 
-
 
198
	private HTML basculerverscarto;
Line 178... Line 199...
178
 
199
	
179
	private boolean masseModification =false ;
200
	private boolean longlatAjoutee;
180
	
201
	
181
	/**
202
	/**
Line 244... Line 265...
244
		commune.setItemSelector("div.search-item-commune");
265
		commune.setItemSelector("div.search-item-commune");
245
		commune.setTypeAhead(true);  
266
		commune.setTypeAhead(true);  
246
		commune.setLoadingText("Recherche...");  
267
		commune.setLoadingText("Recherche...");  
Line 247... Line 268...
247
		  
268
		  
248
		commune.setHideTrigger(true);
269
		commune.setHideTrigger(true);
Line 249... Line 270...
249
		commune.setTabIndex(1);
270
		//commune.setTabIndex(1);
Line 250... Line 271...
250
		
271
		
251
	    panneauPremierColonne.add(commune, new AnchorLayoutData("95%"));  
272
	    panneauPremierColonne.add(commune, new AnchorLayoutData("95%"));  
252
 
273
 
253
	    station = new TextField("Station", "station");  
274
	    station = new TextField("Station", "station");  
Line -... Line 275...
-
 
275
	    station.setAllowBlank(true);
-
 
276
	    //station.setTabIndex(3);
-
 
277
	    panneauPremierColonne.add(station, new AnchorLayoutData("95%"));  
-
 
278
	    
-
 
279
	    longitude = new TextField("X", "x", 100);
-
 
280
		longitude.setAllowBlank(true);
-
 
281
		
-
 
282
		latitude = new TextField("Y", "y", 100);
-
 
283
		latitude.setAllowBlank(true);
-
 
284
	
-
 
285
		// Panneau de type plusieurs champs de formulaire sur une meme ligne, où seront renseignés X/Y
-
 
286
		coordPanel = new MultiFieldPanel(); 
-
 
287
		coordPanel.setVisible(false);
-
 
288
		coordPanel.addToRow(longitude, new ColumnLayoutData(0.5));  
-
 
289
		coordPanel.addToRow(latitude, new ColumnLayoutData(0.5)); 
-
 
290
		coordPanel.setBorder(false);
-
 
291
		
-
 
292
		  //création du champs coordonnées
-
 
293
		
-
 
294
		coordonnees = new TextField("Coordonnées", "", 0);
-
 
295
		coordonnees.setMaxLength(0);
-
 
296
		coordonnees.setReadOnly(true);
-
 
297
		coordonnees.setCls("fieldname");
-
 
298
		
-
 
299
		  //création du lien "saisie X/Y" dans le formulaire
-
 
300
		
-
 
301
		accesformulaire = new HTML("<a id=\"lien_coord\" href=\"#\" tabindex=\"7\">Saisie X/Y</a>");
-
 
302
		accesformulaire.addStyleName("lien");
-
 
303
			
-
 
304
		//création info bulle sur le lien "saisie X/Y"
-
 
305
			ToolTip tip1 = new ToolTip();  
-
 
306
			tip1.setHtml("X / Y sont les longitudes / latitudes, à remplir en degrés décimaux");  
-
 
307
			tip1.applyTo(accesformulaire.getElement());
-
 
308
			
-
 
309
			//ajout d'un listener sur le lien "saisie X/Y"
-
 
310
			
-
 
311
			coordPanel.addListener(new PanelListenerAdapter() {
-
 
312
				
-
 
313
				public void onAfterLayout(Container c) {
-
 
314
					ExtElement lienCoord = Ext.get("lien_coord");
-
 
315
					lienCoord.removeAllListeners();
-
 
316
					lienCoord.addListener("click", new EventCallback() {
-
 
317
						public void execute(EventObject e) {
-
 
318
							coordPanel.setVisible(!coordPanel.isVisible());
-
 
319
						}
-
 
320
					}) ;
-
 
321
				
-
 
322
					ExtElement lienCarto = Ext.get("lien_carto");
-
 
323
					lienCarto.removeAllListeners();
-
 
324
					lienCarto.addListener("click", new EventCallback() {
-
 
325
 
-
 
326
						public void execute(EventObject e) {
-
 
327
							
-
 
328
							if(coordonneesValides() == null) {
-
 
329
								if(commune.getValue() != null && !commune.getValue().equals("")) {
-
 
330
									obtenirInformationCommune();
-
 
331
									longlatAjoutee = true;
-
 
332
						
-
 
333
								} else {
-
 
334
									Window.alert("Veuillez renseigner au moins une commune ou des coordonnées pour la géolocalisation");
-
 
335
								}
-
 
336
							} else {
-
 
337
								obtenirInformationCoord();
-
 
338
							}
-
 
339
						}
-
 
340
					});
-
 
341
				}
-
 
342
 
-
 
343
			});
-
 
344
			
-
 
345
			
-
 
346
			  //création du lien "Accès carto" dans le formulaire			
-
 
347
			basculerverscarto = new HTML(" <a id=\"lien_carto\" href=\"#\" tabindex=\"6\">Selection depuis la carto</a>");
-
 
348
			basculerverscarto.addStyleName("lien");
-
 
349
			
-
 
350
			//création info bulle sur le lien "accès carto"
-
 
351
			ToolTip tip2 = new ToolTip();  
-
 
352
			tip2.setHtml("Via une carte, obtenez les coordonnées (longitude/latitude) de votre observation ");  
-
 
353
			tip2.applyTo(basculerverscarto.getElement());
-
 
354
			
-
 
355
			//Sur une meme ligne, ajout de plusieurs champs
-
 
356
			final MultiFieldPanel htmlPanel = new MultiFieldPanel();  
-
 
357
			htmlPanel.addToRow(coordonnees, 100); 
-
 
358
			htmlPanel.addToRow(basculerverscarto, new ColumnLayoutData(0.5)); 
-
 
359
			htmlPanel.addToRow(accesformulaire, new ColumnLayoutData(0.5)); 
-
 
360
			htmlPanel.setBorder(false);
-
 
361
			htmlPanel.setId("x-coord-panel");
254
	    station.setAllowBlank(true);
362
			
255
	    station.setTabIndex(3);
363
		panneauPremierColonne.add(htmlPanel);
256
	    panneauPremierColonne.add(station, new AnchorLayoutData("95%"));  
364
		panneauPremierColonne.add(coordPanel);
257
	    
365
	    
258
	    date = new DateField("Date", "date", 100);  
366
	    date = new DateField("Date", "date", 100);  
259
	    date.setAllowBlank(true);
367
	    date.setAllowBlank(true);
Line 260... Line 368...
260
	    formatDate = "d/m/Y";
368
	    formatDate = "d/m/Y";
Line 275... Line 383...
275
		espece.setItemSelector("div.search-item-espece");
383
		espece.setItemSelector("div.search-item-espece");
276
		espece.setTypeAhead(true);  
384
		espece.setTypeAhead(true);  
277
		espece.setLoadingText("Recherche...");  
385
		espece.setLoadingText("Recherche...");  
Line 278... Line 386...
278
		  
386
		  
279
		espece.setHideTrigger(true);
387
		espece.setHideTrigger(true);
Line 280... Line 388...
280
		espece.setTabIndex(6);
388
		//espece.setTabIndex(6);
Line 281... Line 389...
281
 
389
 
282
	    panneauPremierColonne.add(espece, new AnchorLayoutData("95%"));   
390
	    panneauPremierColonne.add(espece, new AnchorLayoutData("95%"));   
283
	    
391
	    
284
	    lieudit = new TextField("Lieu-dit", "lieudit");  
392
	    lieudit = new TextField("Lieu-dit", "lieudit");  
Line 285... Line 393...
285
	    lieudit.setAllowBlank(true);
393
	    lieudit.setAllowBlank(true);
286
	    lieudit.setTabIndex(2);
394
	    //lieudit.setTabIndex(2);
287
	    panneauSecondeColonne.add(lieudit,  new AnchorLayoutData("95%"));  
395
	    panneauSecondeColonne.add(lieudit,  new AnchorLayoutData("95%"));  
288
	       
396
	       
Line 289... Line 397...
289
	
397
	
290
	    milieu = new TextField("Milieu", "milieu");  
398
	    milieu = new TextField("Milieu", "milieu");  
291
	    milieu.setAllowBlank(true);
399
	    milieu.setAllowBlank(true);
292
	    milieu.setTabIndex(4);
400
	    //milieu.setTabIndex(4);
293
	    panneauSecondeColonne.add(milieu,  new AnchorLayoutData("95%"));
401
	    panneauSecondeColonne.add(milieu,  new AnchorLayoutData("95%"));
Line 374... Line 482...
374
		// on ajoute les listeners
482
		// on ajoute les listeners
Line 375... Line 483...
375
		
483
		
Line -... Line 484...
-
 
484
		
-
 
485
		ajouterListeners() ;
376
		
486
		
Line 377... Line 487...
377
		ajouterListeners() ;
487
		saisieTabindex();
378
		
488
		
379
	}
489
	}
Line 801... Line 911...
801
					
911
					
802
					Store store=new Store(dataProxy,reader);
912
					Store store=new Store(dataProxy,reader);
Line 803... Line 913...
803
					store.load() ;
913
					store.load() ;
-
 
914
		
804
		
915
					commune.setStore(store);
Line 805... Line 916...
805
					commune.setStore(store);
916
					commune.expand();
Line 806... Line 917...
806
			}
917
			}
Line 871... Line 982...
871
				String[] anumNom = (String[])nouvelleDonnees ;
982
				String[] anumNom = (String[])nouvelleDonnees ;
872
				numeroNom = anumNom[1];
983
				numeroNom = anumNom[1];
873
				espece.setValue(anumNom[0]);
984
				espece.setValue(anumNom[0]);
874
				setModification("false");
985
				setModification("false");
875
			}
986
			}
-
 
987
			
-
 
988
			if(nouvelleDonnees instanceof EntiteGeographiqueObservation)
-
 
989
			{
-
 
990
				EntiteGeographiqueObservation infosComm = (EntiteGeographiqueObservation)nouvelleDonnees ;
-
 
991
				rafraichirCommuneEtCoord(infosComm);
-
 
992
			}
-
 
993
 
-
 
994
	}
-
 
995
	
-
 
996
	
-
 
997
	private void rafraichirCommuneEtCoord(EntiteGeographiqueObservation infosCom) {
-
 
998
		
-
 
999
		String nCommune = "";
-
 
1000
 
-
 
1001
		
-
 
1002
		if(infosCom.getLocation() != null && !infosCom.getLocation().equals("")) {
-
 
1003
			nCommune += infosCom.getLocation();
-
 
1004
		}
-
 
1005
		
-
 
1006
		if(infosCom.getIdLocation() != null && !infosCom.getIdLocation().equals("")) {
-
 
1007
			nCommune += " ("+infosCom.getIdLocation()+")";
-
 
1008
			departement = infosCom.getIdLocation();
-
 
1009
		}
-
 
1010
		
-
 
1011
		commune.setValue(nCommune);
-
 
1012
 
-
 
1013
		if(infosCom.getLat() != null && !infosCom.getLat().equals("")) {
-
 
1014
			latitude.setValue(infosCom.getLat());
-
 
1015
		}
Line -... Line 1016...
-
 
1016
 
-
 
1017
		if(infosCom.getLon() != null && !infosCom.getLon().equals("")) {
-
 
1018
			longitude.setValue(infosCom.getLon());
876
 
1019
		}
-
 
1020
	}
877
	}
1021
 
Line 878... Line 1022...
878
	public void obtenirListeReferentielCommune() {
1022
	public void obtenirListeReferentielCommune() {
879
		
1023
		
Line 880... Line 1024...
880
	 String com=commune.getText().replaceAll(" ","/");
1024
	 String com=commune.getText()/*.replaceAll(" ","/")*/;
Line 881... Line 1025...
881
	 com=com.replaceAll("%","");
1025
	 com=com.replaceAll("%","");
Line 882... Line 1026...
882
		  
1026
		  
Line 883... Line 1027...
883
	 observationMediateur.obtenirListeReferentielCommune(this,com);
1027
	 observationMediateur.obtenirListeReferentielCommune(this,com);
884
	 
1028
	 
Line 885... Line 1029...
885
	}
1029
	}
Line 886... Line 1030...
886
	
1030
	
Line 1181... Line 1325...
1181
				lieudit.reset() ;
1325
				lieudit.reset() ;
1182
				station.reset() ;
1326
				station.reset() ;
1183
				milieu.reset() ;
1327
				milieu.reset() ;
1184
				comment.reset() ;
1328
				comment.reset() ;
1185
				milieu.reset() ;
1329
				milieu.reset() ;
-
 
1330
				latitude.reset();
-
 
1331
				longitude.reset();
1186
				departement ="";
1332
				departement ="";
1187
				espece.reset();
1333
				espece.reset();
1188
				numeroNom = "" ;
1334
				numeroNom = "" ;
1189
				numeroOrdre = "";
1335
				numeroOrdre = "";
1190
				break;
1336
				break;
Line 1312... Line 1458...
1312
		dateModifiee = false;
1458
		dateModifiee = false;
1313
		especeModifiee = false;
1459
		especeModifiee = false;
1314
		commModifie = false;
1460
		commModifie = false;
1315
	}
1461
	}
Line -... Line 1462...
-
 
1462
	
-
 
1463
	public void saisieTabindex()
-
 
1464
	{
-
 
1465
		
-
 
1466
		selecteurMode.setTabIndex(0);
-
 
1467
		commune.setTabIndex(1);
-
 
1468
		lieudit.setTabIndex(2);
-
 
1469
		station.setTabIndex(3);
-
 
1470
		milieu.setTabIndex(4);
-
 
1471
		coordonnees.setTabIndex(-1);
-
 
1472
		coordonnees.addListener(new TextFieldListenerAdapter() {
-
 
1473
 
-
 
1474
			public void onFocus(Field field) {
-
 
1475
				if(coordPanel.isVisible()) {
-
 
1476
					longitude.focus();
-
 
1477
				} else {
-
 
1478
					Ext.get("lien_carto").focus();
-
 
1479
				}
-
 
1480
			}	
-
 
1481
		});
-
 
1482
			
-
 
1483
		longitude.setTabIndex(8);
-
 
1484
		latitude.setTabIndex(9);
-
 
1485
		comment.setTabIndex(10);
-
 
1486
		date.setTabIndex(11);
-
 
1487
		espece.setTabIndex(12);
-
 
1488
		boutonOK.setTabIndex(13);
-
 
1489
		boutonAnnuler.setTabIndex(14);
-
 
1490
		
-
 
1491
	}
-
 
1492
	
-
 
1493
	private void obtenirInformationCoord() {
-
 
1494
		if(coordonneesValides() != null) {
-
 
1495
			observationMediateur.obtenirInformationCoord(LatLng.newInstance(coordonneesValides()[0],coordonneesValides()[1]));
-
 
1496
		} else {
-
 
1497
			Window.alert("Les coordonnées saisies sont invalides");
-
 
1498
		}
-
 
1499
 
-
 
1500
	}
-
 
1501
	
-
 
1502
	private void obtenirInformationCommune() {
-
 
1503
		observationMediateur.obtenirInformationCommune(commune.getValue(), obtenirDepartementAPartirChampCommune());
-
 
1504
	}
-
 
1505
	
-
 
1506
	private double[] coordonneesValides() {
-
 
1507
		
-
 
1508
		try {
-
 
1509
						
-
 
1510
			double lat = Double.parseDouble(latitude.getValueAsString().replaceAll(",", "."));
-
 
1511
			double lon = Double.parseDouble(longitude.getValueAsString().replaceAll(",", "."));
-
 
1512
			
-
 
1513
			double[] coord = {lat, lon};
-
 
1514
			return coord;
-
 
1515
			
-
 
1516
		} catch (NumberFormatException ne) {
-
 
1517
			return null;
-
 
1518
		}
-
 
1519
	}
-
 
1520
	
-
 
1521
	private String obtenirDepartementAPartirChampCommune() {
-
 
1522
		if(departement.equals("000null") || departement.equals("")) {
-
 
1523
			String[] depCom = commune.getText().split(" ");
-
 
1524
			if(depCom.length > 1) {
-
 
1525
				String dep = depCom[1].replace('(', ' ');
-
 
1526
				dep =dep.replace(')', ' ');
-
 
1527
				dep = dep.trim();
-
 
1528
				dep = dep.replace('\\',' ');
-
 
1529
				dep = dep.trim();
-
 
1530
				
-
 
1531
				try
-
 
1532
				{
-
 
1533
					int nDep = Integer.parseInt(dep);
-
 
1534
					if(nDep > 0 && nDep < 110) {
-
 
1535
						departement = dep ;
-
 
1536
					}
-
 
1537
				}
-
 
1538
				catch(NumberFormatException e)
-
 
1539
				{
-
 
1540
					departement = "" ;
-
 
1541
				}
-
 
1542
			}
-
 
1543
		}
-
 
1544
		
-
 
1545
		return departement;
-
 
1546
	}
1316
	
1547
	
1317
	private Field obtenirCorrespondanceChampsEnum(Champs champ) {
1548
	private Field obtenirCorrespondanceChampsEnum(Champs champ) {
1318
		switch(champ) {
1549
		switch(champ) {
1319
    	case DATE:
1550
    	case DATE: