Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 707 → Rev 708

/trunk/src/org/tela_botanica/client/vues/observation/FormulaireSaisieObservationVue.java
6,7 → 6,6
import java.util.Iterator;
 
import org.tela_botanica.client.CarnetEnLigneMediateur;
import org.tela_botanica.client.Util;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Configuration;
import org.tela_botanica.client.modeles.EntiteGeographiqueObservation;
13,10 → 12,13
import org.tela_botanica.client.modeles.ListeObservation;
import org.tela_botanica.client.modeles.ListeReferentielCommune;
import org.tela_botanica.client.modeles.ListeReferentielNom;
import org.tela_botanica.client.modeles.ListeReferentielPerso;
import org.tela_botanica.client.modeles.Observation;
import org.tela_botanica.client.modeles.ReferentielCommune;
import org.tela_botanica.client.modeles.ReferentielNom;
import org.tela_botanica.client.modeles.ListeReferentielPerso.TypesReferentiels;
import org.tela_botanica.client.observation.ObservationMediateur;
import org.tela_botanica.client.util.Util;
 
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.JavaScriptObject;
87,9 → 89,9
FormPanel panneauFormulaire = null;
 
private DateField date = null;
private TextField lieudit = null;
private TextField station = null;
private TextField milieu = null;
private ComboBox lieudit = null;
private ComboBox station = null;
private ComboBox milieu = null;
private TextField comment = null;
private ComboBox commune = null;
private String departement = null;
146,6 → 148,9
private Button boutonAnnuler = new Button("Réinitialiser");
 
private boolean selectionCommune=false;
private boolean selectionStation=false;
private boolean selectionLieuDit=false;
private boolean selectionMilieu=false;
private boolean selectionEspece=false;
private boolean modification = false ;
227,6 → 232,8
 
private Timer tCoord;
final String resultTplRefPerso = "<div class=\"search-item-commune\">{element_referentiel}</div>";
/**
* Constructeur sans argument (privé car ne doit pas être utilisé)
*/
303,8 → 310,8
//Sur une meme ligne, ajout de plusieurs champs
htmlCommunePanel = new MultiFieldPanel();
int largeurCommune = Window.getClientWidth()/4;
htmlCommunePanel.addToRow(commune, largeurCommune);
int largeurCommune = Window.getClientWidth()/4;
htmlCommunePanel.addToRow(commune, largeurCommune);
htmlCommunePanel.addToRow(basculerverscarto, 160);
 
htmlCommunePanel.setBorder(false);
312,7 → 319,14
 
panneauPremierColonne.add(htmlCommunePanel);
 
station = new TextField("Station", "station");
station = new ComboBox("Station", "station");
station.setTpl(resultTplRefPerso);
station.setMode(ComboBox.REMOTE);
// commune.setPageSize(10); // Ne fonctionne pas
station.setItemSelector("div.search-item-commune");
station.setTypeAhead(true);
station.setLoadingText("Recherche...");
station.setHideTrigger(true);
station.setAllowBlank(true);
 
panneauPremierColonne.add(station, new AnchorLayoutData("95%"));
453,15 → 467,25
 
