Subversion Repositories eFlore/Applications.cel

Rev

Rev 656 | Rev 708 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 656 Rev 681
Line 203... Line 203...
203
 
203
 
Line 204... Line 204...
204
	private TextField longitude;
204
	private TextField longitude;
Line -... Line 205...
-
 
205
 
-
 
206
	private TextField latitude;
205
 
207
	
Line 206... Line 208...
206
	private TextField latitude;
208
	private MultiFieldPanel htmlCommunePanel = null;
Line 207... Line 209...
207
 
209
 
Line 208... Line 210...
208
	private MultiFieldPanel coordPanel;
210
	private MultiFieldPanel coordPanel;
Line 209... Line 211...
209
 
211
 
Line 210... Line 212...
210
	private TextField coordonnees;
212
	private TextField coordonnees;
Line 284... Line 286...
284
		commune.setMode(ComboBox.REMOTE);
286
		commune.setMode(ComboBox.REMOTE);
285
		// commune.setPageSize(10); // Ne fonctionne pas 
287
		// commune.setPageSize(10); // Ne fonctionne pas 
286
		commune.setItemSelector("div.search-item-commune");
288
		commune.setItemSelector("div.search-item-commune");
287
		commune.setTypeAhead(true);  
289
		commune.setTypeAhead(true);  
288
		commune.setLoadingText("Recherche...");  
290
		commune.setLoadingText("Recherche...");  
289
		  
-
 
290
		commune.setHideTrigger(true);
291
		commune.setHideTrigger(true);
291
		//commune.setTabIndex(1);
292
		//commune.setTabIndex(1);
Line 292... Line 293...
292
		
293
		
293
		  //création du lien "Accès carto" dans le formulaire	
294
		  //création du lien "Accès carto" dans le formulaire	
294
		basculerverscarto = new HTML(" <a id=\"lien_carto\" href=\"#\" tabindex=\"2\">Localiser</a>");
295
		basculerverscarto = new HTML(" <a id=\"lien_carto\" href=\"#\" tabindex=\"2\">Localiser la commune</a>");
Line 295... Line 296...
295
		basculerverscarto.addStyleName("lien_actif");
296
		basculerverscarto.addStyleName("lien_actif");
296
		
297
		
297
		//création info bulle sur le lien "accès carto"
298
		//création info bulle sur le lien "accès carto"
298
		ToolTip tip2 = new ToolTip();  
299
		ToolTip tip2 = new ToolTip();  
Line 299... Line 300...
299
		tip2.setHtml("Via une carte, obtenez les coordonnées (latitude/longitude) de votre observation ");  
300
		tip2.setHtml("Via une carte, obtenez les coordonnées (latitude/longitude) de votre observation ");  
300
		tip2.applyTo(basculerverscarto.getElement());
301
		tip2.applyTo(basculerverscarto.getElement());
Line -... Line 302...
-
 
302
		
301
		
303
		//Sur une meme ligne, ajout de plusieurs champs
302
		//Sur une meme ligne, ajout de plusieurs champs
304
		htmlCommunePanel = new MultiFieldPanel(); 
Line 303... Line 305...
303
		final MultiFieldPanel htmlCommunePanel = new MultiFieldPanel(); 
305
		
304
		
306
		int largeurCommune = Window.getClientWidth()/4; 
Line 305... Line 307...
305
		htmlCommunePanel.addToRow(commune,new ColumnLayoutData(0.7)); 
307
		htmlCommunePanel.addToRow(commune, largeurCommune); 
Line 351... Line 353...
351
		coordonnees.setMaxLength(0);
353
		coordonnees.setMaxLength(0);
352
		coordonnees.setReadOnly(true);
354
		coordonnees.setReadOnly(true);
353
		coordonnees.setCls("fieldname");
355
		coordonnees.setCls("fieldname");
Line 354... Line 356...
354
		
356
		
355
		//création du lien "saisie X/Y" dans le formulaire
357
		//création du lien "saisie X/Y" dans le formulaire
