6,6 → 6,7 |
import java.util.Iterator; |
|
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.Configuration; |
import org.tela_botanica.client.modeles.EntiteGeographiqueObservation; |
import org.tela_botanica.client.modeles.ListeObservation; |
import org.tela_botanica.client.modeles.ListeReferentielCommune; |
89,10 → 90,12 |
private String numeroNom = null; |
private String numeroOrdre = null; |
|
private String referentielGeo = null; |
|
// Pour remise a zero partielle lors d'une validation |
|
private enum Champs { |
DATE, LIEUDIT, STATION, MILIEU, COMMENT, COMMUNE, ESPECE, TOUT ; |
DATE, LIEUDIT, STATION, MILIEU, COMMENT, COMMUNE, ESPECE, TOUT, LATITUDE, LONGITUDE ; |
|
public String toString() { |
|
118,8 → 121,14 |
case ESPECE: |
return "espèce"; |
|
case LATITUDE: |
return "latitude"; |
|
case LONGITUDE: |
return "longitude"; |
|
case TOUT: |
return "date, commune, lieu dit, station, milieu, espèce, commentaire"; |
return "date, commune, lieu dit, station, milieu, espèce, commentaire, latitude, longitude"; |
} |
return TOUT.toString(); |
} |
136,7 → 145,7 |
private Toolbar bt = null ; |
|
private final String VALEURS_MULTIPLES = "(Valeurs multiples)"; |
private final String modeleMessageModif = "commune:lieu-dit:station:milieu:date:espece:commentaire"; |
private final String modeleMessageModif = "commune:lieu-dit:station:milieu:latitude:longitude:date:espece:commentaire"; |
private boolean communeModifiee = false; |
private boolean lieuDitModifie = false; |
private boolean stationModifiee = false; |
199,6 → 208,10 |
|
private boolean longlatAjoutee; |
|
private boolean latModifiee; |
|
private boolean longModifiee; |
|
/** |
* Constructeur sans argument (privé car ne doit pas être utilisé) |
*/ |
276,22 → 289,23 |
//station.setTabIndex(3); |
panneauPremierColonne.add(station, new AnchorLayoutData("95%")); |
|
longitude = new TextField("X", "x", 100); |
latitude = new TextField("X", "x", 100); |
latitude.setAllowBlank(true); |
|
longitude = new TextField("Y", "y", 100); |
longitude.setAllowBlank(true); |
|
latitude = new TextField("Y", "y", 100); |
latitude.setAllowBlank(true); |
|
// Panneau de type plusieurs champs de formulaire sur une meme ligne, où seront renseignés X/Y |
coordPanel = new MultiFieldPanel(); |
coordPanel.setVisible(false); |
coordPanel.addToRow(latitude, new ColumnLayoutData(0.5)); |
coordPanel.addToRow(longitude, new ColumnLayoutData(0.5)); |
coordPanel.addToRow(latitude, new ColumnLayoutData(0.5)); |
coordPanel.setBorder(false); |
|
//création du champs coordonnées |
referentielGeo = Configuration.getReferentielGeo(); |
|
coordonnees = new TextField("Coordonnées", "", 0); |
coordonnees = new TextField("Coordonnées ("+referentielGeo+")", "", 0); |
coordonnees.setMaxLength(0); |
coordonnees.setReadOnly(true); |
coordonnees.setCls("fieldname"); |
344,7 → 358,7 |
|
|
//création du lien "Accès carto" dans le formulaire |
basculerverscarto = new HTML(" <a id=\"lien_carto\" href=\"#\" tabindex=\"6\">Selection depuis la carto</a>"); |
basculerverscarto = new HTML(" <a id=\"lien_carto\" href=\"#\" tabindex=\"6\">Selection depuis une carte</a>"); |
basculerverscarto.addStyleName("lien"); |
|
//création info bulle sur le lien "accès carto" |
406,9 → 420,6 |
//comment.setTabIndex(7); |
panneauSecondeColonne.add(comment, new AnchorLayoutData("95%") ); |
|
|
|
|
if (Window.getClientWidth()> Window.getClientHeight()) { |
panneauIntermediaire.add(panneauPremierColonne, new ColumnLayoutData(.5)); |
panneauIntermediaire.add(panneauSecondeColonne, new ColumnLayoutData(.5)); |
789,8 → 800,68 |
} |
}); |
|
latitude.addKeyPressListener(new EventCallback() { |
|
public void execute(EventObject e) { |
switch(e.getKey()) { |
case KEY_ALT: |
case KEY_CTRL: |
case KEY_DOWN: |
case KEY_END: |
case KEY_ESCAPE: |
case KEY_HOME: |
case KEY_LEFT: |
case KEY_PAGEDOWN: |
case KEY_PAGEUP: |
case KEY_RIGHT: |
case KEY_SHIFT: |
case KEY_TAB: |
case KEY_UP: |
|
break; |
|
case KEY_ENTER: |
validerSaisie(Champs.LATITUDE); |
break; |
|
default: |
latModifiee = true; |
} |
} |
}); |
|
longitude.addKeyPressListener(new EventCallback() { |
|
public void execute(EventObject e) { |
switch(e.getKey()) { |
case KEY_ALT: |
case KEY_CTRL: |
case KEY_DOWN: |
case KEY_END: |
case KEY_ESCAPE: |
case KEY_HOME: |
case KEY_LEFT: |
case KEY_PAGEDOWN: |
case KEY_PAGEUP: |
case KEY_RIGHT: |
case KEY_SHIFT: |
case KEY_TAB: |
case KEY_UP: |
|
break; |
|
case KEY_ENTER: |
validerSaisie(Champs.LONGITUDE); |
break; |
|
default: |
longModifiee = true; |
} |
} |
}); |
|
|
|
boutonOK.addListener(new ButtonListenerAdapter() { |
|
public void onClick(Button button, EventObject e) { |
999,13 → 1070,13 |
String nCommune = ""; |
|
|
if(infosCom.getLocation() != null && !infosCom.getLocation().equals("")) { |
nCommune += infosCom.getLocation(); |
if(infosCom.getCommune() != null && !infosCom.getCommune().equals("")) { |
nCommune += infosCom.getCommune(); |
} |
|
if(infosCom.getIdLocation() != null && !infosCom.getIdLocation().equals("")) { |
nCommune += " ("+infosCom.getIdLocation()+")"; |
departement = infosCom.getIdLocation(); |
if(infosCom.getIdLocalite() != null && !infosCom.getIdLocalite().equals("")) { |
nCommune += " ("+infosCom.getIdLocalite()+")"; |
departement = infosCom.getIdLocalite(); |
} |
|
commune.setValue(nCommune); |
1017,6 → 1088,11 |
if(infosCom.getLon() != null && !infosCom.getLon().equals("")) { |
longitude.setValue(infosCom.getLon()); |
} |
|
coordPanel.setVisible(true); |
|
latModifiee = true; |
longModifiee = true; |
} |
|
public void obtenirListeReferentielCommune() { |
1065,6 → 1141,12 |
} |
|
Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),date.getRawValue()); |
|
String[] coords = getValeurCoordonnees(); |
|
obs.setCoordonneeX(coords[0]); |
obs.setCoordonneeY(coords[1]); |
|
observationMediateur.ajouterObservation(obs); |
} |
|
1096,6 → 1178,11 |
Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),date.getRawValue()); |
obs.setNumeroOrdre(numeroOrdre); |
|
String[] coords = getValeurCoordonnees(); |
|
obs.setCoordonneeX(coords[0]); |
obs.setCoordonneeY(coords[1]); |
|
observationMediateur.modifierObservation(obs); |
|
selecteurMode.setValue("création"); |
1113,6 → 1200,8 |
String dateM = null; |
String especeM = null; |
String commM = null; |
String latM = null; |
String longM = null; |
|
String champs = modeleMessageModif; |
|
1184,6 → 1273,18 |
champs = champs.replaceAll(":commentaire", ""); |
} |
|
if(latModifiee) { |
latM = latitude.getText(); |
}else { |
champs = champs.replaceAll(":latitude", ""); |
} |
|
if(longModifiee) { |
longM = longitude.getText(); |
}else { |
champs = champs.replaceAll(":longitude", ""); |
} |
|
champs = champs.replaceAll(":",", "); |
if(champs.startsWith(",")) { |
champs = champs.replaceFirst(",", ""); |
1196,6 → 1297,8 |
} else { |
Observation obs = new Observation(especeM,numNomSelM,communeM,departementM,lieuDitM,stationM,milieuM, commM,dateM); |
obs.setNumeroOrdre(numeroOrdre); |
obs.setCoordonneeX(latM); |
obs.setCoordonneeY(longM); |
if(Window.confirm(message)) { |
observationMediateur.modifierObservationEnMasse(obs); |
reinitialiserValeurModifiees(); |
1274,7 → 1377,12 |
numeroOrdre = obs.getNumeroOrdre() ; |
} |
|
if(!obs.getCoordonneeX().equals("null") && !obs.getCoordonneeX().equals("000null") |
&& !obs.getCoordonneeY().equals("null") && !obs.getCoordonneeY().equals("000null")) { |
latitude.setValue(obs.getCoordonneeX()) ; |
longitude.setValue(obs.getCoordonneeY()) ; |
} |
} |
|
|
public void raz() |
1319,6 → 1427,14 |
numeroOrdre = ""; |
break; |
|
case LATITUDE: |
latitude.reset(); |
break; |
|
case LONGITUDE: |
longitude.reset(); |
break; |
|
case TOUT: |
commune.reset(); |
date.reset() ; |
1353,7 → 1469,7 |
} |
else |
{ |
boutonOK.setText("Ajouter") ; |
boutonOK.setText("Créer") ; |
setTitle("Saisir") ; |
boutonAnnuler.setText("Réinitialiser") ; |
modification = false ; |
1360,7 → 1476,6 |
selecteurMode.removeClass("x-selec-modif") ; |
selecteurMode.setCls("x-selec-crea") ; |
observationMediateur.onModeCreation(); |
|
} |
} |
|
1410,6 → 1525,8 |
String espece = null; |
String date = null; |
String notes = null; |
String lat = null; |
String lon = null; |
|
String ordreObs = ""; |
|
1423,6 → 1540,8 |
espece = comparerDifferencesChamps(espece, obsEnCours.getNomSaisi()); |
date = comparerDifferencesChamps(date, obsEnCours.getDate()); |
notes = comparerDifferencesChamps(notes, obsEnCours.getCommentaire()); |
lat = comparerDifferencesChamps(lat, obsEnCours.getCoordonneeX()); |
lon = comparerDifferencesChamps(lon, obsEnCours.getCoordonneeY()); |
|
ordreObs += obsEnCours.getNumeroOrdre()+","; |
} |
1429,6 → 1548,8 |
|
Observation obs=new Observation(espece,numeroNom,commune,departement,lieuDit,station,milieu, notes,date); |
obs.setNumeroOrdre(ordreObs); |
obs.setCoordonneeX(lat); |
obs.setCoordonneeY(lon); |
rafraichir(obs, false); |
|
} |
1458,6 → 1579,8 |
dateModifiee = false; |
especeModifiee = false; |
commModifie = false; |
latModifiee = false; |
longModifiee = false; |
} |
|
public void saisieTabindex() |
1473,7 → 1596,7 |
|
public void onFocus(Field field) { |
if(coordPanel.isVisible()) { |
longitude.focus(); |
latitude.focus(); |
} else { |
Ext.get("lien_carto").focus(); |
} |
1480,8 → 1603,8 |
} |
}); |
|
longitude.setTabIndex(8); |
latitude.setTabIndex(9); |
latitude.setTabIndex(8); |
longitude.setTabIndex(9); |
comment.setTabIndex(10); |
date.setTabIndex(11); |
espece.setTabIndex(12); |
1518,11 → 1641,34 |
} |
} |
|
private String[] getValeurCoordonnees() { |
double[] coDouble = coordonneesValides(); |
|
if(coDouble != null) { |
String[] coord = {coDouble[0]+"",coDouble[1]+""}; |
return coord; |
} else { |
String[] coord = {"000null","000null" }; |
return coord; |
} |
} |
|
private String obtenirDepartementAPartirChampCommune() { |
|
String dep = ""; |
|
if(departement.equals("000null") || departement.equals("")) { |
|
String[] depCom = commune.getText().split(" "); |
if(depCom.length > 1) { |
String dep = depCom[1].replace('(', ' '); |
dep = depCom[1].replace('(', ' '); |
} else { |
dep = ""; |
} |
} else { |
dep = departement; |
} |
|
dep =dep.replace(')', ' '); |
dep = dep.trim(); |
dep = dep.replace('\\',' '); |
1534,18 → 1680,20 |
if(nDep > 0 && nDep < 110) { |
departement = dep ; |
} |
|
if(departement.length() == 1) { |
departement = "0"+departement; |
} |
} |
catch(NumberFormatException e) |
{ |
departement = "" ; |
} |
} |
} |
|
return departement; |
} |
|
private Field obtenirCorrespondanceChampsEnum(Champs champ) { |
/*private Field obtenirCorrespondanceChampsEnum(Champs champ) { |
switch(champ) { |
case DATE: |
return date; |
1569,5 → 1717,5 |
return espece; |
} |
return null; |
}*/ |
} |
} |