panneauPremierColonne.add(espece, new AnchorLayoutData("95%"));
lieudit = new TextField("Lieu-dit", "lieudit");
lieudit = new ComboBox("Lieu-dit", "lieudit");
lieudit.setTpl(resultTplRefPerso);
lieudit.setMode(ComboBox.REMOTE);
lieudit.setItemSelector("div.search-item-commune");
lieudit.setTypeAhead(true);
lieudit.setLoadingText("Recherche...");
lieudit.setHideTrigger(true);
lieudit.setAllowBlank(true);
//lieudit.setTabIndex(2);
panneauSecondeColonne.add(lieudit, new AnchorLayoutData("95%"));
milieu = new TextField("Milieu", "milieu");
milieu = new ComboBox("Milieu", "milieu");
milieu.setTpl(resultTplRefPerso);
milieu.setMode(ComboBox.REMOTE);
milieu.setItemSelector("div.search-item-commune");
milieu.setTypeAhead(true);
milieu.setLoadingText("Recherche...");
milieu.setHideTrigger(true);
milieu.setAllowBlank(true);
//milieu.setTabIndex(4);
panneauSecondeColonne.add(milieu, new AnchorLayoutData("95%"));
comment = new TextArea("Notes", "comment");
669,6 → 693,23
}
});
ListenerConfig listenerConfigAutocompletion=new ListenerConfig();
listenerConfigAutocompletion.setDelay(200);
listenerConfigAutocompletion.setStopPropagation(false);
listenerConfigAutocompletion.setStopEvent(false);
station.addListener(new ComboBoxListenerAdapter() {
public void onSelect(ComboBox comboBox, Record record, int index) {
station.setValue(record.getAsString("element_referentiel"));
selectionStation=true;
station.collapse();
}
public void onExpand(ComboBox comboBox) {
comboBox.focus();
}
});
station.addKeyPressListener(new EventCallback() {
 
public void execute(EventObject e) {
690,15 → 731,22
case KEY_UP:
break;
case KEY_ENTER:
validerSaisie(Champs.STATION);
break;
case KEY_ENTER:
if (selectionStation) {
stationModifiee= true;
selectionStation=false;
}
else {
validerSaisie(Champs.STATION);
}
break;
default:
obtenirReferentielStation();
stationModifiee = true;
}
}
});
},listenerConfigAutocompletion);
771,6 → 819,15
}, listenerConfigEspece
);
// Listener completion lieudit
lieudit.addListener(new ComboBoxListenerAdapter() {
public void onSelect(ComboBox comboBox, Record record, int index) {
lieudit.setValue(record.getAsString("element_referentiel"));
selectionLieuDit=true;
lieudit.collapse();
}
});
lieudit.addKeyPressListener(new EventCallback() {
 
794,16 → 851,32
break;
case KEY_ENTER:
validerSaisie(Champs.LIEUDIT);
break;
case KEY_ENTER:
if (selectionLieuDit) {
lieuDitModifie= true;
selectionLieuDit=false;
}
else {
validerSaisie(Champs.LIEUDIT);
}
break;
default:
lieuDitModifie = true;
obtenirReferentielLieuDit();
}
}
});
},listenerConfigAutocompletion);
// Listener completion lieudit
milieu.addListener(new ComboBoxListenerAdapter() {
public void onSelect(ComboBox comboBox, Record record, int index) {
milieu.setValue(record.getAsString("element_referentiel"));
selectionMilieu=true;
milieu.collapse();
}
});
milieu.addKeyPressListener(new EventCallback() {
 
public void execute(EventObject e) {
826,15 → 899,22
break;
case KEY_ENTER:
validerSaisie(Champs.MILIEU);
break;
case KEY_ENTER:
if (selectionMilieu) {
milieuModifie= true;
selectionMilieu=false;
}
else {
validerSaisie(Champs.MILIEU);
}
break;
default:
milieuModifie = true;
obtenirListeReferentielMilieu();
}
}
});
},listenerConfigAutocompletion);
comment.addKeyPressListener(new EventCallback() {
 
982,7 → 1062,7
});
}
 
/**
* Validation de la saisie
*/
1108,6 → 1188,58
}
if(nouvelleDonnees instanceof ListeReferentielPerso)
{
ListeReferentielPerso referentielPerso = (ListeReferentielPerso)nouvelleDonnees;
int i = 0;
Object[][] refData = new Object[referentielPerso.size()][1];
// on la parse et on récupère les informations quiç nous interessent
for (Iterator it = referentielPerso.keySet().iterator(); it.hasNext();)
{
String ref= referentielPerso.get(it.next());
refData[i][0]= ref;
i++;
}
//creation du store
FieldDef defStation = new StringFieldDef("element_referentiel");
FieldDef[] defTab = {defStation};
RecordDef rd = new RecordDef(defTab);
final MemoryProxy dataProxy = new MemoryProxy(refData);
final ArrayReader reader = new ArrayReader(rd);
Store store=new Store(dataProxy,reader);
switch (referentielPerso.getTypeReferentiel()) {
case REFERENTIEL_STATION:
station.setStore(store);
store.load();
break;
case REFERENTIEL_LIEU_DIT:
lieudit.setStore(store);
store.load();
break;
case REFERENTIEL_MILIEU:
milieu.setStore(store);
store.load();
break;
default:
break;
}
}
// On recoit une observation dont on veut afficher le detail
if(nouvelleDonnees instanceof Observation)
1257,6 → 1389,20
observationMediateur.obtenirListeReferentielNom(this,esp);
}
protected void obtenirReferentielStation() {
observationMediateur.obtenirListeReferentielPerso(this,TypesReferentiels.REFERENTIEL_STATION,station.getText());
}
 
protected void obtenirListeReferentielMilieu() {
observationMediateur.obtenirListeReferentielPerso(this,TypesReferentiels.REFERENTIEL_MILIEU,milieu.getText());
}
 
protected void obtenirReferentielLieuDit() {
observationMediateur.obtenirListeReferentielPerso(this,TypesReferentiels.REFERENTIEL_LIEU_DIT,lieudit.getText());
}
 
public void ajouterObservation() {
1891,11 → 2037,24
}
public void redimensionnerFormulaire() {
doLayout();
//htmlCommunePanel.setWidth(panneauPremierColonne.getWidth() - 10);
afficherFormulaireLatLon.setWidth(panneauIntermediaire.getWidth()+"px");
panneauPremierColonne.doLayout();
panneauSecondeColonne.doLayout();
panneauIntermediaire.doLayout();
/*if(panneauPremierColonne.getWidth() < 450 ) {
basculerverscarto.setHTML("<a id=\"lien_carto\" href=\"#\" tabindex=\"2\">Localiser</a>");
commune.setWidth(180);
basculerverscarto.setWidth("60px");
htmlCommunePanel.doLayout();
} else {
basculerverscarto.setHTML("<a id=\"lien_carto\" href=\"#\" tabindex=\"2\">Localiser la commune</a>");
commune.setWidth(290);
basculerverscarto.setWidth("160px");
htmlCommunePanel.doLayout();
}*/
doLayout();
}
}