356
		accesformulaire = new HTML("<a id=\"lien_coord\" href=\"#\" tabindex=\"6\">Saisie Lat/Lon ("+referentielGeo+")</a>");
-
 
357
		accesformulaire.setWidth("100%");
358
		afficherFormulaireLatLon = new HTML("<span style=\"padding-left:30px;\" class=\"conteneur_lien_afficher_lat_lon\">" +
358
		accesformulaire.addStyleName("lien_actif");
-
 
359
			
359
				"<a title=\"Lat / Lon sont les latitudes / longitudes, à remplir en degrés décimaux\" class=\"lien_actif\" id=\"lien_coord\" href=\"#\" tabindex=\"6\">Saisie Lat/Lon ("+referentielGeo+")</a>" +
360
		//création info bulle sur le lien "saisie X/Y"
-
 
361
			ToolTip tip1 = new ToolTip();  
360
				"<span><span style=\"padding-left:20px\" class=\"conteneur_lien_localiser_lat_lon\">"+
362
			tip1.setHtml("Lat / Lon sont les latitudes / longitudes, à remplir en degrés décimaux");  
361
				"<a title=\"Cliquez pour obtenir les coordonnées de votre observation à partir de la carte\" class=\"lien_actif\" id=\"lien_carto_coord\" href=\"#\" tabindex=\"7\">Localiser sur la carte</a>"+
Line 363... Line 362...
363
			tip1.applyTo(accesformulaire.getElement());
362
				"</span>");
Line 364... Line 363...
364
			
363
						
Line 365... Line 364...
365
			//ajout d'un listener sur le lien "saisie X/Y"
364
			//ajout d'un listener sur le lien "saisie X/Y"
-
 
365
			
366
			
366
			coordPanel.addListener(new PanelListenerAdapter() {
367
			coordPanel.addListener(new PanelListenerAdapter() {
367
				
368
				
368
				public void onAfterLayout(Container c) {
369
				public void onAfterLayout(Container c) {
369
					
Line 380... Line 380...
380
							
380
							
381
							CarnetEnLigneMediateur.fireResize();
381
							CarnetEnLigneMediateur.fireResize();
382
						}
382
						}
Line -... Line 383...
-
 
383
					}) ;
-
 
384
					
-
 
385
					ExtElement lienCartoCoord = Ext.get("lien_carto_coord");
-
 
386
					lienCartoCoord.removeAllListeners();
-
 
387
					lienCartoCoord.addListener("click", new EventCallback() {
-
 
388
						public void execute(EventObject e) {
-
 
389
							obtenirInformationCoord();
-
 
390
						}
383
					}) ;
391
					}) ;
384
				
392
				
385
					ExtElement lienCarto = Ext.get("lien_carto");
393
					ExtElement lienCarto = Ext.get("lien_carto");
Line 386... Line 394...
386
					lienCarto.removeAllListeners();
394
					lienCarto.removeAllListeners();
Line 403... Line 411...
403
						int largeurN = (int)largeur;
411
						int largeurN = (int)largeur;
Line 404... Line 412...
404
						
412
						
405
						latitude.setWidth(largeurN+"px");
413
						latitude.setWidth(largeurN+"px");
406
						longitude.setWidth(largeurN+"px");
414
						longitude.setWidth(largeurN+"px");
407
						lienSelectionCommune.setWidth(largeurN+"px");
-
 
408
						
415
						lienSelectionCommune.setWidth(largeurN+"px");						
409
					}
416
					}
410
				}
417
				}
Line 411... Line 418...
411
			});
418
			});
412
						
419
						
Line 413... Line 420...
413
		//Sur une meme ligne, ajout de plusieurs champs
420
		//Sur une meme ligne, ajout de plusieurs champs
414
		final MultiFieldPanel htmlPanel = new MultiFieldPanel();  
421
		final MultiFieldPanel htmlPanel = new MultiFieldPanel();  
415
		
422
		
416
		htmlPanel.addToRow(coordonnees, 100); 
