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() { |