Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 264 → 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;
}
}
/trunk/src/org/tela_botanica/client/vues/observation/CartographieObservationVue.java
9,6 → 9,7
import com.google.gwt.maps.client.MapType;
import com.google.gwt.maps.client.MapWidget;
import com.google.gwt.maps.client.control.LargeMapControl;
import com.google.gwt.maps.client.event.InfoWindowRestoreEndHandler;
import com.google.gwt.maps.client.event.MapZoomEndHandler;
import com.google.gwt.maps.client.event.MarkerClickHandler;
import com.google.gwt.maps.client.event.MarkerDragEndHandler;
18,6 → 19,7
import com.google.gwt.maps.client.geom.LatLng;
import com.google.gwt.maps.client.overlay.Marker;
import com.google.gwt.maps.client.overlay.MarkerOptions;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.HTML;
import com.gwtext.client.core.EventCallback;
62,6 → 64,8
 
private InfoWindow info;
 
private boolean listenerInitialise = false;
 
public CartographieObservationVue(ObservationMediateur om) {
oMediateur = om;
83,7 → 87,7
public void onAfterLayout(Container c) {
if(!carteAjoutee) {
initialiserCarte();
initialiserCarte(false);
}
recentrerCarte();
}
115,7 → 119,7
public void mettreAJourInfos(final LatLng pointNouvelleCommune, String infosComplementaires, int zoom) {
 
if (!carteAjoutee) {
initialiserCarte();
initialiserCarte(true);
}
 
pointCommune = pointNouvelleCommune;
126,12 → 130,15
recentrerCarte();
}
 
public void initialiserCarte() {
public void initialiserCarte(boolean commune) {
 
map = new MapWidget(pointCommune, niveauZoom);
panneauCarto.add(map);
panneauCarto.doLayout();
info = map.getInfoWindow();
if(!commune) {
fabriquerMarqueurIndication();
}
map.checkResizeAndCenter();
map.setUIToDefault();
map.addControl(new LargeMapControl());
147,6 → 154,17
});
}
public void fabriquerMarqueurIndication() {
Marker marker = fabriquerMarqueur(pointCommune,"");
map.addOverlay(marker);
info.open(marker, new InfoWindowContent("<div id=\"info_contenu\">"+
"Déplacez ce marqueur pour localiser votre observation (commune et coordonnées)<br />"
+"longitude="
+ marker.getLatLng().getLongitude() + "<br />latitude="
+ marker.getLatLng().getLatitude() + "</div>"));
map.setZoomLevel(3);
}
 
public void AfficherMessageAucuneInfos() {
mettreAJourInfos(centreFrance,"", niveauZoom);
157,11 → 175,22
return niveauZoom;
}
private void ajouterListenerBouton(String idBouton) {
ExtElement bouton = Ext.get(idBouton);
 
private void ajouterListenerBouton(final String idBouton) {
final ExtElement bouton = Ext.get(idBouton);
if(bouton == null) {
Timer t = new Timer() {
public void run() {
ajouterListenerBouton(idBouton);
}
};
t.schedule(500);
return;
}
bouton.addListener("click", new EventCallback() {
 
public void execute(EventObject e) {
EntiteGeographiqueObservation infosCommune = new EntiteGeographiqueObservation(codeCommune,valeurCommune,null,null);
infosCommune.setLat(pointCommune.getLatitude()+"");
168,8 → 197,9
infosCommune.setLon(pointCommune.getLongitude()+"");
oMediateur.rafraichirSaisieCommuneObservation(infosCommune);
}
 
});
});
bouton.focus();
}
 
public void rafraichir(Object nouvelleDonnees,
181,14 → 211,15
}
}
 