423
		htmlPanel.addToRow(coordonnees, 100); 
Line 417... Line 424...
417
		htmlPanel.addToRow(accesformulaire, new ColumnLayoutData(0.5)); 
424
		htmlPanel.addToRow(afficherFormulaireLatLon, new ColumnLayoutData(0.9)); 
418
		htmlPanel.setBorder(false);
425
		htmlPanel.setBorder(false);
Line 419... Line 426...
419
		htmlPanel.setId("x-coord-panel");
426
		htmlPanel.setId("x-coord-panel");
420
			
427
			
421
		panneauPremierColonne.add(htmlPanel);
428
		panneauPremierColonne.add(htmlPanel);
422
		panneauPremierColonne.add(coordPanel);
429
		panneauPremierColonne.add(coordPanel);
-
 
430
	    
423
	    
431
	    date = new DateField("Date", "date", 200);  
424
	    date = new DateField("Date", "date", 100);  
432
	    date.setAllowBlank(true);
Line 425... Line 433...
425
	    date.setAllowBlank(true);
433
	    formatDate = "d/m/Y";
Line 426... Line 434...
426
	    formatDate = "d/m/Y";
434
	    date.setFormat(formatDate) ;
Line 1148... Line 1156...
1148
		String nCommune = "";
1156
		String nCommune = "";
1149
		if(infosCom != null && !infosCom.getCommune().trim().equals("")){
1157
		if(infosCom != null && !infosCom.getCommune().trim().equals("")){
1150
			nCommune += infosCom.getCommune();
1158
			nCommune += infosCom.getCommune();
1151
			if(!infosCom.getIdLocalite().trim().equals(""))
1159
			if(!infosCom.getIdLocalite().trim().equals(""))
1152
			nCommune += " ("+infosCom.getIdLocalite()+")";
1160
			nCommune += " ("+infosCom.getIdLocalite()+")";
1153
		}
1161
			
1154
		lienSelectionCommune.setHtml("<a id=\"lien_selection_commune\" tabindex=\"9\">"+nCommune+"</a>");
1162
			lienSelectionCommune.setHtml("<a id=\"lien_selection_commune\" tabindex=\"9\">"+nCommune+"</a>");
1155
		lienSelectionCommune.setStyleName("img-curseur-depl");
1163
			lienSelectionCommune.setStyleName("img-curseur-depl");
Line 1156... Line 1164...
1156
		
1164
			
1157
		Ext.get("lien_selection_commune").addListener("click",new EventCallback() {
1165
			Ext.get("lien_selection_commune").addListener("click",new EventCallback() {
Line 1178... Line 1186...
1178
			public void execute(EventObject e) {
1186
				public void execute(EventObject e) {
1179
				Ext.get("lien_selection_commune").toggleClass("lien_sel");
1187
					Ext.get("lien_selection_commune").toggleClass("lien_sel");
1180
			}			
1188
				}			
1181
		});
1189
			});
Line -... Line 1190...
-
 
1190
			
-
 
1191
		} else {
-
 
1192
			if(rechercheCommuneEnCours) {
-
 
1193
				lienSelectionCommune.setHtml("<span id=\"aucune_selection_commune\"> Erreur de localisation </span>");
-
 
1194
			} else {
-
 
1195
				lienSelectionCommune.setHtml("<span id=\"aucune_selection_commune\"> </span>");
-
 
1196
			}
-
 
1197
		}
1182
 
1198
 
1183
		Ext.get(lienSelectionCommune.getElement()).unmask();
1199
		Ext.get(lienSelectionCommune.getElement()).unmask();
1184
		rechercheCommuneEnCours = false;
1200
		rechercheCommuneEnCours = false;
Line 1185... Line 1201...
1185
	}
1201
	}
Line 1243... Line 1259...
1243
	}
1259
	}
Line 1244... Line 1260...
1244
   
1260
   
Line -... Line 1261...
-
 
1261
 
-
 
