Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 2567 → Rev 2568

/trunk/src/org/tela_botanica/client/vues/observation/CartographieObservationVue.java
43,10 → 43,11
private boolean carteAjoutee = false;
private boolean infoOuverte = false;
 
String valeurCommune = "Bourges"; // j'aurais préféré Bort-les-Orgues
String valeurLocalite = "Bourges"; // j'aurais préféré Bort-les-Orgues
LatLng centreFrance = null;
LatLng pointCommune = null;
LatLng pointLocalite = null;
String codeLoc = "";
String pays = "";
 
int niveauZoom = 6;
 
89,7 → 90,7
if(panneauCarto.isVisible()) {
if(masquer) {
panneauCarto.getEl().mask("Recherche des coordonnées et de la commune, veuillez patienter");
panneauCarto.getEl().mask("Recherche des coordonnées et de la localite, veuillez patienter");
} else {
panneauCarto.getEl().unmask();
}
96,21 → 97,22
}
}
public void obtenirInfosCommunes(LatLng coord) {
public void obtenirInfosLocalites(LatLng coord) {
// Remise à zéro des infos restantes d'une ancienne requete
valeurCommune = "";
valeurLocalite = "";
codeLoc = "";
pays = "";
oMediateur.obtenirInformationCoord(this, coord.lat(), coord.lng());
}
 
public void mettreAJourInfos(final LatLng pointNouvelleCommune, int zoom) {
public void mettreAJourInfos(final LatLng pointNouvelleLocalite, int zoom) {
GoogleMap mapNulle = null;
if(nmk != null) {
nmk.setMap(mapNulle);
}
pointCommune = pointNouvelleCommune;
nmk = fabriquerMarqueur(pointCommune);
pointLocalite = pointNouvelleLocalite;
nmk = fabriquerMarqueur(pointLocalite);
nmk.setMap(map);
afficherInfoMarker(nmk, construireContenuInfoMarker(nmk));
recentrerCarte(nmk.getPosition());
117,12 → 119,12
map.setZoom(zoom);
}
 
private void initialiserCarte(boolean commune) {
private void initialiserCarte(boolean localite) {
 
panneauCarto.clear();
 
centreFrance = LatLng.create(47.0504, 2.2347);
pointCommune = centreFrance;
pointLocalite = centreFrance;
 
MapOptions options = MapOptions.create();
options.setCenter(centreFrance);
145,7 → 147,7
}
});
if(!commune) {
if(!localite) {
fabriquerMarqueurIndication();
}
152,7 → 154,7
map.addClickListener(new ClickHandler() {
@Override
public void handle(MouseEvent event) {
obtenirInfosCommunes(event.getLatLng());
obtenirInfosLocalites(event.getLatLng());
}
});
175,10 → 177,10
if(nmk != null) {
nmk.setMap(mapNulle);
}
nmk = fabriquerMarqueur(pointCommune);
nmk = fabriquerMarqueur(pointLocalite);
nmk.setMap(map);
info.setContent("<div id=\"info_contenu\">"+
"Déplacez ce marqueur pour localiser votre observation (commune et coordonnées)<br />"
"Déplacez ce marqueur pour localiser votre observation (localite et coordonnées)<br />"
+"longitude="
+ Util.tronquerNombrePourAffichage("" + nmk.getPosition().lng(), 5) + "<br />latitude="
+ Util.tronquerNombrePourAffichage("" + nmk.getPosition().lat(), 5) + "</div>");
211,11 → 213,11
bouton.addListener("click", new EventCallback() {
@Override
public void execute(EventObject e) {
EntiteGeographiqueObservation infosCommune = new EntiteGeographiqueObservation(codeLoc,valeurCommune,null,null);
// TODO: ajouter pays à tout Ceci
infosCommune.setLat(pointCommune.lat()+"");
infosCommune.setLon(pointCommune.lng()+"");
oMediateur.rafraichirSaisieCommuneObservation(infosCommune);
EntiteGeographiqueObservation infosLocalite = new EntiteGeographiqueObservation(codeLoc,valeurLocalite,null,null);
infosLocalite.setPays(pays);
infosLocalite.setLat(pointLocalite.lat()+"");
infosLocalite.setLon(pointLocalite.lng()+"");
oMediateur.rafraichirSaisieLocaliteObservation(infosLocalite);
}
});
257,10 → 259,11
niveauZoom = infos.getZoom();
}
 
String nouvelleValeurCommune = infos.getZoneGeo();
valeurCommune = nouvelleValeurCommune;
String nouvelleValeurLocalite = infos.getZoneGeo();
valeurLocalite = nouvelleValeurLocalite;
codeLoc = "";
if(infos.getIdZoneGeo() != null) {
// Quoi stocker pour en dehors de la france ?
if (infos.getPays().equals("FR")) {
codeLoc = Util.convertirChaineZoneGeoVersDepartement(infos.getIdZoneGeo());
} else {
267,7 → 270,8
codeLoc = infos.getPays();
}
}
pointCommune = coord;
pays = infos.getPays();
pointLocalite = coord;
mettreAJourInfos(coord, niveauZoom);
}
287,7 → 291,7
@Override
public void handle(MouseEvent event) {
afficherInfoMarker(marker, construireContenuPartielInfoMarker(marker));
obtenirInfosCommunes(event.getLatLng());
obtenirInfosLocalites(event.getLatLng());
}
});
342,7 → 346,7
 