if (nouvelleDonnees instanceof Object[]) {
if (nouvelleDonnees instanceof EntiteGeographiqueObservation) {
Object[] infos = (Object[]) nouvelleDonnees;
LatLng coord = LatLng.newInstance((Double) infos[0],
(Double) infos[1]);
EntiteGeographiqueObservation infos = (EntiteGeographiqueObservation) nouvelleDonnees;
LatLng coord = LatLng.newInstance(Double.parseDouble(infos.getLat()),
Double.parseDouble(infos.getLon()));
valeurCommune = (String)infos[3];
codeCommune = (String)infos[2];
valeurCommune = infos.getCommune();
codeCommune = infos.getIdLocalite();
pointCommune = coord;
mettreAJourInfos(coord, "", niveauZoom);
}
230,7 → 261,6
}
 
public void recentrerCarte() {
//mettreAJourInfos(pointCommune,"", niveauZoom);
map.setSize((this.getWidth() - 12)+"px" , (this.getHeight() - 24)+"px");
panneauCarto.setSize((this.getWidth() - 12)+"px" , (this.getHeight() - 12)+"px");
map.setCenter(pointCommune, niveauZoom);
242,6 → 272,7
}
public void afficherInfoMarker(Marker marker) {
final String htmlBoutonOk = "<br /><button id=\"okMap\" class=\"x-btn-text\" type=\"button\">OK</button>";
 
info.open(marker, new InfoWindowContent(""
249,7 → 280,8
+"longitude="
+ marker.getLatLng().getLongitude() + "<br />latitude="
+ marker.getLatLng().getLatitude() + htmlBoutonOk));
 
recentrerCarte();
ajouterListenerBouton("okMap");
}
 
/trunk/src/org/tela_botanica/client/vues/observation/filtres/RechercheLibreVue.java
New file
0,0 → 1,102
package org.tela_botanica.client.vues.observation.filtres;
 
import org.tela_botanica.client.interfaces.Filtrable;
import org.tela_botanica.client.observation.ObservationMediateur;
 
import com.google.gwt.user.client.ui.ClickListener;
import com.gwtext.client.core.EventCallback;
import com.gwtext.client.core.EventObject;
import com.google.gwt.user.client.ui.Widget;
import com.gwtext.client.widgets.Button;
import com.gwtext.client.widgets.Panel;
import com.gwtext.client.widgets.event.ButtonListener;
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
import com.gwtext.client.widgets.form.TextField;
 
public class RechercheLibreVue extends Panel implements Filtrable {
 
private ObservationMediateur oMediateur = null;
private TextField champRecherche = null;
private static String titrePanneau = "Recherche libre";
private String valeurRecherchee= "";
private Button boutonRechercher = null;
private boolean estModifie = true;
private final int KEY_ENTER = 13;
public RechercheLibreVue(ObservationMediateur om) {
super(titrePanneau);
oMediateur = om;
champRecherche = new TextField();
boutonRechercher = new Button("Rechercher");
boutonRechercher.addListener(new ButtonListenerAdapter() {
 
public void onClick(Button button, EventObject e) {
valider();
}
});
champRecherche.addKeyPressListener(new EventCallback() {
public void execute(EventObject e) {
switch(e.getKey()) {
case KEY_ENTER:
valider();
break;
}
}
});
add(champRecherche);
add(boutonRechercher);
setCollapsible(true);
setTitleCollapse(true);
setPaddings(5);
}
 
 
public boolean renvoyerEtatFiltre() {
return estModifie;
}
 
 
public String renvoyerNomFiltre() {
return "Taxon";
}
 
public String[] renvoyerValeursAFiltrer() {
if(champRecherche.getValueAsString() != null) {
valeurRecherchee = champRecherche.getValueAsString();
}
String[] valeurs = {"nom_taxon",valeurRecherchee};
return valeurs;
}
 
 
public void valider() {
if(champRecherche.getValueAsString() != null && champRecherche.getValueAsString() != valeurRecherchee) {
estModifie = true;
oMediateur.obtenirNombreObservation();
} else {
estModifie = false;
}
}
public void raz() {
if(champRecherche.isCreated()) {
champRecherche.reset();
valeurRecherchee = "";
}
}
}