Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 1857 → Rev 1858

/trunk/src/org/tela_botanica/client/vues/observation/FormulaireSaisieObservationVue.java
83,7 → 83,7
* Le médiateur associé à la vue
*/
private ObservationMediateur observationMediateur = null;
 
FormPanel panneauFormulaire = null;
 
private DateField date = null;
101,56 → 101,56
private String referentielGeo = null;
 
// 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;
 
@Override
public String toString() {
switch(this) {
case DATE:
return "date";
case COMMUNE:
return "commune";
case LIEUDIT:
return "lieu dit";
case STATION:
return "station";
case MILIEU:
return "milieu";
case COMMENT:
return "commentaire";
case ESPECE:
return "espèce";
case LATITUDE:
return "latitude";
case LONGITUDE:
return "longitude";
case ALTITUDE:
return "altitude";
case ABONDANCE:
return "abondance";
case CERTITUDE:
return "identification";
case REFERENTIELTAXO:
return "referentiel";
case PHENOLOGIE:
return "phenologie";
case TOUT:
return "date, commune, lieu dit, station, milieu, espèce, commentaire, latitude, longitude, altitude, abondance, identification, referentiel, phenologie";
}
157,7 → 157,7
return TOUT.toString();
}
};
 
private String formatDate = null ;
private Button boutonOK = new Button("Créer");
private Button boutonModifier = new Button("Modifier");
169,9 → 169,9
private boolean selectionAbondance = false;
private boolean selectionCertitude = false;
private boolean selectionPhenologie = false;
 
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;
185,7 → 185,7
private boolean certitudeModifiee = false;
private boolean referentielTaxoModifie = false;
private boolean phenologieModifiee = false;;
 
private final int KEY_ALT = 18;
private final int KEY_BACKSPACE = 8;
private final int KEY_CTRL = 17;
202,7 → 202,7
private final int KEY_SHIFT = 16;
private final int KEY_TAB = 9;
private final int KEY_UP = 38;
 
/**
* Booleen d'instanciation
*/
217,55 → 217,55
private TextField longitude;
 
private TextField latitude;
 
private TextField altitude;
 
private MultiFieldPanel htmlCommunePanel = null;
 
private MultiFieldPanel coordPanel;
 
private TextField coordonnees;
 
private Label lienSelectionCommune = null;
 
private HTML afficherFormulaireLatLon;
 
private HTML basculerverscarto;
 
private boolean longlatAjoutee;
 
private boolean latModifiee;
 
private boolean longModifiee;
 
private boolean altModifiee;
 
protected boolean rechercheCommuneEnCours = false;
 
private Timer tCoord;
final String resultTplRefPerso = "<div class=\"search-item-commune\">{element_referentiel}</div>";
private ComboBox selecteurAbondance = null;
private ComboBox selecteurCertitude = null;
 
final String resultTplRefPerso = "<div class=\"search-item-commune\">{element_referentiel}</div>";
 
private ComboBox selecteurAbondance = null;
 
private ComboBox selecteurCertitude = null;
 
private ComboBox selecteurReferentielTaxo = null;
 
private ComboBox selecteurStadePheno = null;
 
private boolean selectionMultiple = false;
 
private HTML lienAfficherChampsEtendus = null;
 
Panel conteneurChampEtenduGauche = null;
Panel conteneurChampEtenduDroite = null;
 
private boolean afficherChampsEtendus = false;
private boolean premierAffichage = true;
 
private Map<String, TextField> listeChampsEtendus;
 
/**
* Constructeur sans argument (privé car ne doit pas être utilisé)
*/
274,75 → 274,75
{
super() ;
}
 