String contenuMarker = "";
if(valeurCommune == null || valeurCommune.trim().equals("")) {
if(valeurLocalite == null || valeurLocalite.trim().equals("")) {
if(marker.getPosition().lng() == 0 && marker.getPosition().lat() == 0) {
LatLng point = centreFrance;
marker.setPosition(point);
356,10 → 360,10
+"latitude="+Util.tronquerNombrePourAffichage(""+marker.getPosition().lat(), 5)+
"</div>";
} else {
String chaineCommune = valeurCommune + ((codeLoc.isEmpty()) ? "" : " ("+codeLoc+")");
String chaineLocalite = valeurLocalite + ((codeLoc.isEmpty()) ? "" : " ("+codeLoc+")");
contenuMarker =
"<div id=\"info_contenu\">"+
chaineCommune+"<br />"
chaineLocalite+"<br />"
+"longitude="+Util.tronquerNombrePourAffichage(""+marker.getPosition().lng(), 5)+"<br />"
+"latitude="+Util.tronquerNombrePourAffichage(""+marker.getPosition().lat(), 5)+
"</div>";
398,7 → 402,7
info.setContent(contenuInfo);
info.open(map, marker);
pointCommune = marker.getPosition();
pointLocalite = marker.getPosition();
info.addDomReadyListenerOnce(new InfoWindow.DomReadyHandler() {
@Override
411,8 → 415,8
}
public void afficherCarteEnAttenteAvecMarker(double lat, double lon) {
pointCommune = LatLng.create(lat, lon);
nmk.setPosition(pointCommune);
pointLocalite = LatLng.create(lat, lon);
nmk.setPosition(pointLocalite);
afficherInfoMarker(nmk, construireContenuPartielInfoMarker(nmk));
}
 
/trunk/src/org/tela_botanica/client/vues/observation/filtres/ArbreEntiteGeographiqueObservationFiltreVue.java
134,15 → 134,10
// enfin on considère le composant comme instancié
estInstancie = true;
 
}
 
});
}
 
