92,13 → 92,13 |
private String numeroNom = null; |
private String numeroOrdre = null; |
private String codeInseeCommune = null; |
|
private String referentielTaxo = 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, LATITUDE, LONGITUDE, ABONDANCE, CERTITUDE; |
DATE, LIEUDIT, STATION, MILIEU, COMMENT, COMMUNE, ESPECE, TOUT, LATITUDE, LONGITUDE, ABONDANCE, CERTITUDE, REFERENTIELTAXO, PHENOLOGIE; |
|
@Override |
public String toString() { |
136,9 → 136,15 |
|
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, abondance, identification"; |
return "date, commune, lieu dit, station, milieu, espèce, commentaire, latitude, longitude, abondance, identification, referentiel, phenologie"; |
} |
return TOUT.toString(); |
} |
152,12 → 158,13 |
private boolean selectionEspece=false; |
private boolean selectionAbondance = false; |
private boolean selectionCertitude = false; |
private boolean selectionPhenologie = false; |
|
private boolean modification = false ; |
private Toolbar bt = null ; |
|
private final String VALEURS_MULTIPLES = "(Valeurs multiples)"; |
private final String modeleMessageModif = "commune:lieu-dit:station:milieu:latitude:longitude:date:espece:commentaire:abondance:identification"; |
private final String modeleMessageModif = "commune:lieu-dit:station:milieu:latitude:longitude:date:espece:commentaire:abondance:identification:referentiel:phenologie"; |
private boolean communeModifiee = false; |
private boolean lieuDitModifie = false; |
private boolean stationModifiee = false; |
167,6 → 174,8 |
private boolean commModifie = false; |
private boolean abondanceModifiee = false; |
private boolean certitudeModifiee = false; |
private boolean referentielTaxoModifie = false; |
private boolean phenologieModifiee = false;; |
|
private final int KEY_ALT = 18; |
private final int KEY_BACKSPACE = 8; |
239,6 → 248,10 |
|
private ComboBox selecteurCertitude = null; |
|
private ComboBox selecteurReferentielTaxo = null; |
|
private ComboBox selecteurStadePheno = null; |
|
/** |
* Constructeur sans argument (privé car ne doit pas être utilisé) |
*/ |
253,12 → 266,12 |
* @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); |
382,57 → 395,7 |
|
@Override |
public void onAfterLayout(Container c) { |
|
ExtElement lienCoord = Ext.get("lien_coord"); |
lienCoord.removeAllListeners(); |
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() { |
@Override |
public void execute(EventObject e) { |
obtenirInformationCoord(); |
} |
}) ; |
|
ExtElement lienCarto = Ext.get("lien_carto"); |
lienCarto.removeAllListeners(); |
lienCarto.addListener("click", new EventCallback() { |
|
@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"); |
} |
surPremierAffichageCoordPanel(largeur); |
} |
}); |
|
455,20 → 418,30 |
//date.setTabIndex(5); |
panneauPremierColonne.add(date, new AnchorLayoutData("55%")); |
|
// 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(); |
selecteurReferentielTaxo.setCls("champ-separation"); |
selecteurReferentielTaxo.setLabel("Référentiel"); |
selecteurReferentielTaxo.setStore(Ontologies.getValeursReferentiel()); |
selecteurReferentielTaxo.setValue(referentielTaxo); |
selecteurReferentielTaxo.setDisplayField("label") ; |
selecteurReferentielTaxo.setValueField("valeur"); |
selecteurReferentielTaxo.setEditable(false); |
selecteurReferentielTaxo.setHideTrigger(false); |
selecteurReferentielTaxo.setForceSelection(true); |
|
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.setPageSize(10); // Ne fonctionne pas |
espece.setItemSelector("div.search-item-espece"); |
espece.setTypeAhead(true); |
espece.setLoadingText("Recherche..."); |
|
espece.setHideTrigger(true); |
//espece.setTabIndex(6); |
|
Panel panelSeparationPp = new Panel(); |
panelSeparationPp.setHeight(15); |
475,7 → 448,7 |
panelSeparationPp.setBorder(false); |
|
panneauPremierColonne.add(panelSeparationPp); |
|
panneauPremierColonne.add(selecteurReferentielTaxo, new AnchorLayoutData("50%")); |
panneauPremierColonne.add(espece, new AnchorLayoutData("95%")); |
|
selecteurAbondance = new ComboBox(); |
522,11 → 495,10 |
comment.setAllowBlank(true); |
comment.setHeight(50); |
|
//comment.setTabIndex(7); |
panneauSecondeColonne.add(comment, new AnchorLayoutData("95%") ); |
|
Panel panelSeparationPs = new Panel(); |
panelSeparationPs.setHeight(15); |
panelSeparationPs.setHeight(39); |
panelSeparationPs.setBorder(false); |
|
panneauSecondeColonne.add(panelSeparationPs); |
541,6 → 513,16 |
selecteurCertitude.setForceSelection(false); |
panneauSecondeColonne.add(selecteurCertitude, new AnchorLayoutData("50%")); |
|
selecteurStadePheno = new ComboBox(); |
selecteurStadePheno.setLabel("Phénologie"); |
selecteurStadePheno.setStore(Ontologies.getValeursPhenologie()); |
selecteurStadePheno.setDisplayField("label") ; |
selecteurStadePheno.setValueField("valeur"); |
selecteurStadePheno.setEditable(true); |
selecteurStadePheno.setHideTrigger(false); |
selecteurStadePheno.setForceSelection(false); |
panneauSecondeColonne.add(selecteurStadePheno, new AnchorLayoutData("50%")); |
|
if (Window.getClientWidth() > Window.getClientHeight() || Window.getClientWidth() < 800) { |
panneauIntermediaire.add(panneauPremierColonne, new ColumnLayoutData(.5)); |
panneauIntermediaire.add(panneauSecondeColonne, new ColumnLayoutData(.5)); |
547,8 → 529,7 |
} |
else { |
panneauIntermediaire.add(panneauPremierColonne); |
panneauIntermediaire.add(panneauSecondeColonne); |
|
panneauIntermediaire.add(panneauSecondeColonne); |
} |
|
panneauFormulaire.add(panneauIntermediaire); |
569,8 → 550,7 |
bt.addSpacer() ; |
bt.addText("Mode de saisie ") ; |
bt.addField(selecteurMode) ; |
|
|
|
if (Ext.isIE()) { |
panneauPremierColonne.setButtonAlign(Position.RIGHT); |
panneauPremierColonne.addButton(boutonOK); |
577,15 → 557,12 |
panneauSecondeColonne.setButtonAlign(Position.LEFT); |
panneauPremierColonne.addButton(boutonAnnuler); |
} |
else { |
|
else { |
panneauFormulaire.addButton(boutonOK); |
panneauFormulaire.addButton(boutonAnnuler); |
} |
|
|
|
selecteurMode.addListener(new ComboBoxListenerAdapter() { |
|
@Override |
public void onSelect(ComboBox comboBox, Record record, int index) { |
|
593,7 → 570,6 |
comboBox.setValue(record.getAsString("nom_mode")); |
setModification(record.getAsString("mode")) ; |
} |
|
}); |
|
this.add(panneauFormulaire) ; |
615,417 → 591,124 |
htmlPanel.doLayout(); |
|
doLayout(); |
}}); |
} |
}); |
|
// on ajoute les listeners |
ajouterListeners() ; |
saisieTabindex(); |
} |
|
private void ajouterListeners() |
{ |
// Listener completion communne |
final Rafraichissable r = this; |
|
commune.addListener(new ComboBoxListenerAdapter() { |
@Override |
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(); |
} |
}); |
|
|
ListenerConfig listenerConfigCommune=new ListenerConfig(); |
listenerConfigCommune.setDelay(200); |
listenerConfigCommune.setStopPropagation(false); |
listenerConfigCommune.setStopEvent(false); |
|
commune.addKeyPressListener(new EventCallback() { |
|
@Override |
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: |
|
if (selectionCommune) { |
communeModifiee= true; |
selectionCommune=false; |
} |
else { |
|
validerSaisie(Champs.COMMUNE); |
// lancer mise a jour |
} |
break; |
|
default: |
departement=""; |
commune.collapse(); |
obtenirListeReferentielCommune(); |
communeModifiee= true; |
|
break; |
} |
} |
}, listenerConfigCommune |
); |
|
date.addKeyPressListener(new EventCallback() { |
|
@Override |
public void execute(EventObject e) { |
// TODO Auto-generated method stub |
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: |
if(date.getRawValue().equals(VALEURS_MULTIPLES)) { |
date.clearInvalid(); |
} |
case KEY_UP: |
|
break; |
|
case KEY_ENTER: |
validerSaisie(Champs.DATE); |
break; |
|
default: |
dateModifiee = true; |
} |
private void surPremierAffichageCoordPanel(final double largeur) { |
ExtElement lienCoord = Ext.get("lien_coord"); |
lienCoord.removeAllListeners(); |
lienCoord.addListener("click", new EventCallback() { |
@Override |
public void execute(EventObject e) { |
|
coordPanel.setVisible(!coordPanel.isVisible()); |
|
if(Ext.isIE()) { |
latitude.focus(); |
} |
}); |
|
date.addListener(new DatePickerListenerAdapter() { |
|
@Override |
public void onSelect(DatePicker dataPicker, Date date) { |
dateModifiee = true; |
} |
}); |
|
ListenerConfig listenerConfigAutocompletion=new ListenerConfig(); |
listenerConfigAutocompletion.setDelay(200); |
listenerConfigAutocompletion.setStopPropagation(false); |
listenerConfigAutocompletion.setStopEvent(false); |
|
|
// Listener completion espece |
espece.addListener(new ComboBoxListenerAdapter() { |
@Override |
public void onSelect(ComboBox comboBox, Record record, int index) { |
espece.setValue(record.getAsString("nom")); |
numeroNom=record.getAsString("numeroNom"); |
selectionEspece=true; |
observationMediateur.obtenirImageInformationExternes(numeroNom); |
} |
}); |
|
|
ListenerConfig listenerConfigEspece=new ListenerConfig(); |
listenerConfigEspece.setDelay(10); |
listenerConfigEspece.setStopPropagation(false); |
listenerConfigEspece.setStopEvent(false); |
|
|
CarnetEnLigneMediateur.fireResize(); |
} |
}) ; |
|
espece.addKeyPressListener(new EventCallback() { |
|
@Override |
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: |
|
if(selectionEspece) { |
especeModifiee = true; |
selectionEspece=false; |
} |
else { |
validerSaisie(Champs.ESPECE); |
} |
|
break; |
|
default: |
|
numeroNom=""; |
obtenirListeReferentielNom(); |
especeModifiee = true; |
|
break; |
} |
ExtElement lienCartoCoord = Ext.get("lien_carto_coord"); |
lienCartoCoord.removeAllListeners(); |
lienCartoCoord.addListener("click", new EventCallback() { |
@Override |
public void execute(EventObject e) { |
obtenirInformationCoord(); |
} |
}) ; |
|
ExtElement lienCarto = Ext.get("lien_carto"); |
lienCarto.removeAllListeners(); |
lienCarto.addListener("click", new EventCallback() { |
|
|
|
} |
|
}, listenerConfigEspece |
|
); |
|
comment.addKeyPressListener(new EventCallback() { |
|
@Override |
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; |
|
default: |
commModifie = true; |
} |
} |
}); |
|
tCoord = new Timer() { |
|
@Override |
public void run() { |
double[] coord = coordonneesValides(); |
if(!rechercheCommuneEnCours && coord != null && (longModifiee || latModifiee)) { |
rechercheCommuneEnCours = true; |
Ext.get(lienSelectionCommune.getElement()).mask("recherche"); |
observationMediateur.obtenirInformationCoord(r,LatLng.newInstance(coord[0], coord[1])); |
} |
} |
@Override |
public void execute(EventObject e) { |
|
}; |
|
latitude.addKeyPressListener(new EventCallback() { |
|
@Override |
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; |
tCoord.cancel(); |
tCoord.schedule(250); |
} |
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) { |
|
longitude.addKeyPressListener(new EventCallback() { |
|
@Override |
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_UP: |
case KEY_TAB: |
break; |
|
case KEY_ENTER: |
validerSaisie(Champs.LONGITUDE); |
break; |
|
default: |
longModifiee = true; |
tCoord.cancel(); |
tCoord.schedule(250); |
} |
} |
}); |
int largeurN = (int)largeur; |
|
selecteurAbondance.addListener(new ComboBoxListenerAdapter() { |
|
@Override |
public void onSelect(ComboBox comboBox, Record record, int index) { |
selectionAbondance=true; |
abondanceModifiee = true; |
} |
}); |
latitude.setWidth(largeurN+"px"); |
longitude.setWidth(largeurN+"px"); |
lienSelectionCommune.setWidth(largeurN+"px"); |
} |
} |
|
selecteurAbondance.addKeyPressListener(new EventCallback() { |
private void ajouterListeners() |
{ |
// Listener completion communne |
final Rafraichissable r = this; |
|
ListenerConfig listenerConfigCommune=new ListenerConfig(); |
listenerConfigCommune.setDelay(200); |
listenerConfigCommune.setStopPropagation(false); |
listenerConfigCommune.setStopEvent(false); |
|
@Override |
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: |
if(!selectionAbondance) { |
validerSaisie(Champs.ABONDANCE); |
} else { |
selectionAbondance = false; |
} |
break; |
date.addListener(new DatePickerListenerAdapter() { |
|
default: |
selecteurAbondance.setRawValue(selecteurAbondance.getRawValue()); |
selecteurAbondance.setValue(selecteurAbondance.getRawValue()); |
abondanceModifiee = true; |
selectionAbondance = false; |
break; |
} |
} |
}); |
@Override |
public void onSelect(DatePicker dataPicker, Date date) { |
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); |
|
selecteurCertitude.addListener(new ComboBoxListenerAdapter() { |
tCoord = new Timer() { |
|
@Override |
public void onSelect(ComboBox comboBox, Record record, int index) { |
selectionCertitude=true; |
certitudeModifiee = true; |
} |
}); |
@Override |
public void run() { |
double[] coord = coordonneesValides(); |
if(!rechercheCommuneEnCours && coord != null && (longModifiee || latModifiee)) { |
rechercheCommuneEnCours = true; |
Ext.get(lienSelectionCommune.getElement()).mask("recherche"); |
observationMediateur.obtenirInformationCoord(r,LatLng.newInstance(coord[0], coord[1])); |
} |
} |
|
selecteurCertitude.addKeyPressListener(new EventCallback() { |
|
@Override |
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: |
if(!selectionCertitude) { |
validerSaisie(Champs.CERTITUDE); |
} else { |
selectionCertitude = false; |
} |
break; |
|
default: |
selecteurCertitude.setRawValue(selecteurCertitude.getRawValue()); |
selecteurCertitude.setValue(selecteurCertitude.getRawValue()); |
certitudeModifiee = true; |
selectionCertitude = false; |
break; |
} |
} |
}); |
|
}; |
|
ajouterListenerChampEvenementsClavier(commune, listenerConfigCommune); |
ajouterListenerChampEvenementsClavier(date); |
ajouterListenerChampEvenementsClavier(selecteurReferentielTaxo); |
ajouterListenerChampEvenementsClavier(espece, listenerConfigEspece); |
ajouterListenerChampEvenementsClavier(comment); |
ajouterListenerChampEvenementsClavier(latitude); |
ajouterListenerChampEvenementsClavier(longitude); |
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) { |
if(modification) { |
if(masseModification) { |
modifierObservationEnMasse(null); |
1036,17 → 719,12 |
else { |
ajouterObservation(); |
} |
|
|
} |
|
} |
}); |
|
boutonAnnuler.addListener(new ButtonListenerAdapter() { |
|
|
boutonAnnuler.addListener(new ButtonListenerAdapter() { |
@Override |
public void onClick(Button button, EventObject e) { |
|
public void onClick(Button button, EventObject e) { |
if(modification) |
{ |
supprimerObservation() ; |
1055,19 → 733,251 |
{ |
raz(); |
} |
} |
|
} |
}); |
|
|
this.addListener(new ContainerListenerAdapter() { |
@Override |
public void onAfterLayout(Container self) { |
commune.focus(); |
} |
}); |
|
}); |
} |
|
private void ajouterListenerChampsCombobox() { |
commune.addListener(new ComboBoxListenerAdapter() { |
@Override |
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() { |
@Override |
public void onSelect(ComboBox comboBox, Record record, int index) { |
referentielTaxo = record.getAsString("valeur"); |
observationMediateur.setRefTaxSelectionne(index); |
referentielTaxoModifie = true; |
} |
}); |
|
espece.addListener(new ComboBoxListenerAdapter() { |
@Override |
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() { |
@Override |
public void onSelect(ComboBox comboBox, Record record, int index) { |
selectionAbondance=true; |
abondanceModifiee = true; |
} |
}); |
|
selecteurCertitude.addListener(new ComboBoxListenerAdapter() { |
|
@Override |
public void onSelect(ComboBox comboBox, Record record, int index) { |
selectionCertitude=true; |
certitudeModifiee = true; |
} |
}); |
|
selecteurStadePheno.addListener(new ComboBoxListenerAdapter() { |
@Override |
public void onSelect(ComboBox comboBox, Record record, int index) { |
selectionPhenologie=true; |
phenologieModifiee = true; |
} |
}); |
} |
|
private void ajouterListenerChampEvenementsClavier(final TextField champ) { |
champ.addKeyPressListener(new EventCallback() { |
@Override |
public void execute(EventObject e) { |
surEvenementClavier(e, champ); |
} |
}); |
} |
|
|
private void ajouterListenerChampEvenementsClavier(final TextField champ, final ListenerConfig config) { |
champ.addKeyPressListener(new EventCallback() { |
@Override |
public void execute(EventObject e) { |
surEvenementClavier(e, champ); |
} |
}, config); |
} |
|
private void surEvenementClavier(EventObject e, TextField champ) { |
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: |
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); |
} else { |
selectionPhenologie = false; |
} |
} |
|
if(champ.equals(selecteurCertitude)) { |
if(!selectionCertitude) { |
validerSaisie(Champs.CERTITUDE); |
} else { |
selectionCertitude = false; |
} |
} |
|
if(champ.equals(selecteurAbondance)) { |
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(espece)) { |
if(selectionEspece) { |
especeModifiee = true; |
selectionEspece=false; |
} |
else { |
validerSaisie(Champs.ESPECE); |
} |
} |
|
if(champ.equals(selecteurReferentielTaxo)) { |
validerSaisie(Champs.REFERENTIELTAXO); |
} |
|
if(champ.equals(date)) { |
validerSaisie(Champs.DATE); |
} |
|
if(champ.equals(commune)) { |
if(champ.equals(commune)) { |
if (selectionCommune) { |
communeModifiee= true; |
selectionCommune=false; |
} |
else { |
validerSaisie(Champs.COMMUNE); |
} |
} |
} |
} |
|
private void gererEvenementClavierDefaut(TextField champ) { |
//TODO: faire un switch ou une enum |
if(champ.equals(selecteurStadePheno)) { |
selecteurStadePheno.setRawValue(selecteurStadePheno.getRawValue()); |
selecteurStadePheno.setValue(selecteurStadePheno.getRawValue()); |
phenologieModifiee = true; |
selectionPhenologie = false; |
} |
|
if(champ.equals(selecteurCertitude)) { |
selecteurCertitude.setRawValue(selecteurCertitude.getRawValue()); |
selecteurCertitude.setValue(selecteurCertitude.getRawValue()); |
certitudeModifiee = true; |
selectionCertitude = false; |
} |
|
if(champ.equals(selecteurAbondance)) { |
selecteurAbondance.setRawValue(selecteurAbondance.getRawValue()); |
selecteurAbondance.setValue(selecteurAbondance.getRawValue()); |
abondanceModifiee = true; |
selectionAbondance = false; |
} |
|
if(champ.equals(longitude)) { |
longModifiee = true; |
tCoord.cancel(); |
tCoord.schedule(250); |
} |
|
if(champ.equals(latitude)) { |
latModifiee = true; |
tCoord.cancel(); |
tCoord.schedule(250); |
} |
|
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(); |
obtenirListeReferentielCommune(); |
communeModifiee= true; |
} |
} |
|
/** |
* Validation de la saisie |
*/ |
1076,7 → 986,7 |
|
if(modification) { |
if(masseModification) { |
modifierObservationEnMasse(champs); |
modifierObservationEnMasse(champs); |
} else { |
modifierObservation(); |
} |
1144,16 → 1054,14 |
|
} |
|
// si l'on a reçu une liste du référentiel nom (complétion referentiel nom) |
|
// si l'on a reçu une liste du référentiel nom (complétion referentiel nom) |
if(nouvelleDonnees instanceof ListeReferentielNom) |
{ |
|
ListeReferentielNom data = (ListeReferentielNom) nouvelleDonnees ; |
Object[][] nomData = new Object[data.size()][3]; |
int i = 0 ; |
|
// on la parse et on récupère les informations quiç nous interessent |
// on la parse et on récupère les informations qui nous interessent |
for (Iterator it = data.keySet().iterator(); it.hasNext();) |
{ |
|
1200,8 → 1108,6 |
calculerAfficherDifferences(listeObs); |
} |
|
// Sur Mise à jour ou suppression d'une suppression ? |
|
if(nouvelleDonnees instanceof String) |
{ |
String str = (String)nouvelleDonnees ; |
1299,7 → 1205,6 |
} |
|
private void rafraichirCommuneEtCoord(EntiteGeographiqueObservation infosCom) { |
; |
// on ne remplace la commune que si le champ était vide |
if(commune.getRawValue() == null || commune.getRawValue().equals("")) { |
rafraichirCommune(infosCom); |
1328,13 → 1233,12 |
|
} |
|
|
public void obtenirListeReferentielNom() { |
// FIXME : trouver un autre moyen que le hack "/*" pour rechercher les taxons lors de la saisie d'un espace apres le genre |
String esp=espece.getText().replaceAll(" ","/*"); |
esp=esp.replaceAll("%",""); |
String referentiel = this.referentielTaxo; |
|
observationMediateur.obtenirListeReferentielNom(this,esp); |
observationMediateur.obtenirListeReferentielNom(this,referentiel ,esp); |
} |
|
protected void obtenirReferentielStation() { |
1357,9 → 1261,7 |
return; |
} |
|
if(departement != null) { |
// TODO : regler le probleme a la base plutot que ce patch |
|
if(departement != null) { |
if(departement.equals("000null") || departement.equals("")) { |
String[] depCom = commune.getText().split(" "); |
if(depCom.length > 1) { |
1383,22 → 1285,24 |
} |
} |
} |
|
|
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); |
|
String[] coords = getValeurCoordonnees(); |
|
obs.setLatitude(coords[0]); |
obs.setLongitude(coords[1]); |
|
|
obs.setAbondance(getAbondance()); |
obs.setCertitude(getCertitude()); |
obs.setPhenologie(getPhenologie()); |
|
obs.setReferentielTaxo(Ontologies.getInfosReferentielNomParCode(referentielTaxo).getCodeVersionComplet()); |
|
observationMediateur.ajouterObservation(obs); |
} |
|
|
private void modifierObservation() { |
|
if(!Util.verifierDateFormatCel(date.getRawValue()) && !date.getRawValue().equals("")) { |
1442,15 → 1346,18 |
|
obs.setAbondance(getAbondance()); |
obs.setCertitude(getCertitude()); |
obs.setPhenologie(getPhenologie()); |
obs.setReferentielTaxo(getReferentielTaxo()); |
|
observationMediateur.modifierObservation(obs); |
|
selecteurMode.setValue("création"); |
setModification("false"); |
|
} |
|
private void modifierObservationEnMasse(Champs champModifie) { |
|
//TODO: factoriser |
String communeM = null; |
String departementM = null; |
String numNomSelM = null; |
1464,6 → 1371,8 |
String longM = null; |
String abondanceM = null; |
String certitudeM = null; |
String referentielTaxoM = null; |
String phenologieM = null; |
|
String champs = modeleMessageModif; |
|
1560,6 → 1469,18 |
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(",", ""); |
1576,6 → 1497,8 |
obs.setLongitude(longM); |
obs.setAbondance(abondanceM); |
obs.setCertitude(certitudeM); |
obs.setReferentielTaxo(referentielTaxoM); |
obs.setPhenologie(phenologieM); |
if(Window.confirm(message)) { |
observationMediateur.modifierObservationEnMasse(obs); |
reinitialiserValeurModifiees(); |
1583,8 → 1506,7 |
} |
} |
|
private void supprimerObservation() { |
|
private void supprimerObservation() { |
observationMediateur.supprimerObservation(this, numeroOrdre); |
} |
|
1672,6 → 1594,18 |
|
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(); |
selecteurReferentielTaxo.setValue(referentielTaxo); |
} else { |
referentielTaxo = ""; |
selecteurReferentielTaxo.setRawValue(VALEURS_MULTIPLES); |
} |
} |
|
|
1683,8 → 1617,6 |
public void raz(Champs champs) |
{ |
switch (champs) { |
|
|
case DATE: |
date.reset() ; |
break; |
1705,7 → 1637,6 |
comment.reset() ; |
break; |
|
|
case COMMUNE: |
commune.reset() ; |
departement =""; |
1737,6 → 1668,14 |
selecteurCertitude.setValue(""); |
break; |
|
case REFERENTIELTAXO: |
selecteurReferentielTaxo.setValue(""); |
break; |
|
case PHENOLOGIE: |
selecteurStadePheno.setValue(""); |
break; |
|
case TOUT: |
commune.reset(); |
date.reset() ; |
1751,6 → 1690,9 |
espece.reset(); |
selecteurAbondance.clearValue(); |
selecteurCertitude.clearValue(); |
selecteurReferentielTaxo.clearValue(); |
selecteurStadePheno.clearValue(); |
referentielTaxo = ""; |
numeroNom = "" ; |
numeroOrdre = ""; |
afficherIndicationCommune(null); |
1834,6 → 1776,8 |
String lon = null; |
String abondance = null; |
String certitude = null; |
String referentielTaxo = null; |
String phenologie = null; |
|
String ordreObs = ""; |
|
1851,6 → 1795,8 |
lon = comparerDifferencesChamps(lon, obsEnCours.getLongitude()); |
abondance = comparerDifferencesChamps(abondance, obsEnCours.getAbondance()); |
certitude = comparerDifferencesChamps(certitude, obsEnCours.getCertitude()); |
referentielTaxo = comparerDifferencesChamps(referentielTaxo, obsEnCours.getReferentielTaxo()); |
phenologie = comparerDifferencesChamps(phenologie, obsEnCours.getPhenologie()); |
|
ordreObs += obsEnCours.getNumeroOrdre()+","; |
} |
1861,6 → 1807,8 |
obs.setLongitude(lon); |
obs.setAbondance(abondance); |
obs.setCertitude(certitude); |
obs.setReferentielTaxo(referentielTaxo); |
obs.setPhenologie(phenologie); |
rafraichir(obs, false); |
} |
|
1892,6 → 1840,8 |
longModifiee = false; |
abondanceModifiee = false; |
certitudeModifiee = false; |
referentielTaxoModifie = false; |
phenologieModifiee = false; |
} |
|
public void saisieTabindex() |
1922,8 → 1872,9 |
espece.setTabIndex(12); |
selecteurCertitude.setTabIndex(13); |
selecteurAbondance.setTabIndex(14); |
boutonOK.setTabIndex(15); |
boutonAnnuler.setTabIndex(16); |
selecteurStadePheno.setTabIndex(15); |
boutonOK.setTabIndex(16); |
boutonAnnuler.setTabIndex(17); |
|
} |
|
1937,7 → 1888,7 |
} |
|
private void obtenirInformationCommune() { |
observationMediateur.obtenirInformationCommune(getCommuneSansDepartement(), obtenirDepartementAPartirChampCommune()); |
observationMediateur.obtenirInformationCommune(getCommuneSansDepartement(), Util.obtenirDepartementAPartirChaineCommune(departement, commune.getText())); |
} |
|
public double[] coordonneesValides() { |
1967,52 → 1918,6 |
} |
} |
|
private String obtenirDepartementAPartirChampCommune() { |
|
String dep = ""; |
|
if(departement == null) { |
departement = ""; |
} |
|
if(departement.equals("000null") || departement.equals("")) { |
|
String[] depCom = commune.getText().split(" "); |
if(depCom.length > 1) { |
dep = depCom[1].replace('(', ' '); |
} else { |
dep = ""; |
} |
} else { |
dep = departement; |
} |
|
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 ; |
} |
|
if(departement.length() == 4) { |
departement = "0"+departement; |
} |
|
departement = departement.substring(0,2); |
} |
catch(NumberFormatException e) |
{ |
departement = "" ; |
} |
|
return departement; |
} |
|
public String getCommune() { |
|
String valeurCommune = ""; |
2024,7 → 1929,7 |
} |
|
public String getDepartement() { |
return obtenirDepartementAPartirChampCommune(); |
return Util.obtenirDepartementAPartirChaineCommune(departement, commune.getText()); |
} |
|
public String getCommuneSansDepartement() { |
2031,35 → 1936,38 |
return Util.supprimerNumDepartementChaineLocalite(getCommune()); |
} |
|
//TODO fusionner les deux fonctions et les objets qu'elles utilisent |
// car leur code est à 99% identique |
public String getAbondance() { |
String valeurAbondance = selecteurAbondance.getValue(); |
String valeurAbondanceBrute = selecteurAbondance.getRawValue(); |
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 |
// caractère |
if(valeurAbondance.equals(valeurAbondanceBrute.substring(0, valeurAbondanceBrute.length() -1))) { |
valeurAbondance = selecteurAbondance.getRawValue(); |
if(valeurChamp != null && valeurChamp.length() > 0) { |
if(valeurChamp.equals(valeurChampBrute.substring(0, valeurChampBrute.length() -1))) { |
valeurChamp = champ.getRawValue(); |
} |
} |
|
return valeurAbondance; |
return valeurChamp; |
} |
|
public String getAbondance() { |
return getValeurChampListeLibre(selecteurAbondance); |
} |
|
public String getCertitude() { |
String valeurCertitude = selecteurCertitude.getValue(); |
String valeurCertitudeBrute = selecteurCertitude.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 |
// caractère |
if(valeurCertitude.equals(valeurCertitudeBrute.substring(0, valeurCertitudeBrute.length() -1))) { |
valeurCertitude = selecteurCertitude.getRawValue(); |
} |
|
return valeurCertitude; |
return getValeurChampListeLibre(selecteurCertitude); |
} |
|
public String getPhenologie() { |
return getValeurChampListeLibre(selecteurStadePheno); |
} |
|
public String getReferentielTaxo() { |
String codeCourt = getValeurChampListeLibre(selecteurReferentielTaxo); |
return Ontologies.getInfosReferentielNomParCode(codeCourt).getCodeVersionComplet(); |
} |
|
public boolean communeInitialisee() { |
return communeModifiee; |