1262
	public void ajouterObservation() {
-
 
1263
		
-
 
1264
		if(!Util.verifierDateFormatCel(date.getRawValue()) && !date.getRawValue().equals("")) {
-
 
1265
			Window.alert("Attention la date saisie est invalide, la date doit être au format jj/mm/aaaa");
-
 
1266
			date.setInvalidText("Date invalide");
1245
 
1267
			return;
1246
	public void ajouterObservation() {
1268
		}
Line 1247... Line 1269...
1247
		
1269
		
1248
		if(departement != null) {  
1270
		if(departement != null) {  
Line 1270... Line 1292...
1270
					}
1292
					}
1271
				}
1293
				}
1272
			}
1294
			}
1273
		}
1295
		}
Line -... Line 1296...
-
 
1296
		
-
 
1297
		String dateObs = Util.remplacerSeparateursDateFormatCel(date.getRawValue());
1274
 
1298
 
Line 1275... Line 1299...
1275
		Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),date.getRawValue());	
1299
		Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),dateObs);	
Line 1276... Line 1300...
1276
		
1300
		
1277
		String[] coords = getValeurCoordonnees();
1301
		String[] coords = getValeurCoordonnees();
Line 1282... Line 1306...
1282
		observationMediateur.ajouterObservation(obs);
1306
		observationMediateur.ajouterObservation(obs);
1283
	}
1307
	}
Line 1284... Line 1308...
1284
	
1308
	
Line -... Line 1309...
-
 
1309
	private void modifierObservation() {
-
 
1310
		
-
 
1311
		if(!Util.verifierDateFormatCel(date.getRawValue()) && !date.getRawValue().equals("")) {
-
 
1312
			Window.alert("Attention la date saisie est invalide, la date doit être au format jj/mm/aaaa");
-
 
1313
			date.setInvalidText("Date invalide");
-
 
1314
			return;
1285
	private void modifierObservation() {
1315
		}
1286
		
1316
		
1287
		if(departement.equals("000null") || departement.equals("")) {
1317
		if(departement.equals("000null") || departement.equals("")) {
1288
			String[] depCom = commune.getText().split(" ");
1318
			String[] depCom = commune.getText().split(" ");
1289
			if(depCom.length > 1) {
1319
			if(depCom.length > 1) {
Line 1305... Line 1335...
1305
					departement = "" ;
1335
					departement = "" ;
1306
				}
1336
				}
1307
			}
1337
			}
1308
		}
1338
		}
Line -... Line 1339...
-
 
1339
		
-
 
1340
		String dateObs = Util.remplacerSeparateursDateFormatCel(date.getRawValue());
1309
		
1341
		
1310
		Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),date.getRawValue());
1342
		Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),dateObs);
Line 1311... Line 1343...
1311
		obs.setNumeroOrdre(numeroOrdre);
1343
		obs.setNumeroOrdre(numeroOrdre);
Line 1312... Line 1344...
1312
		
1344
		
Line 1386... Line 1418...
1386
			champs = champs.replaceAll(":milieu", "");
1418
			champs = champs.replaceAll(":milieu", "");
1387
		}
1419
		}
Line 1388... Line 1420...
1388
 
1420
 
1389
		if(dateModifiee && !date.getRawValue().equals(VALEURS_MULTIPLES)) {
1421
		if(dateModifiee && !date.getRawValue().equals(VALEURS_MULTIPLES)) {
-
 
1422
			dateM = date.getRawValue();
1390
			dateM = date.getRawValue();
1423
			dateM = Util.remplacerSeparateursDateFormatCel(dateM);
1391
		}else {
1424
		}else {
1392
			champs = champs.replaceAll(":date", "");
1425
			champs = champs.replaceAll(":date", "");
Line 1393... Line 1426...
1393
		}
1426
		}
Line 1479... Line 1512...
1479
		if(!obs.getMilieu().equals("null") && !obs.getMilieu().equals("000null")) {
1512
		if(!obs.getMilieu().equals("null") && !obs.getMilieu().equals("000null")) {
1480
			milieu.setValue(obs.getMilieu()) ;
1513
			milieu.setValue(obs.getMilieu()) ;
1481
		}
1514
		}
