Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 267 → Rev 268

/trunk/src/org/tela_botanica/client/vues/observation/FormulaireSaisieObservationVue.java
18,12 → 18,16
 
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.maps.client.geom.LatLng;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;
import com.gwtext.client.core.EventCallback;
import com.gwtext.client.core.EventObject;
import com.gwtext.client.core.Ext;
import com.gwtext.client.core.ExtElement;
import com.gwtext.client.core.Function;
import com.gwtext.client.core.ListenerConfig;
import com.gwtext.client.core.Position;
import com.gwtext.client.data.ArrayReader;
52,10 → 56,12
import com.gwtext.client.widgets.form.DateField;
import com.gwtext.client.widgets.form.Field;
import com.gwtext.client.widgets.form.FormPanel;
import com.gwtext.client.widgets.form.Label;
import com.gwtext.client.widgets.form.MultiFieldPanel;
import com.gwtext.client.widgets.form.TextArea;
import com.gwtext.client.widgets.form.TextField;
import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter;
import com.gwtext.client.widgets.form.event.TextFieldListener;
import com.gwtext.client.widgets.form.event.TextFieldListenerAdapter;
import com.gwtext.client.widgets.layout.AnchorLayoutData;
import com.gwtext.client.widgets.layout.ColumnLayout;
201,6 → 207,8
private MultiFieldPanel coordPanel;
 
private TextField coordonnees;
private Label lienSelectionCommune = null;
 
private HTML accesformulaire;
 
211,6 → 219,10
private boolean latModifiee;
 
private boolean longModifiee;
 
protected boolean rechercheCommuneEnCours = false;
 