/**
* Constructeur avec argument
* @param im
*/
public FormulaireSaisieObservationVue(ObservationMediateur obs)
{
{
super("Saisie");
// on associe le médiateur
observationMediateur = obs ;
 
referentielTaxo = obs.getRefTaxSelectionne().getCode();
panneauFormulaire = new FormPanel(Position.RIGHT);
panneauFormulaire.setBorder(false);
 
// Panneau intermediaire qui contient deux colonnes de formulaire
panneauIntermediaire = new Panel();
panneauIntermediaire = new Panel();
 
if (Window.getClientWidth()> Window.getClientHeight()) {
panneauIntermediaire.setLayout(new ColumnLayout());
panneauIntermediaire.setLayout(new ColumnLayout());
}
else {
panneauIntermediaire.setLayout(new RowLayout());
panneauIntermediaire.setLayout(new RowLayout());
}
 
panneauIntermediaire.setBorder(false);
 
//création du panneau formulaire de gauche auquels on ajoute les champs
panneauPremierColonne = new Panel();
panneauPremierColonne.setLayout(new FormLayout());
panneauPremierColonne = new Panel();
panneauPremierColonne.setLayout(new FormLayout());
panneauPremierColonne.setBorder(false);
 
//création du panneau formulaire de droite
panneauSecondeColonne = new Panel();
panneauSecondeColonne.setLayout(new FormLayout());
panneauSecondeColonne = new Panel();
panneauSecondeColonne.setLayout(new FormLayout());
panneauSecondeColonne.setBorder(false);
 
this.setPaddings(5) ;
 
// Accesskey pour debugging
commune=new ComboBox("Commune","commune\" accesskey=\"1");
final String resultTplCommune = "<div class=\"search-item-commune\">{commune}</div>";
commune=new ComboBox("Commune","commune\" 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.setTypeAhead(true);
commune.setLoadingText("Recherche...");
commune.setHideTrigger(true);
//création du lien "Accès carto" dans le formulaire
 
//création du lien "Accès carto" dans le formulaire
basculerverscarto = new HTML(" <a id=\"lien_carto\" href=\"#\" tabindex=\"2\">Localiser la commune</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 ");
ToolTip tip2 = new ToolTip();
tip2.setHtml("Via une carte, obtenez les coordonnées (latitude/longitude) de votre observation ");
tip2.applyTo(basculerverscarto.getElement());
 
//Sur une meme ligne, ajout de plusieurs champs
htmlCommunePanel = new MultiFieldPanel();
htmlCommunePanel = new MultiFieldPanel();
 
int largeurCommune = Window.getClientWidth()/4;
htmlCommunePanel.addToRow(commune, largeurCommune);
htmlCommunePanel.addToRow(basculerverscarto, 160);
htmlCommunePanel.addToRow(basculerverscarto, 160);
 
htmlCommunePanel.setBorder(false);
htmlCommunePanel.setId("x-commune-panel");
htmlCommunePanel.setId("x-commune-panel");
 
panneauPremierColonne.add(htmlCommunePanel);
 
356,53 → 356,53
@Override
public void onValidationSaisie() {
validerSaisie(Champs.STATION);
}
}
};
panneauPremierColonne.add(station, new AnchorLayoutData("95%"));
panneauPremierColonne.add(station, new AnchorLayoutData("95%"));
 
latitude = new TextField("Lat", "lat");
latitude.setGrowMax(70);
latitude.setAllowBlank(true);
 
longitude = new TextField("Lon", "lon");
longitude.setGrowMax(70);
longitude.setAllowBlank(true);
 
altitude = new TextField("Alt (mètres)", "alt");
altitude.setGrowMax(70);
altitude.setAllowBlank(true);
 
lienSelectionCommune = new Label("");
 
 
lienSelectionCommune.setId("conteneur_selection_commune");
lienSelectionCommune.setStyleName("conteneur_selection_commune");
lienSelectionCommune.addStyleName("lien_actif");
 
// Panneau de type plusieurs champs de formulaire sur une meme ligne, où seront renseignés Lat/Lon
coordPanel = new MultiFieldPanel();
coordPanel = new MultiFieldPanel();
coordPanel.setPaddings(0, 0, 0, 10);
coordPanel.setVisible(false);
 
final double largeur ;
largeur = 120;
coordPanel.addToRow(latitude, new ColumnLayoutData(largeur));
coordPanel.addToRow(longitude, new ColumnLayoutData(largeur));
coordPanel.addToRow(lienSelectionCommune, new ColumnLayoutData(largeur));
 
coordPanel.addToRow(latitude, new ColumnLayoutData(largeur));
coordPanel.addToRow(longitude, new ColumnLayoutData(largeur));
coordPanel.addToRow(lienSelectionCommune, new ColumnLayoutData(largeur));
lienSelectionCommune.addClass("lien_decale");
coordPanel.setBorder(false);
 
coordPanel.addToRow(altitude, new ColumnLayoutData(largeur));
//création du champs coordonnées
 
//création du champs coordonnées
referentielGeo = Configuration.getReferentielGeo();
 
coordonnees = new TextField("Coordonnées", "", 0);
coordonnees.setMaxLength(0);
coordonnees.setReadOnly(true);
coordonnees.setCls("fieldname");
 
//création du lien "saisie X/Y" dans le formulaire
afficherFormulaireLatLon = new HTML("<span style=\"padding-left:30px;\" class=\"conteneur_lien_afficher_lat_lon\">" +
"<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>" +
409,28 → 409,28
"<span><span style=\"padding-left:20px\" class=\"conteneur_lien_localiser_lat_lon\">"+
"<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>"+
"</span>");
//ajout d'un listener sur le lien "saisie X/Y"
 
//ajout d'un listener sur le lien "saisie X/Y"
coordPanel.addListener(new PanelListenerAdapter() {
 
@Override
public void onAfterLayout(Container c) {
surPremierAffichageCoordPanel(largeur);
}
});
 
//Sur une meme ligne, ajout de plusieurs champs
final MultiFieldPanel htmlPanel = new MultiFieldPanel();
htmlPanel.addToRow(coordonnees, 100);
htmlPanel.addToRow(afficherFormulaireLatLon, new ColumnLayoutData(0.9));
final MultiFieldPanel htmlPanel = new MultiFieldPanel();
 
htmlPanel.addToRow(coordonnees, 100);
htmlPanel.addToRow(afficherFormulaireLatLon, new ColumnLayoutData(0.9));
htmlPanel.setBorder(false);
htmlPanel.setId("x-coord-panel");
 
panneauPremierColonne.add(htmlPanel);
panneauPremierColonne.add(coordPanel);
date = new DateField("Date", "date", 250);
 
date = new DateField("Date", "date", 250);
date.setAllowBlank(true);
formatDate = "d/m/Y";
date.setFormat(formatDate) ;
437,11 → 437,11
date.setTitle("Date de l'observation au format jj/mm/aaaa");
date.setMaxValue(new Date());
//date.setTabIndex(5);
panneauPremierColonne.add(date, new AnchorLayoutData("55%"));
final String champsListeTpl = "<div class=\"x-combo-list-item search-item-tpl\" title=\"{label}\">{label}</div>";
panneauPremierColonne.add(date, new AnchorLayoutData("55%"));
 
final String champsListeTpl = "<div class=\"x-combo-list-item search-item-tpl\" title=\"{label}\">{label}</div>";
// Selection d'un référentiel par défaut (le premier spécifié dans la config)
referentielTaxo = Configuration.getReferentielsDispos().get(0).getCode();
selecteurReferentielTaxo = new ComboBox();
455,27 → 455,27
selecteurReferentielTaxo.setHideTrigger(false);
selecteurReferentielTaxo.setForceSelection(true);
selecteurReferentielTaxo.setTpl(champsListeTpl);
espece=new ComboBox("Espèce","nom");
final String resultTplEspece = "<div class=\"search-item-espece {indicateurNomRetenu}\">{nom}</div>";
espece=new ComboBox("Espèce","nom");
final String resultTplEspece = "<div class=\"search-item-espece {indicateurNomRetenu}\">{nom}</div>";
 
 
espece.setTpl(resultTplEspece);
espece.setMode(ComboBox.REMOTE);
espece.setItemSelector("div.search-item-espece");
espece.setTypeAhead(true);
espece.setLoadingText("Recherche...");
espece.setTypeAhead(true);
espece.setLoadingText("Recherche...");
 
espece.setHideTrigger(true);
 
Panel panelSeparationPp = new Panel();
panelSeparationPp.setHeight(15);
panelSeparationPp.setBorder(false);
 
panneauPremierColonne.add(panelSeparationPp);
panneauPremierColonne.add(selecteurReferentielTaxo, new AnchorLayoutData("85%"));
panneauPremierColonne.add(espece, new AnchorLayoutData("95%"));
panneauPremierColonne.add(selecteurReferentielTaxo, new AnchorLayoutData("85%"));
panneauPremierColonne.add(espece, new AnchorLayoutData("95%"));
 
selecteurAbondance = new ComboBox();
selecteurAbondance.setCls("champ-separation");
selecteurAbondance.setLabel("Abondance");
486,13 → 486,13
selecteurAbondance.setHideTrigger(false);
selecteurAbondance.setForceSelection(false);
selecteurAbondance.setTpl(champsListeTpl);
panneauPremierColonne.add(selecteurAbondance, new AnchorLayoutData("95%"));
panneauPremierColonne.add(selecteurAbondance, new AnchorLayoutData("95%"));
lieudit = new AutoCompletionRefComboBox("Lieu-dit", "lieudit",observationMediateur,TypesReferentiels.REFERENTIEL_LIEU_DIT) {
 
@Override
public void onModificationValeur() {
lieuDitModifie = true;
lieuDitModifie = true;
}
 
@Override
500,8 → 500,8
validerSaisie(Champs.LIEUDIT);
}
};
panneauSecondeColonne.add(lieudit, new AnchorLayoutData("95%"));
panneauSecondeColonne.add(lieudit, new AnchorLayoutData("95%"));
milieu = new AutoCompletionRefComboBox("Milieu","milieu",observationMediateur,TypesReferentiels.REFERENTIEL_MILIEU) {
 
@Override
513,22 → 513,22
public void onValidationSaisie() {
validerSaisie(Champs.MILIEU);
}
};
panneauSecondeColonne.add(milieu, new AnchorLayoutData("95%"));
comment = new TextArea("Notes", "comment");
 
comment = new TextArea("Notes", "comment");
comment.setAllowBlank(true);
comment.setHeight(50);
 
panneauSecondeColonne.add(comment, new AnchorLayoutData("95%") );
 
Panel panelSeparationPs = new Panel();
panelSeparationPs.setHeight(39);
panelSeparationPs.setBorder(false);
 
panneauSecondeColonne.add(panelSeparationPs);
 
selecteurCertitude = new ComboBox();
selecteurCertitude.setLabel("Identification");
selecteurCertitude.setStore(Ontologies.getValeursCertitude());
538,8 → 538,8
selecteurCertitude.setHideTrigger(false);
selecteurCertitude.setForceSelection(false);
selecteurCertitude.setTpl(champsListeTpl);
panneauSecondeColonne.add(selecteurCertitude, new AnchorLayoutData("95%"));
panneauSecondeColonne.add(selecteurCertitude, new AnchorLayoutData("95%"));
 