/**
* ajoute les listeners pour les boutons et le cochage des entites
*/
181,13 → 176,11
nomFiltre = "" ;
entitesGeographiquesEncours = "" ;
String nomPere = "" ;
String nomGrandPere = "" ;
String nomArriereGrandPere = "";
switch(node.getDepth())
{
case 0:
String[] filtresStr = {"pays","departement","localite","lieudit","station"};
int profNoeud = node.getDepth();
if(profNoeud == 0) {
if(!arbreCharge)
{
arbreEntitesGeographiques.getRootNode().expand();
196,27 → 189,15
{
observationMediateur.obtenirNombreObservation() ;
}
return ;
case 4: nomFiltre += "station,lieudit,commune,departement";
nomPere = ((String[])node.getParentNode().getUserObject())[0] ;
nomGrandPere = ((String[])node.getParentNode().getParentNode().getUserObject())[0] ;
nomArriereGrandPere = ((String[])node.getParentNode().getParentNode().getParentNode().getUserObject())[0] ;
entitesGeographiquesEncours += node.getText()+","+nomPere+","+nomGrandPere+","+nomArriereGrandPere ;
break;
case 3: nomFiltre += "lieudit,commune,departement";
nomPere = ((String[])node.getParentNode().getUserObject())[0] ;
nomGrandPere = ((String[])node.getParentNode().getParentNode().getUserObject())[0] ;
entitesGeographiquesEncours += node.getText()+","+nomPere+","+nomGrandPere ;
break;
case 2: nomFiltre += "commune,departement";
nomPere = ((String[])node.getParentNode().getUserObject())[0] ;
entitesGeographiquesEncours += node.getText()+","+nomPere ;
break;
case 1: nomFiltre += "departement";
entitesGeographiquesEncours += node.getText() ;
break;
default:
break;
} else {
Node noeud = (Node)node;
for(int i = profNoeud - 1; i >= 0; i--) {
nomFiltre += filtresStr[i]+",";
entitesGeographiquesEncours += ((String[])noeud.getUserObject())[0]+",";
noeud = noeud.getParentNode();
}
nomFiltre.replaceAll(",$", "");
entitesGeographiquesEncours.replaceAll(",$", "");
}
filtreModifie = true ;
318,6 → 299,7
Observation obs = (Observation)nouvelleDonnees ;
EntiteGeographiqueObservation ent = new EntiteGeographiqueObservation(obs.getIdentifiantLocalite(),obs.getLocalite(),obs.getLieudit(),obs.getStation());
ent.setPays(obs.getPays());
creerHierarchieNoeud(arbreEntitesGeographiques.getTree(), arbreEntitesGeographiques.getRootNode(), ent);
514,6 → 496,8
String lieuDit=null;
String station=null;
String id_pays = ent.getPays();
// TODO creer une fonction plus efficace lors du passage au multi reférentiel
id_zone_geo = Util.convertirChaineZoneGeoVersDepartement(ent.getIdZoneGeo());
524,8 → 508,16
lieuDit = ent.getLieuDit();
station = ent.getStation();
if(id_pays.equals(null) || (id_pays.trim()).isEmpty()) {
id_pays="Inconnue" ;
}
if(id_zone_geo.contains("000null") || id_zone_geo.equals(null) || (id_zone_geo.trim()).equals("")) {
id_zone_geo="Inconnue" ;
} else {
if(ent.getIdZoneGeo().contains("INSEE-C:") && ent.getIdZoneGeo().length() > 10) {
id_pays = "FR";
}
}
if(zone_geo.contains("000null") || zone_geo.equals(null) || (zone_geo.trim().equals(""))) {
540,37 → 532,28
station="Inconnue" ;
}
Node noeudMemeId = arbre.getNodeById(""+id_zone_geo);
if(noeudMemeId == null) {
// on crée le noeud de l'identifiant zone_geo
noeudMemeId = creerNoeud(""+id_zone_geo,id_zone_geo);
root.appendChild(noeudMemeId) ;
}
String[] idLocalites = {id_pays, id_zone_geo, zone_geo, lieuDit, station};
// on teste si la localité existe
Node noeudMemeLoc = arbre.getNodeById(""+(id_zone_geo+zone_geo));
if(noeudMemeLoc == null)
{
// on crée le noeud de la zone_geo
noeudMemeLoc = creerNoeud(""+id_zone_geo+zone_geo, zone_geo);
noeudMemeId.appendChild(noeudMemeLoc) ;
}
Node noeudMemeId = null;
String idNoeud = "";
String locNiveau = "";
// on teste si le lieu dit existe
Node noeudMemeLieu = arbre.getNodeById(""+(id_zone_geo+zone_geo+lieuDit));
if(noeudMemeLieu == null)
{
// on crée le noeud du lieu dit
noeudMemeLieu = creerNoeud(id_zone_geo+zone_geo+lieuDit, lieuDit);
noeudMemeLoc.appendChild(noeudMemeLieu) ;
}
Node noeudParent = root;
// on teste si la station existe
Node noeudMemeStation = arbre.getNodeById(""+(id_zone_geo+zone_geo+lieuDit+station));
if(noeudMemeStation == null) {
// on crée le noeud de la station
noeudMemeStation = creerNoeud(id_zone_geo+zone_geo+lieuDit+station,station);
noeudMemeLieu.appendChild(noeudMemeStation);
for(int i = 0; i < idLocalites.length; i++) {
// Recherche des noeuds correspondant à chacun des niveaux de la hierarchie
locNiveau = idLocalites[i];
idNoeud += idLocalites[i];
noeudMemeId = arbre.getNodeById(idNoeud);
// Si le noeud n'existe pas on le crée
if(noeudMemeId == null) {
noeudMemeId = creerNoeud(idNoeud, locNiveau);
noeudParent.appendChild(noeudMemeId) ;
}
noeudParent = noeudMemeId;
}
root.sort(comparerNoeuds()) ;
620,22 → 603,26
int profondeur = 0;
if(nom.equals("departement")) {
if(nom.equals("pays")) {
profondeur = 1;
}
if(nom.equals("commune")) {
if(nom.equals("departement")) {
profondeur = 2;
}
if(nom.equals("lieudit")) {
if(nom.equals("localite")) {
profondeur = 3;
}
if(nom.equals("station")) {
if(nom.equals("lieudit")) {
profondeur = 4;
}
if(nom.equals("station")) {
profondeur = 5;
}
return profondeur;
}
/trunk/src/org/tela_botanica/client/vues/observation/ListeObservationVue.java
117,7 → 117,7
private final int KEY_ENTER = 13;
private String modeleLieu = "IDLOCCOMMUNE, LIEUDIT, STATION";
private String modeleLieu = "IDLOCLOCALITE, LIEUDIT, STATION";
 
 
private boolean tailleInitialisee = false ;
912,8 → 912,8
nomFiltre = "departement";
}
if(nomFiltre.equals("commune")) {
nomFiltre = "commune";
if(nomFiltre.equals("localite")) {
nomFiltre = "localite";
}
if(nomFiltre.equals("nom_taxon")) {
/trunk/src/org/tela_botanica/client/vues/observation/FormulaireSaisieObservationVue.java
16,11 → 16,11
import org.tela_botanica.client.modeles.objets.Configuration;
import org.tela_botanica.client.modeles.objets.EntiteGeographiqueObservation;
import org.tela_botanica.client.modeles.objets.ListeObservation;
import org.tela_botanica.client.modeles.objets.ListeReferentielCommune;
import org.tela_botanica.client.modeles.objets.ListeReferentielLocalite;
import org.tela_botanica.client.modeles.objets.ListeReferentielNom;
import org.tela_botanica.client.modeles.objets.Observation;
import org.tela_botanica.client.modeles.objets.Ontologies;
import org.tela_botanica.client.modeles.objets.ReferentielCommune;
import org.tela_botanica.client.modeles.objets.ReferentielLocalite;
import org.tela_botanica.client.modeles.objets.ReferentielNom;
import org.tela_botanica.client.modeles.objets.ListeReferentielPerso.TypesReferentiels;
import org.tela_botanica.client.observation.ObservationMediateur;
35,7 → 35,6
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.maps.gwt.client.LatLng;
import com.gwtext.client.core.EventCallback;
import com.gwtext.client.core.EventObject;
import com.gwtext.client.core.Ext;
96,14 → 95,14
private ComboBox station = null;
private ComboBox milieu = null;
private TextField comment = null;
private ComboBox commune = null;
private ComboBox localite = null;
private String departement = null;
private String codeLocalite = null;
private String pays = null;
private ComboBox espece = null;
private String numeroNom = null;
private String numeroOrdre = null;
private String codeLoc = null;
private String referentielTaxo = null;
private String referentielGeo = null;
 
110,7 → 109,7
// Pour remise a zero partielle lors d'une validation
 
private enum Champs {
DATE, LIEUDIT, STATION, MILIEU, COMMENT, COMMUNE, ESPECE, TOUT, LATITUDE, LONGITUDE, ALTITUDE, ABONDANCE, CERTITUDE, REFERENTIELTAXO, PHENOLOGIE;
DATE, LIEUDIT, STATION, MILIEU, COMMENT, LOCALITE, ESPECE, TOUT, LATITUDE, LONGITUDE, ALTITUDE, ABONDANCE, CERTITUDE, REFERENTIELTAXO, PHENOLOGIE;
 
@Override
public String toString() {
119,8 → 118,8
case DATE:
return "date";
case COMMUNE:
return "commune";
case LOCALITE:
return "localite";
case LIEUDIT:
return "lieu dit";
159,7 → 158,7
return "phenologie";
case TOUT:
return "date, commune, lieu dit, station, milieu, espèce, commentaire, latitude, longitude, altitude, abondance, identification, referentiel, phenologie";
return "date, localite, lieu dit, station, milieu, espèce, commentaire, latitude, longitude, altitude, abondance, identification, referentiel, phenologie";
}
return TOUT.toString();
}
171,7 → 170,7
private Button boutonSupprimer = new Button("Supprimer");
private Button boutonAnnuler = new Button("Réinitialiser");
 
private boolean selectionCommune=false;
private boolean selectionlocalite=false;
private boolean selectionEspece=false;
private boolean selectionAbondance = false;
private boolean selectionCertitude = false;
180,8 → 179,8
private Toolbar bt = null ;
 
private final String VALEURS_MULTIPLES = "(Valeurs multiples)";
private final String modeleMessageModif = "commune:lieu-dit:station:milieu:latitude:longitude:altitude:date:espece:commentaire:abondance:identification:referentiel:phenologie";
private boolean communeModifiee = false;
private final String modeleMessageModif = "localite:lieu-dit:station:milieu:latitude:longitude:altitude:date:espece:commentaire:abondance:identification:referentiel:phenologie";
private boolean localiteModifiee = false;
private boolean lieuDitModifie = false;
private boolean stationModifiee = false;
private boolean milieuModifie = false;
227,13 → 226,13
 
private TextField altitude;
 
private MultiFieldPanel htmlCommunePanel = null;
private MultiFieldPanel htmllocalitePanel = null;
 
private MultiFieldPanel coordPanel;
 
private TextField coordonnees;
 
private Label lienSelectionCommune = null;
private Label lienSelectionlocalite = null;
 
private HTML afficherFormulaireLatLon;
 
247,11 → 246,11
 
private boolean altModifiee;
 
protected boolean rechercheCommuneEnCours = false;
protected boolean recherchelocaliteEnCours = false;
 
private Timer tCoord;
 
final String resultTplRefPerso = "<div class=\"search-item-commune\">{element_referentiel}</div>";
final String resultTplRefPerso = "<div class=\"search-item-localite\">{element_referentiel}</div>";
 
private ComboBox selecteurAbondance = null;
 
326,38 → 325,38
this.setPaddings(5) ;
 
// Accesskey pour debugging
commune = new ComboBox("Commune","commune\" accesskey=\"1");
localite = new ComboBox("Localite","localite\" accesskey=\"1");
 
final String resultTplCommune = "<div class=\"search-item-commune\">{commune}</div>";
commune.setTpl(resultTplCommune);
commune.setMode(ComboBox.REMOTE);
commune.setItemSelector("div.search-item-commune");
commune.setTypeAhead(true);
commune.setLoadingText("Recherche...");
commune.setHideTrigger(true);
final String resultTpllocalite = "<div class=\"search-item-localite\">{localite}</div>";
localite.setTpl(resultTpllocalite);
localite.setMode(ComboBox.REMOTE);
localite.setItemSelector("div.search-item-localite");
localite.setTypeAhead(true);
localite.setLoadingText("Recherche...");
localite.setHideTrigger(true);
 
//création du lien "Accès carto" dans le formulaire
String aideLienLocaliser = "Vous pouvez entrer une nom sous la forme commune (departement) ou bien commune (pays) "+
"avec un numéro de département sur 2 chiffres ou un code de pays àdeux lettres ";
String aideLienLocaliser = "Via une carte, obtenez les coordonnées (latitude/longitude) de votre observation, Vous pouvez entrer une nom sous la forme commune (departement) ou bien localite (pays) "+
"avec un numéro de département sur 2 chiffres ou un code de pays à deux lettres (format iso 3166 1)";
basculerverscarto = new HTML(" <a id=\"lien_carto\" title=\""+aideLienLocaliser+"\" href=\"#\" tabindex=\"2\">Localiser la zone</a>");
basculerverscarto.addStyleName("lien_actif");
 
//création info bulle sur le lien "accès carto"
ToolTip tip2 = new ToolTip();
tip2.setHtml("Via une carte, obtenez les coordonnées (latitude/longitude) de votre observation ");
tip2.setHtml(aideLienLocaliser);
tip2.applyTo(basculerverscarto.getElement());
 
//Sur une meme ligne, ajout de plusieurs champs
htmlCommunePanel = new MultiFieldPanel();
htmllocalitePanel = new MultiFieldPanel();
 
int largeurCommune = Window.getClientWidth()/4;
htmlCommunePanel.addToRow(commune, largeurCommune);
htmlCommunePanel.addToRow(basculerverscarto, 160);
int largeurlocalite = Window.getClientWidth()/4;
htmllocalitePanel.addToRow(localite, largeurlocalite);
htmllocalitePanel.addToRow(basculerverscarto, 160);
 
htmlCommunePanel.setBorder(false);
htmlCommunePanel.setId("x-commune-panel");
htmllocalitePanel.setBorder(false);
htmllocalitePanel.setId("x-localite-panel");
 
panneauPremierColonne.add(htmlCommunePanel);
panneauPremierColonne.add(htmllocalitePanel);
 
station = new AutoCompletionRefComboBox("Station", "station", observationMediateur, TypesReferentiels.REFERENTIEL_STATION) {
 
385,12 → 384,12
altitude.setGrowMax(70);
altitude.setAllowBlank(true);
 
lienSelectionCommune = new Label("");
lienSelectionlocalite = new Label("");
 
 
lienSelectionCommune.setId("conteneur_selection_commune");
lienSelectionCommune.setStyleName("conteneur_selection_commune");
lienSelectionCommune.addStyleName("lien_actif");
lienSelectionlocalite.setId("conteneur_selection_localite");
lienSelectionlocalite.setStyleName("conteneur_selection_localite");
lienSelectionlocalite.addStyleName("lien_actif");
 
// Panneau de type plusieurs champs de formulaire sur une meme ligne, où seront renseignés Lat/Lon
coordPanel = new MultiFieldPanel();
402,8 → 401,8
 
coordPanel.addToRow(latitude, new ColumnLayoutData(largeur));
coordPanel.addToRow(longitude, new ColumnLayoutData(largeur));
coordPanel.addToRow(lienSelectionCommune, new ColumnLayoutData(largeur));
lienSelectionCommune.addClass("lien_decale");
coordPanel.addToRow(lienSelectionlocalite, new ColumnLayoutData(largeur));
lienSelectionlocalite.addClass("lien_decale");
coordPanel.setBorder(false);
 
coordPanel.addToRow(altitude, new ColumnLayoutData(largeur));
604,7 → 603,7
panneauPremierColonne.doLayout();
panneauSecondeColonne.doLayout();
htmlCommunePanel.doLayout();
htmllocalitePanel.doLayout();
htmlPanel.doLayout();
doLayout();
776,11 → 775,11
@Override
public void execute(EventObject e) {
 
if(commune.getValue() != null && !commune.getValue().equals("")) {
obtenirInformationCommune();
if(localite.getValue() != null && !localite.getValue().equals("")) {
obtenirInformationLocalite();
longlatAjoutee = true;
} else {
Window.alert("Veuillez renseigner une commune et un numéro de département sous la forme : Commune (departement)");
Window.alert("Veuillez renseigner une localite suivie d'un numéro de département ou une localité suivie d'un code de pays à deux lettres \n Sous la forme : localite (departement) ou Localité (Pays)");
}
}
});
791,7 → 790,7
 
latitude.setWidth(largeurN+"px");
longitude.setWidth(largeurN+"px");
lienSelectionCommune.setWidth(largeurN+"px");
lienSelectionlocalite.setWidth(largeurN+"px");
}
}
 
800,10 → 799,10
// Listener completion communne
final Rafraichissable r = this;
ListenerConfig listenerConfigCommune=new ListenerConfig();
listenerConfigCommune.setDelay(200);
listenerConfigCommune.setStopPropagation(false);
listenerConfigCommune.setStopEvent(false);
ListenerConfig listenerConfiglocalite=new ListenerConfig();
listenerConfiglocalite.setDelay(200);
listenerConfiglocalite.setStopPropagation(false);
listenerConfiglocalite.setStopEvent(false);
 
date.addListener(new DatePickerListenerAdapter() {
 
828,9 → 827,9
@Override
public void run() {
double[] coord = coordonneesValides();
if(!rechercheCommuneEnCours && coord != null && (longModifiee || latModifiee)) {
rechercheCommuneEnCours = true;
Ext.get(lienSelectionCommune.getElement()).mask("recherche");
if(!recherchelocaliteEnCours && coord != null && (longModifiee || latModifiee)) {
recherchelocaliteEnCours = true;
Ext.get(lienSelectionlocalite.getElement()).mask("recherche");
observationMediateur.obtenirInformationCoord(r,coord[0], coord[1]);
}
}
837,7 → 836,7
 
};
 
ajouterListenerChampEvenementsClavier(commune, listenerConfigCommune);
ajouterListenerChampEvenementsClavier(localite, listenerConfiglocalite);
ajouterListenerChampEvenementsClavier(date);
ajouterListenerChampEvenementsClavier(selecteurReferentielTaxo);
ajouterListenerChampEvenementsClavier(espece, listenerConfigEspece);
890,20 → 889,19
this.addListener(new ContainerListenerAdapter() {
@Override
public void onAfterLayout(Container self) {
commune.focus();
localite.focus();
}
});
}
 
private void ajouterListenerChampsCombobox() {
commune.addListener(new ComboBoxListenerAdapter() {
localite.addListener(new ComboBoxListenerAdapter() {
@Override
public void onSelect(ComboBox comboBox, Record record, int index) {
commune.setValue(record.getAsString("commune"));
departement=record.getAsString("departement");
codeLoc=record.getAsString("codeInsee");
selectionCommune=true;
commune.collapse();
localite.setValue(record.getAsString("localite"));
codeLocalite=record.getAsString("departement");
selectionlocalite=true;
localite.collapse();
}
 
@Override
1058,14 → 1056,14
validerSaisie(Champs.DATE);
}
 
if(champ.equals(commune)) {
if(champ.equals(commune)) {
if (selectionCommune) {
communeModifiee= true;
selectionCommune=false;
if(champ.equals(localite)) {
if(champ.equals(localite)) {
if (selectionlocalite) {
localiteModifiee= true;
selectionlocalite=false;
}
else {
validerSaisie(Champs.COMMUNE);
validerSaisie(Champs.LOCALITE);
}
}
}
1128,11 → 1126,11
dateModifiee = true;
}
 
if(champ.equals(commune)) {
departement="";
commune.collapse();
obtenirListeReferentielCommune();
communeModifiee= true;
if(champ.equals(localite)) {
codeLocalite="";
localite.collapse();
obtenirListeReferentiellocalite();
localiteModifiee= true;
}
}
 
1168,38 → 1166,38
@Override
public void rafraichir(Object nouvelleDonnees, boolean repandreRaffraichissement) {
 
// si l'on a reçu une liste du referentiel commune (completion referentiel commune)
if(nouvelleDonnees instanceof ListeReferentielCommune)
// si l'on a reçu une liste du referentiel localite (completion referentiel localite)
if(nouvelleDonnees instanceof ListeReferentielLocalite)
{
ListeReferentielCommune data = (ListeReferentielCommune) nouvelleDonnees ;
Object[][] communeData = new Object[data.size()][3];
ListeReferentielLocalite data = (ListeReferentielLocalite) nouvelleDonnees ;
Object[][] localiteData = new Object[data.size()][3];
int i = 0 ;
 
// on la parse et on récupère les informations quiç nous interessent
for (Iterator it = data.keySet().iterator(); it.hasNext();)
{
ReferentielCommune ref=data.get(it.next());
ReferentielLocalite ref=data.get(it.next());
 
communeData[i][0]= ref.getCommune();
communeData[i][1]= ref.getDepartement();
communeData[i][2]= ref.getCodeInsee();
localiteData[i][0]= ref.getLocalite();
localiteData[i][1]= ref.getCodeLocalite();
localiteData[i][2]= ref.getCodeInsee();
i++ ;
}
 
// creation du store
FieldDef defCommune = new StringFieldDef("commune");
FieldDef deflocalite = new StringFieldDef("localite");
FieldDef defDepartement = new StringFieldDef("departement");
FieldDef defCodeInsee = new StringFieldDef("codeInsee");
 
FieldDef[] defTab = { defCommune, defDepartement, defCodeInsee};
FieldDef[] defTab = { deflocalite, defDepartement, defCodeInsee};
 
RecordDef rd = new RecordDef(defTab);
 
final MemoryProxy dataProxy = new MemoryProxy(communeData);
final MemoryProxy dataProxy = new MemoryProxy(localiteData);
final ArrayReader reader = new ArrayReader(rd);
 
Store store=new Store(dataProxy,reader);
commune.setStore(store);
localite.setStore(store);
store.load();
 
}
1275,98 → 1273,101
if(nouvelleDonnees instanceof EntiteGeographiqueObservation)
{
EntiteGeographiqueObservation infosComm = (EntiteGeographiqueObservation)nouvelleDonnees ;
if(rechercheCommuneEnCours) {
afficherIndicationCommune(infosComm);
if(recherchelocaliteEnCours) {
afficherIndicationlocalite(infosComm);
} else {
rafraichirCommuneEtCoord(infosComm);
rafraichirlocaliteEtCoord(infosComm);
}
}
}
 
private void afficherIndicationCommune(
private void afficherIndicationlocalite(
final EntiteGeographiqueObservation infosCom) {
 
String nCommune = "";
String nlocalite = "";
if(infosCom != null && infosCom.getZoneGeo() != null && !infosCom.getZoneGeo().trim().isEmpty()){
nCommune += infosCom.getZoneGeo();
nlocalite += infosCom.getZoneGeo();
if(!infosCom.getIdZoneGeo().trim().isEmpty()) {
if(Util.estUnNombre(infosCom.getIdZoneGeo())) {
nCommune += " ("+Util.convertirChaineZoneGeoVersDepartement(infosCom.getIdZoneGeo())+")";
} else if(infosCom.getPays() != null && infosCom.getPays().trim().isEmpty()) {
nCommune += " ("+infosCom.getPays()+")";
nlocalite += " ("+Util.convertirChaineZoneGeoVersDepartement(infosCom.getIdZoneGeo())+")";
}
} else if(infosCom.getPays() != null && !infosCom.getPays().trim().isEmpty()) {
nlocalite += " ("+infosCom.getPays()+")";
}
 
lienSelectionCommune.setHtml("<a id=\"lien_selection_commune\" tabindex=\"9\">"+nCommune+"</a>");
lienSelectionCommune.setStyleName("img-curseur-depl");
lienSelectionlocalite.setHtml("<a id=\"lien_selection_localite\" tabindex=\"9\">"+nlocalite+"</a>");
lienSelectionlocalite.setStyleName("img-curseur-depl");
 
Ext.get("lien_selection_commune").addListener("click",new EventCallback() {
Ext.get("lien_selection_localite").addListener("click",new EventCallback() {
@Override
public void execute(EventObject e) {
rafraichirCommune(infosCom);
rafraichirlocalite(infosCom);
}
});
 
Ext.get("lien_selection_commune").addListener("keypress",new EventCallback() {
Ext.get("lien_selection_localite").addListener("keypress",new EventCallback() {
@Override
public void execute(EventObject e) {
if(e.getCharCode() == KEY_ENTER) {
rafraichirCommune(infosCom);
rafraichirlocalite(infosCom);
}
}
});
 
Ext.get("lien_selection_commune").addListener("focus",new EventCallback() {
Ext.get("lien_selection_localite").addListener("focus",new EventCallback() {
@Override
public void execute(EventObject e) {
Ext.get("lien_selection_commune").toggleClass("lien_sel");
Ext.get("lien_selection_localite").toggleClass("lien_sel");
}
});
 
Ext.get("lien_selection_commune").addListener("blur",new EventCallback() {
Ext.get("lien_selection_localite").addListener("blur",new EventCallback() {
@Override
public void execute(EventObject e) {
Ext.get("lien_selection_commune").toggleClass("lien_sel");
Ext.get("lien_selection_localite").toggleClass("lien_sel");
}
});
 
} else {
if(rechercheCommuneEnCours) {
lienSelectionCommune.setHtml("<span id=\"aucune_selection_commune\"> Erreur de localisation </span>");
if(recherchelocaliteEnCours) {
lienSelectionlocalite.setHtml("<span id=\"aucune_selection_localite\"> Erreur de localisation </span>");
} else {
lienSelectionCommune.setHtml("<span id=\"aucune_selection_commune\"> </span>");
lienSelectionlocalite.setHtml("<span id=\"aucune_selection_localite\"> </span>");
}
}
 
Ext.get(lienSelectionCommune.getElement()).unmask();
rechercheCommuneEnCours = false;
Ext.get(lienSelectionlocalite.getElement()).unmask();
recherchelocaliteEnCours = false;
}
 
private void rafraichirCommune(EntiteGeographiqueObservation infosCom) {
String nCommune = "";
private void rafraichirlocalite(EntiteGeographiqueObservation infosCom) {
String nlocalite = "";
 
if(infosCom.getZoneGeo() != null && !infosCom.getZoneGeo().equals("")) {
nCommune += infosCom.getZoneGeo();
nlocalite += infosCom.getZoneGeo();
}
if(Util.estUnNombre(infosCom.getIdZoneGeo())) {
String codeGeoFormate = Util.convertirChaineZoneGeoVersDepartement(infosCom.getIdZoneGeo());
nCommune += " ("+codeGeoFormate+")";
departement = Util.convertirChaineZoneGeoVersDepartement(infosCom.getIdZoneGeo());
} else if(infosCom.getPays() != null && infosCom.getPays().trim().isEmpty()) {
nCommune += " ("+infosCom.getPays()+")";
nlocalite += " ("+codeGeoFormate+")";
codeLocalite = Util.convertirChaineZoneGeoVersDepartement(infosCom.getIdZoneGeo());
} else if(infosCom.getPays() != null && !infosCom.getPays().trim().isEmpty()) {
nlocalite += " ("+infosCom.getPays()+")";
}
if (! nCommune.equals("")) {
commune.setValue(nCommune);
communeModifiee = true;
if (!nlocalite.equals("")) {
// Afin de pas effacer un pays précédemment saisi
if(!localite.getValue().contains(nlocalite)) {
localite.setValue(nlocalite);
}
localiteModifiee = true;
}
}
 
// Se déclenche au retour de la "localisation sur la carte"
private void rafraichirCommuneEtCoord(EntiteGeographiqueObservation infosCom) {
private void rafraichirlocaliteEtCoord(EntiteGeographiqueObservation infosCom) {
rafraichirCommune(infosCom);
rafraichirlocalite(infosCom);
if(infosCom.getLat() != null && !infosCom.getLat().equals("")) {
latitude.setValue(Util.tronquerNombrePourAffichage("" + infosCom.getLat(), 5));
}
1381,12 → 1382,12
coordPanel.setVisible(true);
}
 
public void obtenirListeReferentielCommune() {
public void obtenirListeReferentiellocalite() {
 
String com=commune.getText();
String com=localite.getText();
com=com.replaceAll("%","");
 
observationMediateur.obtenirListeReferentielCommune(this,com);
observationMediateur.obtenirListeReferentielLocalite(this,com);
 
}
 
1418,36 → 1419,14
return;
}
 
if(departement != null) {
if(departement.equals("000null") || departement.equals("")) {
String[] depCom = commune.getText().split(" ");
if(depCom.length > 1) {
String dep = depCom[1].replace('(', ' ');
dep =dep.replace(')', ' ');
dep = dep.trim();
dep = dep.replace('\\',' ');
dep = dep.trim();
affecterCodeLocaliteOuPays();
 
try
{
int nDep = Integer.parseInt(dep);
if(nDep > 0 && nDep < 110) {
departement = dep ;
}
}
catch(NumberFormatException e)
{
departement = "" ;
}
}
}
}
 
String dateObs = Util.remplacerSeparateursDateFormatCel(date.getRawValue());
 
Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),dateObs);
Observation obs=new Observation(espece.getText(),numeroNom,localite.getText(),codeLocalite,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),dateObs);
 
String[] coords = getValeurCoordonnees();
obs.setPays(pays);
obs.setLatitude(coords[0]);
obs.setLongitude(coords[1]);
obs.setAltitude(altitude.getText());
1474,36 → 1453,16
return;
}
 
if(departement.equals("000null") || departement.equals("")) {
String[] depCom = commune.getText().split(" ");
if(depCom.length > 1) {
String dep = depCom[1].replace('(', ' ');
dep =dep.replace(')', ' ');
dep = dep.trim();
dep = dep.replace('\\',' ');
dep = dep.trim();
 
try
{
int nDep = Integer.parseInt(dep);
if(nDep > 0 && nDep < 110) {
departement = dep ;
}
}
catch(NumberFormatException e)
{
departement = "" ;
}
}
}
 
affecterCodeLocaliteOuPays();
String dateObs = Util.remplacerSeparateursDateFormatCel(date.getRawValue());
 
Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),dateObs);
Observation obs=new Observation(espece.getText(),numeroNom,localite.getText(),codeLocalite,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),dateObs);
obs.setNumeroOrdre(numeroOrdre);
 
String[] coords = getValeurCoordonnees();
 
obs.setPays(pays);
obs.setLatitude(coords[0]);
obs.setLongitude(coords[1]);
obs.setAltitude(altitude.getText());
1517,11 → 1476,31
observationMediateur.modifierObservation(obs);
}
 
private void affecterCodeLocaliteOuPays() {
codeLocalite = "";
pays = "";
// Soit un numéro de département, soit un code de pays à deux lettres
String[] codeCom = localite.getText().split(" ");
if(codeCom.length > 1) {
String codeLoc = codeCom[1].replace('(', ' ');
codeLoc = codeLoc.replace(')', ' ').trim().replace('\\',' ').trim();
 
if(Util.estUnNombre(codeLoc)) {
codeLocalite = codeLoc ;
} else {
pays = codeLoc;
}
}
}
 
private void modifierObservationEnMasse(Champs champModifie) {
 
//TODO: factoriser
String communeM = null;
String departementM = null;
String paysM = null;
String localiteM = null;
String codeLocaliteM = null;
String numNomSelM = null;
String lieuDitM = null;
String stationM = null;
1539,33 → 1518,25
 
String champs = modeleMessageModif;
 
if(communeModifiee && ! commune.getRawValue().equals(VALEURS_MULTIPLES)) {
communeM = commune.getText();
if(localiteModifiee && ! localite.getRawValue().equals(VALEURS_MULTIPLES)) {
localiteM = localite.getText();
// Soit un numéro de département, soit un code de pays à deux lettres
String[] codeCom = localite.getText().split(" ");
if(codeCom.length > 1) {
String codeLoc = codeCom[1].replace('(', ' ');
codeLoc = codeLoc.replace(')', ' ').trim().replace('\\',' ').trim();
 
if(departement.equals("000null") || departement.equals("")) {
String[] depCom = commune.getText().split(" ");
if(depCom.length > 1) {
String dep = depCom[1].replace('(', ' ');
dep =dep.replace(')', ' ');
dep = dep.trim();
dep = dep.replace('\\',' ');
dep = dep.trim();
 
try {
int nDep = Integer.parseInt(dep);
if(nDep > 0 && nDep < 110) {
departement = dep ;
}
}
catch(NumberFormatException e) {
departement = "" ;
}
if(Util.estUnNombre(codeLoc)) {
codeLocaliteM = codeLoc ;
} else {
paysM = codeLoc;
}
}
departementM = departement;
}
else {
champs = champs.replaceAll("commune", "");
champs = champs.replaceAll("localite", "");
}
 
if(lieuDitModifie && ! lieudit.getRawValue().equals(VALEURS_MULTIPLES)) {
1658,7 → 1629,8
if(champs.trim().equals("")) {
Window.alert("Aucun champ n'a été modifié");
} else {
Observation obs = new Observation(especeM,numNomSelM,communeM,departementM,lieuDitM,stationM,milieuM, commM,dateM);
Observation obs = new Observation(especeM,numNomSelM,localiteM,codeLocaliteM,lieuDitM,stationM,milieuM, commM,dateM);
obs.setPays(paysM);
obs.setNumeroOrdre(numeroOrdre);
obs.setLatitude(latM);
obs.setLongitude(longM);
1697,6 → 1669,10
idLoc = idLoc.substring(0,2);
}
}
if(obs.getIdentifiantLocalite().isEmpty() && !obs.getPays().isEmpty()) {
idLoc = obs.getPays();
}
 
if(!obs.getDate().equals("null") && !obs.getDate().equals("000null") && !obs.getDate().equals(VALEURS_MULTIPLES)) {
String[] dateEtHeure = obs.getDate().split(" ", 2);
1728,18 → 1704,18
if(!obs.getLocalite().equals("null") && !obs.getLocalite().equals("000null")) {
if(!idLoc.equals("000null") && !idLoc.equals("")) {
if(!idLoc.equals(VALEURS_MULTIPLES)) {
commune.setValue(obs.getLocalite()+" ("+idLoc+")") ;
localite.setValue(obs.getLocalite()+" ("+idLoc+")") ;
} else {
commune.setValue(VALEURS_MULTIPLES);
localite.setValue(VALEURS_MULTIPLES);
}
}
else
{
commune.setValue(obs.getLocalite());
localite.setValue(obs.getLocalite());
}
}
if(!obs.getIdentifiantLocalite().equals("null") && !obs.getIdentifiantLocalite().equals("000null")) {
departement = idLoc;
codeLocalite = idLoc;
}
if(!obs.getNomSaisi().equals("null") && !obs.getNomSaisi().equals("000null")) {
espece.setValue(obs.getNomSaisi()) ;
1929,9 → 1905,10
comment.reset() ;
break;
 
case COMMUNE:
commune.reset() ;
departement ="";
case LOCALITE:
localite.reset() ;
codeLocalite ="";
pays="";
latitude.reset();
longitude.reset();
break;
1944,12 → 1921,12
 
case LATITUDE:
latitude.reset();
afficherIndicationCommune(null);
afficherIndicationlocalite(null);
break;
 
case LONGITUDE:
longitude.reset();
afficherIndicationCommune(null);
afficherIndicationlocalite(null);
break;
 
case ALTITUDE:
1973,7 → 1950,7
break;
 
case TOUT:
commune.reset();
localite.reset();
date.reset() ;
lieudit.reset() ;
station.reset() ;
1983,7 → 1960,8
latitude.reset();
longitude.reset();
altitude.reset();
departement ="";
pays="";
codeLocalite ="";
espece.reset();
selecteurAbondance.clearValue();
selecteurCertitude.clearValue();
1992,7 → 1970,7
referentielTaxo = "";
numeroNom = "" ;
numeroOrdre = "";
afficherIndicationCommune(null);
afficherIndicationlocalite(null);
break;
 
}
2027,8 → 2005,9
 
private void calculerAfficherDifferences(ListeObservation listeObs) {
 
String departement = null;
String commune = null;
String codeLocalite = null;
String pays = null;
String localite = null;
String lieuDit = null;
String station = null;
String milieu = null;
2047,8 → 2026,9
 
for(Iterator<String> it = listeObs.keySet().iterator();it.hasNext();) {
Observation obsEnCours = listeObs.get(it.next());
departement = comparerDifferencesChamps(departement, obsEnCours.getIdentifiantLocalite());
commune = comparerDifferencesChamps(commune, obsEnCours.getLocalite());
pays = comparerDifferencesChamps(pays, obsEnCours.getPays());
codeLocalite = comparerDifferencesChamps(codeLocalite, obsEnCours.getIdentifiantLocalite());
localite = comparerDifferencesChamps(localite, obsEnCours.getLocalite());
lieuDit = comparerDifferencesChamps(lieuDit, obsEnCours.getLieudit());
station = comparerDifferencesChamps(station, obsEnCours.getStation());
milieu = comparerDifferencesChamps(milieu, obsEnCours.getMilieu());
2066,7 → 2046,8
ordreObs += obsEnCours.getNumeroOrdre()+",";
}
 
Observation obs=new Observation(espece,numeroNom,commune,departement,lieuDit,station,milieu, notes,date);
Observation obs=new Observation(espece,numeroNom,localite,codeLocalite,lieuDit,station,milieu, notes,date);
obs.setPays(pays);
obs.setNumeroOrdre(ordreObs);
obs.setLatitude(lat);
obs.setLongitude(lon);
2095,7 → 2076,7
}
 
private void reinitialiserValeurModifiees() {
communeModifiee = false;
localiteModifiee = false;
lieuDitModifie = false;
stationModifiee = false;
milieuModifie = false;
2113,7 → 2094,7
 
public void saisieTabindex()
{
commune.setTabIndex(1);
localite.setTabIndex(1);
lieudit.setTabIndex(3);
station.setTabIndex(4);
milieu.setTabIndex(5);
2195,17 → 2176,17
}
}
 
private void obtenirInformationCommune() {
private void obtenirInformationLocalite() {
String idLoc = "";
if(departement != null && !departement.isEmpty()) {
idLoc = departement;
if(codeLocalite != null && !codeLocalite.isEmpty()) {
idLoc = codeLocalite;
} else {
idLoc = Util.obtenirIdLocAPartirChaineCommune(commune.getText());
idLoc = Util.obtenirIdLocAPartirChaineLocalite(localite.getText());
if(Util.estUnNombre(idLoc)) {
idLoc = Util.formaterDepartement(idLoc);
}
}
observationMediateur.obtenirInformationCommune(getCommuneSansIdLoc(), idLoc);
observationMediateur.obtenirInformationLocalite(getlocaliteSansIdLoc(), idLoc);
}
 
public double[] coordonneesValides() {
2234,18 → 2215,18
}
}
 
public String getCommune() {
public String getlocalite() {
 
String valeurCommune = "";
String valeurlocalite = "";
 
if(commune.getValue() != null) {
valeurCommune = commune.getValue();
if(localite.getValue() != null) {
valeurlocalite = localite.getValue();
}
return valeurCommune;
return valeurlocalite;
}
 
public String getCommuneSansIdLoc() {
return Util.supprimerChaineIdLocalite(getCommune());
public String getlocaliteSansIdLoc() {
return Util.supprimerChaineIdLocalite(getlocalite());
}
 
private String getValeurChampListeLibre(ComboBox champ) {
2284,8 → 2265,8
return Ontologies.getInfosReferentielNomParCode(codeCourt).getCodeVersionComplet();
}
 
public boolean communeInitialisee() {
return communeModifiee;
public boolean localiteInitialisee() {
return localiteModifiee;
}
 
public void redimensionnerFormulaire() {
/trunk/src/org/tela_botanica/client/vues/observation/PanneauFiltresObservationVues.java
170,7 → 170,7
arbreDateObservationFiltreVue.viderFiltre(nom);
}
if(nom.equals("station") || nom.equals("lieudit") || nom.equals("departement") || nom.equals("commune")) {
if(nom.equals("pays") || nom.equals("station") || nom.equals("lieudit") || nom.equals("departement") || nom.equals("localite")) {
arbreEntiteGeographiqueObservationFiltreVue.viderFiltre(nom);
}