private Timer tCoord;
/**
* Constructeur sans argument (privé car ne doit pas être utilisé)
282,11 → 294,28
commune.setHideTrigger(true);
//commune.setTabIndex(1);
panneauPremierColonne.add(commune, new AnchorLayoutData("95%"));
//création du lien "Accès carto" dans le formulaire
basculerverscarto = new HTML("");
basculerverscarto = new HTML(" <a id=\"lien_carto\" href=\"#\" tabindex=\"2\">Localiser</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 (longitude/latitude) de votre observation ");
tip2.applyTo(basculerverscarto.getElement());
//Sur une meme ligne, ajout de plusieurs champs
final MultiFieldPanel htmlCommunePanel = new MultiFieldPanel();
htmlCommunePanel.addToRow(commune,new ColumnLayoutData(0.5));
htmlCommunePanel.addToRow(basculerverscarto,100);
htmlCommunePanel.setBorder(false);
htmlCommunePanel.setId("x-commune-panel");
 
panneauPremierColonne.add(htmlCommunePanel);
 
station = new TextField("Station", "station");
station.setAllowBlank(true);
//station.setTabIndex(3);
 
panneauPremierColonne.add(station, new AnchorLayoutData("95%"));
latitude = new TextField("X", "x", 100);
294,18 → 323,23
longitude = new TextField("Y", "y", 100);
longitude.setAllowBlank(true);
lienSelectionCommune = new Label();
lienSelectionCommune.setId("conteneur_selection_commune");
lienSelectionCommune.setStyleName("conteneur_selection_commune");
// Panneau de type plusieurs champs de formulaire sur une meme ligne, où seront renseignés X/Y
coordPanel = new MultiFieldPanel();
coordPanel.setVisible(false);
coordPanel.addToRow(latitude, new ColumnLayoutData(0.5));
coordPanel.addToRow(longitude, new ColumnLayoutData(0.5));
coordPanel.addToRow(latitude, new ColumnLayoutData(0.3));
coordPanel.addToRow(longitude, new ColumnLayoutData(0.3));
coordPanel.addToRow(lienSelectionCommune, new ColumnLayoutData(0.4));
coordPanel.setBorder(false);
//création du champs coordonnées
referentielGeo = Configuration.getReferentielGeo();
coordonnees = new TextField("Coordonnées ("+referentielGeo+")", "", 0);
coordonnees = new TextField("Coordonnées", "", 0);
coordonnees.setMaxLength(0);
coordonnees.setReadOnly(true);
coordonnees.setCls("fieldname");
312,8 → 346,8
//création du lien "saisie X/Y" dans le formulaire
accesformulaire = new HTML("<a id=\"lien_coord\" href=\"#\" tabindex=\"7\">Saisie X/Y</a>");
accesformulaire.addStyleName("lien");
accesformulaire = new HTML("<a id=\"lien_coord\" href=\"#\" tabindex=\"6\">Saisie X/Y ("+referentielGeo+")</a>");
accesformulaire.addStyleName("lien_actif");
//création info bulle sur le lien "saisie X/Y"
ToolTip tip1 = new ToolTip();
339,16 → 373,12
 
public void execute(EventObject e) {
if(coordonneesValides() == null) {
if(commune.getValue() != null && !commune.getValue().equals("")) {
obtenirInformationCommune();
longlatAjoutee = true;
} else {
Window.alert("Veuillez renseigner au moins une commune ou des coordonnées pour la géolocalisation");
}
if(commune.getValue() != null && !commune.getValue().equals("")) {
obtenirInformationCommune();
longlatAjoutee = true;
} else {
obtenirInformationCoord();
Window.alert("Veuillez renseigner une commune à préciser");
}
}
});
355,21 → 385,10
}
 
});
//création du lien "Accès carto" dans le formulaire
basculerverscarto = new HTML(" <a id=\"lien_carto\" href=\"#\" tabindex=\"6\">Selection depuis une carte</a>");
basculerverscarto.addStyleName("lien");
//création info bulle sur le lien "accès carto"
ToolTip tip2 = new ToolTip();
tip2.setHtml("Via une carte, obtenez les coordonnées (longitude/latitude) de votre observation ");
tip2.applyTo(basculerverscarto.getElement());
//Sur une meme ligne, ajout de plusieurs champs
final MultiFieldPanel htmlPanel = new MultiFieldPanel();
htmlPanel.addToRow(coordonnees, 100);
htmlPanel.addToRow(basculerverscarto, new ColumnLayoutData(0.5));
htmlPanel.addToRow(accesformulaire, new ColumnLayoutData(0.5));
htmlPanel.setBorder(false);
htmlPanel.setId("x-coord-panel");
449,10 → 468,7
bt.addText("Mode de saisie ") ;
bt.addField(selecteurMode) ;
boutonOK.setTabIndex(8);
boutonAnnuler.setTabIndex(9);
if (Ext.isIE6()) {
panneauPremierColonne.setButtonAlign(Position.RIGHT);
panneauPremierColonne.addButton(boutonOK);
502,6 → 518,7
private void ajouterListeners()
{
// Listener completion communne
final Rafraichissable r = this;
commune.addListener(new ComboBoxListenerAdapter() {
public void onSelect(ComboBox comboBox, Record record, int index) {
800,6 → 817,19
}
});
tCoord = new Timer() {
 
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]));
}
}
};
latitude.addKeyPressListener(new EventCallback() {
 
public void execute(EventObject e) {
826,6 → 856,8
 
default:
latModifiee = true;
tCoord.cancel();
tCoord.schedule(250);
}
}
});
834,6 → 866,7
 
public void execute(EventObject e) {
switch(e.getKey()) {
case KEY_ALT:
case KEY_CTRL:
case KEY_DOWN:
845,23 → 878,22
case KEY_PAGEUP:
case KEY_RIGHT:
case KEY_SHIFT:
case KEY_UP:
case KEY_TAB:
case KEY_UP:
break;
break;
case KEY_ENTER:
validerSaisie(Champs.LONGITUDE);
break;
break;
 
default:
longModifiee = true;
longModifiee = true;
tCoord.cancel();
tCoord.schedule(250);
}
}
});
 
 
boutonOK.addListener(new ButtonListenerAdapter() {
public void onClick(Button button, EventObject e) {
894,8 → 926,6
{
raz();
}
}
});
1059,16 → 1089,62
if(nouvelleDonnees instanceof EntiteGeographiqueObservation)
{
EntiteGeographiqueObservation infosComm = (EntiteGeographiqueObservation)nouvelleDonnees ;
rafraichirCommuneEtCoord(infosComm);
if(rechercheCommuneEnCours) {
afficherIndicationCommune(infosComm);
} else {
rafraichirCommuneEtCoord(infosComm);
}
}
 
}
private void rafraichirCommuneEtCoord(EntiteGeographiqueObservation infosCom) {
private void afficherIndicationCommune(
final EntiteGeographiqueObservation infosCom) {
String nCommune = "";
if(infosCom != null && !infosCom.getCommune().trim().equals("")){
nCommune += infosCom.getCommune();
if(!infosCom.getIdLocalite().trim().equals(""))
nCommune += " ("+infosCom.getIdLocalite()+")";
}
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() {
public void execute(EventObject e) {
rafraichirCommune(infosCom);
}
});
Ext.get("lien_selection_commune").addListener("keypress",new EventCallback() {
public void execute(EventObject e) {
if(e.getCharCode() == KEY_ENTER) {
rafraichirCommune(infosCom);
}
}
});
Ext.get("lien_selection_commune").addListener("focus",new EventCallback() {
public void execute(EventObject e) {
Ext.get("lien_selection_commune").toggleClass("lien_sel");
}
});
Ext.get("lien_selection_commune").addListener("blur",new EventCallback() {
public void execute(EventObject e) {
Ext.get("lien_selection_commune").toggleClass("lien_sel");
}
});
 
Ext.get(lienSelectionCommune.getElement()).unmask();
rechercheCommuneEnCours = false;
latModifiee = false;
longModifiee = false;
}
private void rafraichirCommune(EntiteGeographiqueObservation infosCom) {
String nCommune = "";
 
if(infosCom.getCommune() != null && !infosCom.getCommune().equals("")) {
nCommune += infosCom.getCommune();
1078,9 → 1154,13
nCommune += " ("+infosCom.getIdLocalite()+")";
departement = infosCom.getIdLocalite();
}
commune.setValue(nCommune);
}
 
private void rafraichirCommuneEtCoord(EntiteGeographiqueObservation infosCom) {
rafraichirCommune(infosCom);
 
if(infosCom.getLat() != null && !infosCom.getLat().equals("")) {
latitude.setValue(infosCom.getLat());
}
1091,13 → 1171,13
coordPanel.setVisible(true);
latModifiee = true;
longModifiee = true;
latModifiee = false;
longModifiee = false;
}
 
public void obtenirListeReferentielCommune() {
String com=commune.getText()/*.replaceAll(" ","/")*/;
String com=commune.getText();
com=com.replaceAll("%","");
observationMediateur.obtenirListeReferentielCommune(this,com);
1419,6 → 1499,8
case COMMUNE:
commune.reset() ;
departement ="";
latitude.reset();
longitude.reset();
break;
case ESPECE:
1429,10 → 1511,12
case LATITUDE:
latitude.reset();
afficherIndicationCommune(null);
break;
case LONGITUDE:
longitude.reset();
afficherIndicationCommune(null);
break;
case TOUT:
1449,6 → 1533,7
espece.reset();
numeroNom = "" ;
numeroOrdre = "";
afficherIndicationCommune(null);
break;
 
}
1588,9 → 1673,9
selecteurMode.setTabIndex(0);
commune.setTabIndex(1);
lieudit.setTabIndex(2);
station.setTabIndex(3);
milieu.setTabIndex(4);
lieudit.setTabIndex(3);
station.setTabIndex(4);
milieu.setTabIndex(5);
coordonnees.setTabIndex(-1);
coordonnees.addListener(new TextFieldListenerAdapter() {
 
1603,8 → 1688,8
}
});
latitude.setTabIndex(8);
longitude.setTabIndex(9);
latitude.setTabIndex(7);
longitude.setTabIndex(8);
comment.setTabIndex(10);
date.setTabIndex(11);
espece.setTabIndex(12);
1693,29 → 1778,15
return departement;
}
/*private Field obtenirCorrespondanceChampsEnum(Champs champ) {
switch(champ) {
case DATE:
return date;
case COMMUNE:
return commune;
case LIEUDIT:
return lieudit;
case STATION:
return station;
case MILIEU:
return milieu;
case COMMENT:
return comment;
case ESPECE:
return espece;
}
return null;
}*/
public String getCommune() {
return commune.getValue();
}
public String getDepartement() {
return obtenirDepartementAPartirChampCommune();
}
 
public boolean communeInitialisee() {
return communeModifiee;
}
}