selecteurStadePheno = new ComboBox();
selecteurStadePheno.setLabel("Phénologie");
selecteurStadePheno.setStore(Ontologies.getValeursPhenologie());
549,8 → 549,8
selecteurStadePheno.setHideTrigger(false);
selecteurStadePheno.setForceSelection(false);
selecteurStadePheno.setTpl(champsListeTpl);
panneauSecondeColonne.add(selecteurStadePheno, new AnchorLayoutData("95%"));
panneauSecondeColonne.add(selecteurStadePheno, new AnchorLayoutData("95%"));
 
if (Window.getClientWidth() > Window.getClientHeight() || Window.getClientWidth() < 800) {
panneauIntermediaire.add(panneauPremierColonne, new ColumnLayoutData(.5));
panneauIntermediaire.add(panneauSecondeColonne, new ColumnLayoutData(.5));
557,11 → 557,11
}
else {
panneauIntermediaire.add(panneauPremierColonne);
panneauIntermediaire.add(panneauSecondeColonne);
panneauIntermediaire.add(panneauSecondeColonne);
}
 
panneauFormulaire.add(panneauIntermediaire);
 
if (Ext.isIE()) {
panneauPremierColonne.setButtonAlign(Position.RIGHT);
panneauPremierColonne.addButton(boutonOK);
570,34 → 570,34
panneauSecondeColonne.setButtonAlign(Position.LEFT);
panneauPremierColonne.addButton(boutonAnnuler);
}
else {
else {
panneauFormulaire.addButton(boutonOK);
panneauFormulaire.addButton(boutonModifier);
panneauFormulaire.addButton(boutonSupprimer);
panneauFormulaire.addButton(boutonAnnuler);
panneauFormulaire.addButton(boutonAnnuler);
}
 
this.add(panneauFormulaire) ;
 
this.setAutoScroll(true);
 
 
panneauFormulaire.addListener(new PanelListenerAdapter() {
@Override
public void onResize(BoxComponent component, int adjWidth, int adjHeight, int rawWidth, int rawHeight) {
panneauIntermediaire.setWidth(rawWidth);
panneauIntermediaire.setHeight(rawHeight);
panneauPremierColonne.doLayout();
panneauSecondeColonne.doLayout();
htmlCommunePanel.doLayout();
htmlPanel.doLayout();
doLayout();
}
});
 
lienAfficherChampsEtendus = new HTML("Afficher les champs étendus");
lienAfficherChampsEtendus.setStyleName("img-curseur-depl");
lienAfficherChampsEtendus.setStyleName("lienAfficherChampsEtendus");
613,7 → 613,7
conteneurChampEtenduDroite.hide();
}
lienAfficherChampsEtendus.setText("Afficher les champs étendus");
 
} else {
afficherChampsEtendus = true;
if(conteneurChampEtenduGauche != null && conteneurChampEtenduDroite != null) {
639,14 → 639,14
ajouterToolTipsBoutons();
saisieTabindex();
}
 
private void ajouterToolTipsBoutons() {
boutonOK.setTitle("Crée une nouvelle observation à partir des champs saisis dans le formulaire");
boutonModifier.setTitle("Modifie la ou les observations sélectionnées");
boutonSupprimer.setTitle("Supprime la ou les observations sélectionnées");
boutonAnnuler.setTitle("Vide tous les champs du formulaire");
boutonAnnuler.setTitle("Vide tous les champs du formulaire");
}
 
private void surPremierAffichageCoordPanel(final double largeur) {
ExtElement lienCoord = Ext.get("lien_coord");
lienCoord.removeAllListeners();
653,17 → 653,17
lienCoord.addListener("click", new EventCallback() {
@Override
public void execute(EventObject e) {
 
coordPanel.setVisible(!coordPanel.isVisible());
 
if(Ext.isIE()) {
latitude.focus();
}
 
CarnetEnLigneMediateur.fireResize();
}
}) ;
 
ExtElement lienCartoCoord = Ext.get("lien_carto_coord");
lienCartoCoord.removeAllListeners();
lienCartoCoord.addListener("click", new EventCallback() {
672,7 → 672,7
obtenirInformationCoord();
}
}) ;
 
ExtElement lienCarto = Ext.get("lien_carto");
lienCarto.removeAllListeners();
lienCarto.addListener("click", new EventCallback() {
679,32 → 679,32
 
@Override
public void execute(EventObject e) {
 
if(commune.getValue() != null && !commune.getValue().equals("") && !getDepartement().equals("")) {
obtenirInformationCommune();
longlatAjoutee = true;
 
} else {
Window.alert("Veuillez renseigner une commune et un numéro de département sous la forme : Commune (departement)");
}
}
});
 
if(!Ext.isIE() && Window.getClientWidth() < 1200) {
 
int largeurN = (int)largeur;
 
latitude.setWidth(largeurN+"px");
longitude.setWidth(largeurN+"px");
lienSelectionCommune.setWidth(largeurN+"px");
lienSelectionCommune.setWidth(largeurN+"px");
}
}
 
private void ajouterListeners()
{
// Listener completion communne
{
// Listener completion communne
final Rafraichissable r = this;
ListenerConfig listenerConfigCommune=new ListenerConfig();
listenerConfigCommune.setDelay(200);
listenerConfigCommune.setStopPropagation(false);
717,17 → 717,17
dateModifiee = true;
}
});
 
ListenerConfig listenerConfigAutocompletion=new ListenerConfig();
listenerConfigAutocompletion.setDelay(200);
listenerConfigAutocompletion.setStopPropagation(false);
listenerConfigAutocompletion.setStopEvent(false);
 
ListenerConfig listenerConfigEspece=new ListenerConfig();
listenerConfigEspece.setDelay(10);
listenerConfigEspece.setStopPropagation(false);
listenerConfigEspece.setStopEvent(false);
 
tCoord = new Timer() {
 
@Override
739,9 → 739,9
observationMediateur.obtenirInformationCoord(r,LatLng.newInstance(coord[0], coord[1]));
}
}
 
};
 
ajouterListenerChampEvenementsClavier(commune, listenerConfigCommune);
ajouterListenerChampEvenementsClavier(date);
ajouterListenerChampEvenementsClavier(selecteurReferentielTaxo);
750,118 → 750,118
ajouterListenerChampEvenementsClavier(latitude);
ajouterListenerChampEvenementsClavier(longitude);
ajouterListenerChampEvenementsClavier(altitude);
ajouterListenerChampEvenementsClavier(selecteurAbondance);
ajouterListenerChampEvenementsClavier(selecteurCertitude);
ajouterListenerChampEvenementsClavier(selecteurAbondance);
ajouterListenerChampEvenementsClavier(selecteurCertitude);
ajouterListenerChampEvenementsClavier(selecteurStadePheno);
ajouterListenerChampsCombobox();
 
boutonOK.addListener(new ButtonListenerAdapter() {
@Override
public void onClick(Button button, EventObject e) {
public void onClick(Button button, EventObject e) {
ajouterObservation();
}
}
});
 
boutonModifier.addListener(new ButtonListenerAdapter() {
@Override
public void onClick(Button button, EventObject e) {
public void onClick(Button button, EventObject e) {
if(selectionMultiple) {
modifierObservationEnMasse(null);
} else {
modifierObservation() ;
}
}
}
});
 