1482
		if(!obs.getCommentaire().equals("null") && !obs.getCommentaire().equals("000null")) {
1515
		if(!obs.getCommentaire().equals("null") && !obs.getCommentaire().equals("000null")) {
Line 1483... Line 1516...
1483
 
1516
 
Line 1484... Line 1517...
1484
			comment.setRawValue(remplacerSautsDeligneMalEncodes(obs.getCommentaire()));
1517
			comment.setRawValue(Util.remplacerSautsDeligneMalEncodes(obs.getCommentaire()));
1485
			
1518
			
1486
		}
1519
		}
1487
		if(!obs.getLocalite().equals("null") && !obs.getLocalite().equals("000null")) {
1520
		if(!obs.getLocalite().equals("null") && !obs.getLocalite().equals("000null")) {
Line 1739... Line 1772...
1739
					Ext.get("lien_carto").focus();
1772
					Ext.get("lien_carto").focus();
1740
				}
1773
				}
1741
			}	
1774
			}	
1742
		});
1775
		});
Line 1743... Line 1776...
1743
			
1776
			
1744
		latitude.setTabIndex(7);
1777
		latitude.setTabIndex(8);
1745
		longitude.setTabIndex(8);
1778
		longitude.setTabIndex(9);
1746
		comment.setTabIndex(10);
1779
		comment.setTabIndex(10);
1747
		date.setTabIndex(11);
1780
		date.setTabIndex(11);
1748
		espece.setTabIndex(12);
1781
		espece.setTabIndex(12);
1749
		boutonOK.setTabIndex(13);
1782
		boutonOK.setTabIndex(13);
Line 1753... Line 1786...
1753
	
1786
	
1754
	private void obtenirInformationCoord() {
1787
	private void obtenirInformationCoord() {
1755
		if(coordonneesValides() != null) {
1788
		if(coordonneesValides() != null) {
1756
			observationMediateur.obtenirInformationCoord(LatLng.newInstance(coordonneesValides()[0],coordonneesValides()[1]));
1789
			observationMediateur.obtenirInformationCoord(LatLng.newInstance(coordonneesValides()[0],coordonneesValides()[1]));
1757
		} else {
1790
		} else {
1758
			Window.alert("Les coordonnées saisies sont invalides");
1791
			observationMediateur.afficherFenetreCarto();
Line 1759... Line 1792...
1759
		}
1792
		}
Line 1760... Line 1793...
1760
 
1793
 
Line 1857... Line 1890...
1857
		return communeModifiee;
1890
		return communeModifiee;
1858
	}
1891
	}
Line 1859... Line 1892...
1859
	
1892
	
1860
	public void redimensionnerFormulaire() {
1893
	public void redimensionnerFormulaire() {
1861
		doLayout();
-
 
1862
		//panneauIntermediaire.doLayout();
-
 
1863
	}
-
 
1864
	
1894
		doLayout();
1865
	public String remplacerSautsDeligneMalEncodes(String chaineAvecSautsDeLignesMalEncodes) {
-
 
1866
		
1895
		//htmlCommunePanel.setWidth(panneauPremierColonne.getWidth() - 10);
1867
		String chaineAvecSautsDeLignesBienEncodes = chaineAvecSautsDeLignesMalEncodes.replace('\\','%');
1896
		afficherFormulaireLatLon.setWidth(panneauIntermediaire.getWidth()+"px");
1868
		chaineAvecSautsDeLignesBienEncodes = chaineAvecSautsDeLignesBienEncodes.replaceAll("%n","%");
1897
		panneauPremierColonne.doLayout();
1869
		chaineAvecSautsDeLignesBienEncodes = chaineAvecSautsDeLignesBienEncodes.replace('%','\n');
-
 
1870
		
1898
		panneauSecondeColonne.doLayout();
1871
		return chaineAvecSautsDeLignesBienEncodes;
1899
		panneauIntermediaire.doLayout();
1872
	}
1900
	}