boutonSupprimer.addListener(new ButtonListenerAdapter() {
@Override
public void onClick(Button button, EventObject e) {
public void onClick(Button button, EventObject e) {
if(!selectionMultiple) {
supprimerObservation();
} else {
observationMediateur.supprimerObservations();
}
}
}
});
boutonAnnuler.addListener(new ButtonListenerAdapter() {
 
boutonAnnuler.addListener(new ButtonListenerAdapter() {
@Override
public void onClick(Button button, EventObject e) {
public void onClick(Button button, EventObject e) {
setSelectionMultiple(false);
raz();
}
}
});
 
this.addListener(new ContainerListenerAdapter() {
@Override
public void onAfterLayout(Container self) {
commune.focus();
}
});
});
}
 
private void ajouterListenerChampsCombobox() {
commune.addListener(new ComboBoxListenerAdapter() {
commune.addListener(new ComboBoxListenerAdapter() {
@Override
public void onSelect(ComboBox comboBox, Record record, int index) {
public void onSelect(ComboBox comboBox, Record record, int index) {
commune.setValue(record.getAsString("commune"));
departement=record.getAsString("departement");
codeInseeCommune=record.getAsString("codeInsee");
selectionCommune=true;
commune.collapse();
}
}
 
@Override
public void onExpand(ComboBox comboBox) {
comboBox.focus();
}
});
selecteurReferentielTaxo.addListener(new ComboBoxListenerAdapter() {
});
 
selecteurReferentielTaxo.addListener(new ComboBoxListenerAdapter() {
@Override
public void onSelect(ComboBox comboBox, Record record, int index) {
referentielTaxo = record.getAsString("valeur");
observationMediateur.setRefTaxSelectionne(index);
referentielTaxoModifie = true;
}
});
espece.addListener(new ComboBoxListenerAdapter() {
}
});
 
espece.addListener(new ComboBoxListenerAdapter() {
@Override
public void onSelect(ComboBox comboBox, Record record, int index) {
public void onSelect(ComboBox comboBox, Record record, int index) {
espece.setValue(record.getAsString("nom"));
numeroNom=record.getAsString("numeroNom");
selectionEspece=true;
observationMediateur.obtenirImageInformationExternes(referentielTaxo, numeroNom);
}
});
selecteurAbondance.addListener(new ComboBoxListenerAdapter() {
}
});
 
selecteurAbondance.addListener(new ComboBoxListenerAdapter() {
@Override
public void onSelect(ComboBox comboBox, Record record, int index) {
public void onSelect(ComboBox comboBox, Record record, int index) {
selectionAbondance=true;
abondanceModifiee = true;
}
});
selecteurCertitude.addListener(new ComboBoxListenerAdapter() {
 
selecteurCertitude.addListener(new ComboBoxListenerAdapter() {
 
@Override
public void onSelect(ComboBox comboBox, Record record, int index) {
public void onSelect(ComboBox comboBox, Record record, int index) {
selectionCertitude=true;
certitudeModifiee = true;
}
});
selecteurStadePheno.addListener(new ComboBoxListenerAdapter() {
});
 
selecteurStadePheno.addListener(new ComboBoxListenerAdapter() {
@Override
public void onSelect(ComboBox comboBox, Record record, int index) {
public void onSelect(ComboBox comboBox, Record record, int index) {
selectionPhenologie=true;
phenologieModifiee = true;
}
});
});
}
 
private void ajouterListenerChampEvenementsClavier(final TextField champ) {
champ.addKeyPressListener(new EventCallback() {
@Override
870,8 → 870,8
}
});
}
 
 
private void ajouterListenerChampEvenementsClavier(final TextField champ, final ListenerConfig config) {
champ.addKeyPressListener(new EventCallback() {
@Override
880,9 → 880,9
}
}, config);
}
 
private void surEvenementClavier(EventObject e, TextField champ) {
switch(e.getKey()) {
switch(e.getKey()) {
case KEY_ALT:
case KEY_CTRL:
case KEY_DOWN:
897,55 → 897,55
case KEY_TAB:
case KEY_UP:
break;
 
case KEY_ENTER:
surEvenementClavierToucheEntree(champ);
break;
 
default:
gererEvenementClavierDefaut(champ);
break;
}
}
 
private void surEvenementClavierToucheEntree(TextField champ) {
//TODO: faire un switch ou une enum
if(champ.equals(selecteurStadePheno)) {
if(!selectionPhenologie) {
validerSaisie(Champs.PHENOLOGIE);
if(!selectionPhenologie) {
validerSaisie(Champs.PHENOLOGIE);
} else {
selectionPhenologie = false;
}
}
 
if(champ.equals(selecteurCertitude)) {
if(!selectionCertitude) {
validerSaisie(Champs.CERTITUDE);
if(!selectionCertitude) {
validerSaisie(Champs.CERTITUDE);
} else {
selectionCertitude = false;
}
}
 
if(champ.equals(selecteurAbondance)) {
if(!selectionAbondance) {
validerSaisie(Champs.ABONDANCE);
if(!selectionAbondance) {
validerSaisie(Champs.ABONDANCE);
} else {
selectionAbondance = false;
}
}
 
if(champ.equals(longitude)) {
validerSaisie(Champs.LONGITUDE);
}
if(champ.equals(latitude)) {
validerSaisie(Champs.LATITUDE);
 
if(champ.equals(latitude)) {
validerSaisie(Champs.LATITUDE);
}
if(champ.equals(altitude)) {
validerSaisie(Champs.ALTITUDE);
 
if(champ.equals(altitude)) {
validerSaisie(Champs.ALTITUDE);
}
 
if(champ.equals(espece)) {
if(selectionEspece) {
especeModifiee = true;
952,19 → 952,19
selectionEspece=false;
}
else {
validerSaisie(Champs.ESPECE);
validerSaisie(Champs.ESPECE);
}
}
 
if(champ.equals(selecteurReferentielTaxo)) {
validerSaisie(Champs.REFERENTIELTAXO);
validerSaisie(Champs.REFERENTIELTAXO);
}
 
if(champ.equals(date)) {
validerSaisie(Champs.DATE);
validerSaisie(Champs.DATE);
}
if(champ.equals(commune)) {
 
if(champ.equals(commune)) {
if(champ.equals(commune)) {
if (selectionCommune) {
communeModifiee= true;
971,12 → 971,12
selectionCommune=false;
}
else {
validerSaisie(Champs.COMMUNE);
validerSaisie(Champs.COMMUNE);
}
}
}
}
 
private void gererEvenementClavierDefaut(TextField champ) {
//TODO: faire un switch ou une enum
if(champ.equals(selecteurStadePheno)) {
985,7 → 985,7
phenologieModifiee = true;
selectionPhenologie = false;
}
 
if(champ.equals(selecteurCertitude)) {
selecteurCertitude.setRawValue(selecteurCertitude.getRawValue());
selecteurCertitude.setValue(selecteurCertitude.getRawValue());
992,7 → 992,7
certitudeModifiee = true;
selectionCertitude = false;
}
 
if(champ.equals(selecteurAbondance)) {
selecteurAbondance.setRawValue(selecteurAbondance.getRawValue());
selecteurAbondance.setValue(selecteurAbondance.getRawValue());
999,53 → 999,53
abondanceModifiee = true;
selectionAbondance = false;
}
 
if(champ.equals(longitude)) {
longModifiee = true;
tCoord.cancel();
tCoord.schedule(250);
}
if(champ.equals(latitude)) {
 
if(champ.equals(latitude)) {
latModifiee = true;
tCoord.cancel();
tCoord.schedule(250);
}
if(champ.equals(altitude)) {
altModifiee = true;
 
if(champ.equals(altitude)) {
altModifiee = true;
}
 
if(champ.equals(comment)) {
commModifie = true;
}
 
if(champ.equals(espece)) {
numeroNom="";
obtenirListeReferentielNom();
especeModifiee = true;
}
 
if(champ.equals(selecteurReferentielTaxo)) {
referentielTaxoModifie = true;
}
 
if(champ.equals(date)) {
dateModifiee = true;
}
 
if(champ.equals(commune)) {
departement="";
commune.collapse();
commune.collapse();
obtenirListeReferentielCommune();
communeModifiee= true;
communeModifiee= true;
}
}
 
/**
* Validation de la saisie
* Validation de la saisie
*/
 
private void validerSaisie(Champs champs) {
if(!selectionMultiple) {
ajouterObservation();
1054,7 → 1054,7
modifierObservationEnMasse(champs);
}
}
 
/**
* Desactive visuellement ce panneau
*/
1062,7 → 1062,7
{
this.setDisabled(true) ;
}
 
/**
* Active visuellement ce panneau
*/
1073,7 → 1073,7
 
@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)
{
1080,36 → 1080,36
ListeReferentielCommune data = (ListeReferentielCommune) nouvelleDonnees ;
Object[][] communeData = 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();)
{
for (Iterator it = data.keySet().iterator(); it.hasNext();)
{
ReferentielCommune ref=data.get(it.next());
 
communeData[i][0]= ref.getCommune();
communeData[i][1]= ref.getDepartement();
communeData[i][2]= ref.getCodeInsee();
i++ ;
}
 
// creation du store
FieldDef defCommune = new StringFieldDef("commune");
FieldDef defDepartement = new StringFieldDef("departement");
FieldDef defCodeInsee = new StringFieldDef("codeInsee");
 
FieldDef[] defTab = { defCommune, defDepartement, defCodeInsee};
 
RecordDef rd = new RecordDef(defTab);
 
final MemoryProxy dataProxy = new MemoryProxy(communeData);
final ArrayReader reader = new ArrayReader(rd);
Store store=new Store(dataProxy,reader);
final ArrayReader reader = new ArrayReader(rd);
 
Store store=new Store(dataProxy,reader);
commune.setStore(store);
store.load();
 
}
 
// si l'on a reçu une liste du référentiel nom (complétion referentiel nom)
if(nouvelleDonnees instanceof ListeReferentielNom)
{
1118,11 → 1118,11
int i = 0 ;
 
// on la parse et on récupère les informations qui nous interessent
for (Iterator it = data.keySet().iterator(); it.hasNext();)
for (Iterator it = data.keySet().iterator(); it.hasNext();)
{
 
ReferentielNom ref=data.get(it.next());
 
nomData[i][0]= ref.getNom();
nomData[i][1]= ref.getNumeroNom();
if (ref.getStatut().equals("3")) {
1130,7 → 1130,7
}
else {
nomData[i][2]="";
}
}
i++ ;
}
 
1137,21 → 1137,21
FieldDef defNom = new StringFieldDef("nom");
FieldDef defNumeroNom = new StringFieldDef("numeroNom");
FieldDef indicateurNomRetenu = new StringFieldDef("indicateurNomRetenu");
 
FieldDef[] defTab = { defNom, defNumeroNom, indicateurNomRetenu};
 
RecordDef rd = new RecordDef(defTab);
 
final MemoryProxy dataProxy = new MemoryProxy(nomData);
final ArrayReader reader = new ArrayReader(rd);
Store store=new Store(dataProxy,reader);
final ArrayReader reader = new ArrayReader(rd);
 
Store store=new Store(dataProxy,reader);
espece.setStore(store);
store.load() ;
}
// On recoit une observation dont on veut afficher le detail
 
// On recoit une observation dont on veut afficher le detail
 
if(nouvelleDonnees instanceof Observation)
{
Observation obs = (Observation)nouvelleDonnees ;
1158,26 → 1158,26
setSelectionMultiple(false);
afficherDetailsObservation(obs) ;
}
 
if(nouvelleDonnees instanceof ListeObservation) {
 
ListeObservation listeObs = (ListeObservation)nouvelleDonnees;
setSelectionMultiple(true);
calculerAfficherDifferences(listeObs);
}
 
if(nouvelleDonnees instanceof String)
{
String str = (String)nouvelleDonnees ;
observationMediateur.obtenirNombreObservation() ;
}
 
if(nouvelleDonnees instanceof String[]) {
String[] anumNom = (String[])nouvelleDonnees ;
numeroNom = anumNom[1];
espece.setValue(anumNom[0]);
}
 
if(nouvelleDonnees instanceof EntiteGeographiqueObservation)
{
EntiteGeographiqueObservation infosComm = (EntiteGeographiqueObservation)nouvelleDonnees ;
1188,26 → 1188,26
}
}
}
 
private void afficherIndicationCommune(
final EntiteGeographiqueObservation infosCom) {
 
String nCommune = "";
if(infosCom != null && !infosCom.getZoneGeo().trim().equals("")){
nCommune += infosCom.getZoneGeo();
if(!infosCom.getIdZoneGeo().trim().equals(""))
nCommune += " ("+Util.convertirChaineZoneGeoVersDepartement(infosCom.getIdZoneGeo())+")";
 
lienSelectionCommune.setHtml("<a id=\"lien_selection_commune\" tabindex=\"9\">"+nCommune+"</a>");
lienSelectionCommune.setStyleName("img-curseur-depl");
 
Ext.get("lien_selection_commune").addListener("click",new EventCallback() {
@Override
public void execute(EventObject e) {
rafraichirCommune(infosCom);
}
}
});
 
Ext.get("lien_selection_commune").addListener("keypress",new EventCallback() {
@Override
public void execute(EventObject e) {
1214,23 → 1214,23
if(e.getCharCode() == KEY_ENTER) {
rafraichirCommune(infosCom);
}
}
}
});
 
Ext.get("lien_selection_commune").addListener("focus",new EventCallback() {
@Override
public void execute(EventObject e) {
Ext.get("lien_selection_commune").toggleClass("lien_sel");
}
}
});
 
Ext.get("lien_selection_commune").addListener("blur",new EventCallback() {
@Override
public void execute(EventObject e) {
Ext.get("lien_selection_commune").toggleClass("lien_sel");
}
}
});
 
} else {
if(rechercheCommuneEnCours) {
lienSelectionCommune.setHtml("<span id=\"aucune_selection_commune\"> Erreur de localisation </span>");
1242,14 → 1242,14
Ext.get(lienSelectionCommune.getElement()).unmask();
rechercheCommuneEnCours = false;
}
 
private void rafraichirCommune(EntiteGeographiqueObservation infosCom) {
String nCommune = "";
 
if(infosCom.getZoneGeo() != null && !infosCom.getZoneGeo().equals("")) {
nCommune += infosCom.getZoneGeo();
}
 
if(infosCom.getIdZoneGeo() != null && !infosCom.getIdZoneGeo().equals("")) {
String codeGeoFormate = Util.convertirChaineZoneGeoVersDepartement(infosCom.getIdZoneGeo());
nCommune += " ("+codeGeoFormate+")";
1263,7 → 1263,7
// on ne remplace la commune que si le champ était vide
if(commune.getRawValue() == null || commune.getRawValue().equals("")) {
rafraichirCommune(infosCom);
}
}
 
if(infosCom.getLat() != null && !infosCom.getLat().equals("")) {
latitude.setValue(infosCom.getLat());
1272,34 → 1272,34
if(infosCom.getLon() != null && !infosCom.getLon().equals("")) {
longitude.setValue(infosCom.getLon());
}
 
latModifiee = true;
longModifiee = true;
 
coordPanel.setVisible(true);
}
 
public void obtenirListeReferentielCommune() {
 
String com=commune.getText();
com=com.replaceAll("%","");
 
observationMediateur.obtenirListeReferentielCommune(this,com);
 
}
public void obtenirListeReferentielNom() {
 
public void obtenirListeReferentielNom() {
String esp=espece.getText().replaceAll(" ","/*");
esp=esp.replaceAll("%","");
String referentiel = this.referentielTaxo;
observationMediateur.obtenirListeReferentielNom(this,referentiel ,esp);
 
observationMediateur.obtenirListeReferentielNom(this,referentiel ,esp);
}
protected void obtenirReferentielStation() {
 
protected void obtenirReferentielStation() {
observationMediateur.obtenirListeReferentielPerso(this,TypesReferentiels.REFERENTIEL_STATION,station.getText());
}
 
protected void obtenirListeReferentielMilieu() {
observationMediateur.obtenirListeReferentielPerso(this,TypesReferentiels.REFERENTIEL_MILIEU,milieu.getText());
}
1307,15 → 1307,15
protected void obtenirReferentielLieuDit() {
observationMediateur.obtenirListeReferentielPerso(this,TypesReferentiels.REFERENTIEL_LIEU_DIT,lieudit.getText());
}
 
public void ajouterObservation() {
 
if(date.getRawValue() != null && !date.getRawValue().equals("") && !Util.verifierDateFormatCel(date.getRawValue())) {
Window.alert("Attention la date saisie est invalide, la date doit être au format jj/mm/aaaa");
date.setInvalidText("Date invalide");
return;
}
 
if(departement != null) {
if(departement.equals("000null") || departement.equals("")) {
String[] depCom = commune.getText().split(" ");
1325,7 → 1325,7
dep = dep.trim();
dep = dep.replace('\\',' ');
dep = dep.trim();
 
try
{
int nDep = Integer.parseInt(dep);
1343,8 → 1343,8
 
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,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),dateObs);
 
String[] coords = getValeurCoordonnees();
obs.setLatitude(coords[0]);
obs.setLongitude(coords[1]);
1353,25 → 1353,25
obs.setAbondance(getAbondance());
obs.setCertitude(getCertitude());
obs.setPhenologie(getPhenologie());
 
obs.setReferentielTaxo(Ontologies.getInfosReferentielNomParCode(referentielTaxo).getCodeVersionComplet());
obs.setChampsEtendus(getValeursChampsEtendus());
 
observationMediateur.ajouterObservation(obs);
}
 
private void modifierObservation() {
 
if(!Window.confirm("Êtes-vous sur de vouloir modifier l'observation sélectionnée ?")) {
return;
}
 
if(date.getRawValue() != null && !date.getRawValue().equals("") && !Util.verifierDateFormatCel(date.getRawValue())) {
Window.alert("Attention la date saisie est invalide, la date doit être au format jj/mm/aaaa");
date.setInvalidText("Date invalide");
return;
}
 
if(departement.equals("000null") || departement.equals("")) {
String[] depCom = commune.getText().split(" ");
if(depCom.length > 1) {
1380,7 → 1380,7
dep = dep.trim();
dep = dep.replace('\\',' ');
dep = dep.trim();
 
try
{
int nDep = Integer.parseInt(dep);
1394,29 → 1394,29
}
}
}
 
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);
obs.setNumeroOrdre(numeroOrdre);
 
String[] coords = getValeurCoordonnees();
 
obs.setLatitude(coords[0]);
obs.setLongitude(coords[1]);
obs.setAltitude(altitude.getText());
 
obs.setAbondance(getAbondance());
obs.setCertitude(getCertitude());
obs.setPhenologie(getPhenologie());
obs.setReferentielTaxo(getReferentielTaxo());
obs.setChampsEtendus(getValeursChampsEtendus());
 
observationMediateur.modifierObservation(obs);
}
 
private void modifierObservationEnMasse(Champs champModifie) {
 
//TODO: factoriser
String communeM = null;
String departementM = null;
1426,7 → 1426,7
String milieuM = null;
String dateM = null;
String especeM = null;
String commM = null;
String commM = null;
String latM = null;
String longM = null;
String altM = null;
1434,12 → 1434,12
String certitudeM = null;
String referentielTaxoM = null;
String phenologieM = null;
 
String champs = modeleMessageModif;
if(communeModifiee) {
 
if(communeModifiee && ! commune.getRawValue().equals(VALEURS_MULTIPLES)) {
communeM = commune.getText();
 
if(departement.equals("000null") || departement.equals("")) {
String[] depCom = commune.getText().split(" ");
if(depCom.length > 1) {
1448,113 → 1448,111
dep = dep.trim();
dep = dep.replace('\\',' ');
dep = dep.trim();
try
{
 
try {
int nDep = Integer.parseInt(dep);
if(nDep > 0 && nDep < 110) {
departement = dep ;
}
}
catch(NumberFormatException e)
{
catch(NumberFormatException e) {
departement = "" ;
}
}
}
departementM = departement;
} else {
}
else {
champs = champs.replaceAll("commune", "");
}
if(lieuDitModifie) {
 
if(lieuDitModifie && ! lieudit.getRawValue().equals(VALEURS_MULTIPLES)) {
lieuDitM = lieudit.getText();
}else {
} else {
champs = champs.replaceAll(":lieu-dit", "");
}
if(stationModifiee) {
 
if(stationModifiee && ! station.getRawValue().equals(VALEURS_MULTIPLES)) {
stationM = station.getText();
}else {
} else {
champs = champs.replaceAll(":station", "");
}
 
if(milieuModifie) {
if(milieuModifie && ! milieu.getRawValue().equals(VALEURS_MULTIPLES)) {
milieuM = milieu.getText();
}else {
} else {
champs = champs.replaceAll(":milieu", "");
}
 
if(dateModifiee && !date.getRawValue().equals(VALEURS_MULTIPLES)) {
if(dateModifiee && ! date.getRawValue().equals(VALEURS_MULTIPLES)) {
dateM = date.getRawValue();
dateM = Util.remplacerSeparateursDateFormatCel(dateM);
}else {
} else {
champs = champs.replaceAll(":date", "");
}
 
if(especeModifiee) {
if(especeModifiee && ! espece.getRawValue().equals(VALEURS_MULTIPLES)) {
especeM = espece.getText();
numNomSelM = numeroNom;
}else {
} else {
champs = champs.replaceAll(":espece", "");
}
 
if(commModifie) {
if(commModifie && ! comment.getRawValue().equals(VALEURS_MULTIPLES)) {
commM = comment.getText();
}else {
} else {
champs = champs.replaceAll(":commentaire", "");
}
if(latModifiee) {
 
if(latModifiee && ! latitude.getRawValue().equals(VALEURS_MULTIPLES)) {
latM = latitude.getText();
}else {
} else {
champs = champs.replaceAll(":latitude", "");
}
if(altModifiee) {
 
if(altModifiee && ! altitude.getRawValue().equals(VALEURS_MULTIPLES)) {
altM = altitude.getText();
}else {
} else {
champs = champs.replaceAll(":altitude", "");
}
if(longModifiee) {
 
if(longModifiee && ! longitude.getRawValue().equals(VALEURS_MULTIPLES)) {
longM = longitude.getText();
}else {
} else {
champs = champs.replaceAll(":longitude", "");
}
 
if(abondanceModifiee && !selecteurAbondance.getRawValue().equals(VALEURS_MULTIPLES)) {
abondanceM = getAbondance();
} else {
champs = champs.replaceAll(":abondance", "");
}
 
if(certitudeModifiee && !selecteurCertitude.getRawValue().equals(VALEURS_MULTIPLES)) {
certitudeM = getCertitude();
} else {
champs = champs.replaceAll(":identification", "");
}
 
if(referentielTaxoModifie && !selecteurReferentielTaxo.getRawValue().equals(VALEURS_MULTIPLES)) {
referentielTaxoM = getReferentielTaxo();
} else {
champs = champs.replaceAll(":referentiel", "");
}
 
if(phenologieModifiee && !selecteurStadePheno.getRawValue().equals(VALEURS_MULTIPLES)) {
phenologieM = getPhenologie();
} else {
champs = champs.replaceAll(":phenologie", "");
}
 
champs = champs.replaceAll(":",", ");
if(champs.startsWith(",")) {
champs = champs.replaceFirst(",", "");
}
 
String message = "Voulez vous modifier le(s) champ(s) suivant(s) : "+champs+" pour les observations selectionnées ?" ;
 
if(champs.trim().equals("")) {
Window.alert("Aucun champ n'a été modifié");
} else {
1573,11 → 1571,11
}
}
}
private void supprimerObservation() {
 
private void supprimerObservation() {
observationMediateur.supprimerObservation(this, numeroOrdre);
}
 
public void afficherDetailsObservation(Observation obs)
{
raz() ;
1597,7 → 1595,7
idLoc = idLoc.substring(0,2);
}
}
 
if(!obs.getDate().equals("null") && !obs.getDate().equals("000null") && !obs.getDate().equals(VALEURS_MULTIPLES)) {
String[] dateEtHeure = obs.getDate().split(" ", 2);
if(verifierFormatDate(dateEtHeure[0])) {
1605,7 → 1603,7
}
else
{
date.setRawValue("");
date.setRawValue("");
}
} else {
date.setRawValue(VALEURS_MULTIPLES);
1623,7 → 1621,7
if(!obs.getCommentaire().equals("null") && !obs.getCommentaire().equals("000null")) {
 
comment.setRawValue(Util.remplacerSautsDeligneMalEncodes(obs.getCommentaire()));
 
}
if(!obs.getLocalite().equals("null") && !obs.getLocalite().equals("000null")) {
if(!idLoc.equals("000null") && !idLoc.equals("")) {
1650,25 → 1648,25
if(!obs.getNumeroOrdre().equals("null") && !obs.getNumeroOrdre().equals("000null")) {
numeroOrdre = obs.getNumeroOrdre() ;
}
 
if(doitAfficherLatLon(obs)) {
latitude.setValue(Util.formaterNombre(obs.getLatitude())) ;
longitude.setValue(Util.formaterNombre(obs.getLongitude())) ;
}
 
if(!obs.getAltitude().isEmpty() && !obs.getAltitude().equals("null") && !obs.getAltitude().equals("000null")) {
altitude.setValue(Util.formaterNombre(obs.getAltitude())) ;
}
 
selecteurAbondance.getStore().load();
selecteurAbondance.setValue(obs.getAbondance());
 
selecteurCertitude.getStore().load();
selecteurCertitude.setValue(obs.getCertitude());
 
selecteurStadePheno.getStore().load();
selecteurStadePheno.setValue(obs.getPhenologie());
 
selecteurReferentielTaxo.getStore().load();
if(obs.getReferentielTaxo() != VALEURS_MULTIPLES) {
referentielTaxo = obs.getCodeCourtReferentielTaxo();
1680,21 → 1678,21
referentielTaxo = "";
selecteurReferentielTaxo.setRawValue(VALEURS_MULTIPLES);
}
 
afficherChampsEtendus(obs);
}
 
private boolean doitAfficherLatLon(Observation obs) {
return !obs.getLatitude().isEmpty() &&
!obs.getLatitude().equals("null") &&
!obs.getLatitude().equals("null") &&
!obs.getLatitude().equals("000null") &&
!Util.estZero(obs.getLatitude()) &&
!obs.getLongitude().isEmpty() &&
!obs.getLongitude().equals("null") &&
!Util.estZero(obs.getLatitude()) &&
!obs.getLongitude().isEmpty() &&
!obs.getLongitude().equals("null") &&
!obs.getLongitude().equals("000null") &&
!Util.estZero(obs.getLongitude());
}
 
private void viderChampsEtendus() {
if(listeChampsEtendus != null) {
for (Iterator<String> it = listeChampsEtendus.keySet().iterator(); it.hasNext();) {
1710,21 → 1708,21
listeChampsEtendus = null;
}
}
 
private void afficherChampsEtendus(Observation obs) {
viderChampsEtendus();
 
FormLayout flmd = new FormLayout();
flmd.setLabelWidth(150);
 
FormLayout flmg = new FormLayout();
flmg.setLabelWidth(150);
 
conteneurChampEtenduGauche = new Panel();
conteneurChampEtenduGauche.setLayout(flmg);
conteneurChampEtenduDroite = new Panel();
conteneurChampEtenduDroite.setLayout(flmd);
 
conteneurChampEtenduGauche.setAutoWidth(true);
conteneurChampEtenduGauche.setStyle("conteneurChampsEtendus");
conteneurChampEtenduGauche.setBodyBorder(false);
1731,10 → 1729,10
conteneurChampEtenduDroite.setAutoWidth(true);
conteneurChampEtenduDroite.setStyle("conteneurChampsEtendus");
conteneurChampEtenduDroite.setBodyBorder(false);
 
// pour corriger le décalage sur le panneau induit par le lien d'affichage
conteneurChampEtenduDroite.setPaddings(25, 0, 0, 0);
 
if(obs.getChampsEtendus() != null && obs.getChampsEtendus().size() > 0) {
lienAfficherChampsEtendus.setVisible(true);
listeChampsEtendus = new HashMap<String, TextField>(obs.getChampsEtendus().size());
1744,7 → 1742,7
ChampEtendu champ = obs.getChampsEtendus().get(id);
String valeur = champ.getValeur();
String label = champ.getLabel();
 
TextField champTexteEtendu = new TextField();
champTexteEtendu.setWidth("90%");
champTexteEtendu.setLabel(label);
1759,10 → 1757,10
listeChampsEtendus.put(id, champTexteEtendu);
gauche = !gauche;
}
 
panneauPremierColonne.add(conteneurChampEtenduGauche);
panneauSecondeColonne.add(conteneurChampEtenduDroite);
 
if(!afficherChampsEtendus) {
conteneurChampEtenduGauche.setVisible(false);
conteneurChampEtenduDroite.setVisible(false);
1772,7 → 1770,7
}
doLayout();
}
 
private Map<String, ChampEtendu> getValeursChampsEtendus() {
Map<String, ChampEtendu> valeursChampsEtendus = new HashMap<String, ChampEtendu>();
if(listeChampsEtendus != null) {
1787,11 → 1785,11
}
return valeursChampsEtendus;
}
 
public void raz()
{
raz(Champs.TOUT);
 
}
public void raz(Champs champs)
{
1799,19 → 1797,19
case DATE:
date.reset() ;
break;
 
case LIEUDIT:
lieudit.reset() ;
break;
 
case STATION:
station.reset() ;
break;
 
case MILIEU:
milieu.reset() ;
break;
 
case COMMENT:
comment.reset() ;
break;
1822,43 → 1820,43
latitude.reset();
longitude.reset();
break;
 
case ESPECE:
espece.reset();
numeroNom = "" ;
numeroOrdre = "";
break;
 
case LATITUDE:
latitude.reset();
afficherIndicationCommune(null);
break;
 
case LONGITUDE:
longitude.reset();
afficherIndicationCommune(null);
break;
 
case ALTITUDE:
altitude.reset();
break;
 
case ABONDANCE:
selecteurAbondance.setValue("");
break;
 
case CERTITUDE:
selecteurCertitude.setValue("");
break;
 
case REFERENTIELTAXO:
selecteurReferentielTaxo.setValue("");
break;
 
case PHENOLOGIE:
selecteurStadePheno.setValue("");
break;
 
case TOUT:
commune.reset();
date.reset() ;
1883,11 → 1881,11
break;
 
}
 
}
 
public boolean verifierFormatDate(String date) {
 
String regex = "[1-9][0-9]{3}-[0-9]{2}-[0-9]{2}" ;
if(date.matches(regex) && !date.equals("0000-00-00")) {
return true ;
1907,13 → 1905,13
boutonOK.disable();
}
}
 
public boolean getSelectionMultiple() {
return selectionMultiple;
}
 
private void calculerAfficherDifferences(ListeObservation listeObs) {
 
String departement = null;
String commune = null;
String lieuDit = null;
1929,9 → 1927,9
String certitude = null;
String referentielTaxo = null;
String phenologie = null;
 
String ordreObs = "";
 
for(Iterator<String> it = listeObs.keySet().iterator();it.hasNext();) {
Observation obsEnCours = listeObs.get(it.next());
departement = comparerDifferencesChamps(departement, obsEnCours.getIdentifiantLocalite());
1939,7 → 1937,7
lieuDit = comparerDifferencesChamps(lieuDit, obsEnCours.getLieudit());
station = comparerDifferencesChamps(station, obsEnCours.getStation());
milieu = comparerDifferencesChamps(milieu, obsEnCours.getMilieu());
espece = comparerDifferencesChamps(espece, obsEnCours.getNomSaisi());
espece = comparerDifferencesChamps(espece, obsEnCours.getNomSaisi());
date = comparerDifferencesChamps(date, obsEnCours.getDate());
notes = comparerDifferencesChamps(notes, obsEnCours.getCommentaire());
lat = comparerDifferencesChamps(lat, obsEnCours.getLatitude());
1949,10 → 1947,10
certitude = comparerDifferencesChamps(certitude, obsEnCours.getCertitude());
referentielTaxo = comparerDifferencesChamps(referentielTaxo, obsEnCours.getReferentielTaxo());
phenologie = comparerDifferencesChamps(phenologie, obsEnCours.getPhenologie());
 
ordreObs += obsEnCours.getNumeroOrdre()+",";
}
 
Observation obs=new Observation(espece,numeroNom,commune,departement,lieuDit,station,milieu, notes,date);
obs.setNumeroOrdre(ordreObs);
obs.setLatitude(lat);
1962,13 → 1960,13
obs.setCertitude(certitude);
obs.setReferentielTaxo(referentielTaxo);
obs.setPhenologie(phenologie);
afficherDetailsObservation(obs);
afficherDetailsObservation(obs);
}
 
private String comparerDifferencesChamps(String valeurActuelle, String nouvelleValeur) {
 
String retour = "000null";
 
if(valeurActuelle == null) {
retour = nouvelleValeur;
} else {
1980,8 → 1978,8
}
return retour;
}
private void reinitialiserValeurModifiees() {
 
private void reinitialiserValeurModifiees() {
communeModifiee = false;
lieuDitModifie = false;
stationModifiee = false;
1997,7 → 1995,7
referentielTaxoModifie = false;
phenologieModifiee = false;
}
 
public void saisieTabindex()
{
commune.setTabIndex(1);
2014,9 → 2012,9
} else {
Ext.get("lien_carto").focus();
}
}
}
});
 
latitude.setTabIndex(8);
longitude.setTabIndex(9);
altitude.setTabIndex(10);
2028,9 → 2026,9
selecteurStadePheno.setTabIndex(16);
boutonOK.setTabIndex(17);
boutonAnnuler.setTabIndex(18);
 
}
 
private void obtenirInformationCoord() {
if(coordonneesValides() != null) {
observationMediateur.obtenirInformationCoord(LatLng.newInstance(coordonneesValides()[0],coordonneesValides()[1]));
2039,29 → 2037,29
}
 
}
 
private void obtenirInformationCommune() {
observationMediateur.obtenirInformationCommune(getCommuneSansDepartement(), Util.obtenirDepartementAPartirChaineCommune(departement, commune.getText()));
}
 
public double[] coordonneesValides() {
 
try {
 
double lat = Double.parseDouble(latitude.getValueAsString().replaceAll(",", "."));
double lon = Double.parseDouble(longitude.getValueAsString().replaceAll(",", "."));
 
double[] coord = {lat, lon};
return coord;
 
} catch (NumberFormatException ne) {
return null;
}
}
 
private String[] getValeurCoordonnees() {
double[] coDouble = coordonneesValides();
 
if(coDouble != null) {
String[] coord = {coDouble[0]+"",coDouble[1]+""};
return coord;
2070,33 → 2068,33
return coord;
}
}
 
public String getCommune() {
 
String valeurCommune = "";
 
if(commune.getValue() != null) {
valeurCommune = commune.getValue();
valeurCommune = commune.getValue();
}
return valeurCommune;
}
 
public String getDepartement() {
return Util.obtenirDepartementAPartirChaineCommune(departement, commune.getText());
}
 
public String getCommuneSansDepartement() {
return Util.supprimerNumDepartementChaineLocalite(getCommune());
}
 
private String getValeurChampListeLibre(ComboBox champ) {
String valeurChamp = champ.getValue();
String valeurChampBrute = champ.getRawValue();
 
// Test idiot qui permet de savoir si l'on utilise la valeur saisie directement ou bien la valeur
// selectionnee car lors du setValue sur le keypress, gwtext ne prends pas en compte le dernier
// selectionnee car lors du setValue sur le keypress, gwtext ne prends pas en compte le dernier
// caractère
 
if(valeurChampBrute.trim().length() == 0) {
valeurChamp = "";
} else {
2112,15 → 2110,15
public String getAbondance() {
return getValeurChampListeLibre(selecteurAbondance);
}
 
public String getCertitude() {
return getValeurChampListeLibre(selecteurCertitude);
}
 
public String getPhenologie() {
return getValeurChampListeLibre(selecteurStadePheno);
}
 
public String getReferentielTaxo() {
String codeCourt = getValeurChampListeLibre(selecteurReferentielTaxo);
return Ontologies.getInfosReferentielNomParCode(codeCourt).getCodeVersionComplet();
2129,13 → 2127,13
public boolean communeInitialisee() {
return communeModifiee;
}
 
public void redimensionnerFormulaire() {
afficherFormulaireLatLon.setWidth(panneauIntermediaire.getWidth()+"px");
panneauPremierColonne.doLayout();
panneauSecondeColonne.doLayout();
panneauIntermediaire.doLayout();
 
doLayout();
}
}