Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 267 → Rev 268

/trunk/src/org/tela_botanica/client/vues/image/ZoomImageVue.java
1,21 → 1,30
package org.tela_botanica.client.vues.image;
 
 
import org.tela_botanica.client.image.ImageMediateur;
import org.tela_botanica.client.interfaces.Rafraichissable;
 
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.user.client.Event;
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.Image;
import com.google.gwt.user.client.ui.KeyboardListener;
import com.google.gwt.user.client.ui.KeyboardListenerCollection;
import com.google.gwt.user.client.ui.LoadListener;
import com.google.gwt.user.client.ui.MouseListener;
import com.google.gwt.user.client.ui.MouseWheelListener;
import com.google.gwt.user.client.ui.MouseWheelVelocity;
import com.google.gwt.user.client.ui.ToggleButton;
import com.google.gwt.user.client.ui.Widget;
import com.gwtext.client.core.AnimationConfig;
import com.gwtext.client.core.Direction;
import com.gwtext.client.core.DomConfig;
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.RegionPosition;
import com.gwtext.client.dd.DragData;
22,13 → 31,21
import com.gwtext.client.dd.DragSource;
import com.gwtext.client.dd.DropTarget;
import com.gwtext.client.dd.DropTargetConfig;
import com.gwtext.client.widgets.Button;
import com.gwtext.client.widgets.Component;
import com.gwtext.client.widgets.Container;
import com.gwtext.client.widgets.Panel;
import com.gwtext.client.widgets.ToolTip;
import com.gwtext.client.widgets.Toolbar;
import com.gwtext.client.widgets.ToolbarButton;
import com.gwtext.client.widgets.ToolbarTextItem;
import com.gwtext.client.widgets.event.ButtonListener;
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
import com.gwtext.client.widgets.event.PanelListenerAdapter;
import com.gwtext.client.widgets.grid.GridDragData;
import com.gwtext.client.widgets.layout.BorderLayout;
import com.gwtext.client.widgets.layout.BorderLayoutData;
import com.gwtext.client.widgets.menu.Menu;
 
/**
* Panneau d'affichage d'une image avec des boutons précdents et suivant
102,6 → 119,28
*/
private boolean enClic = false;
private ToolbarButton modeZoom = null;
private ToolbarTextItem valeurZoom = new ToolbarTextItem("x 1");
private int sourisX = 0;
private int sourisY = 0;
private int sourisXFin = 0;
private int sourisYFin = 0;
private float niveauZoom = 1;
private float pasZoom = new Float(0.1);
 
private int maxZoom = 10;
private float minZoom = new Float(0.5);
 
protected boolean scroll = false;
/**
* Constructeur sans argument (privé car ne doit être utilisé)
*/
150,6 → 189,14
prev.setWidth("60px");
suiv.setWidth("60px");
 
modeZoom = new ToolbarButton("Mode Zoom");
Toolbar tb = new Toolbar();
tb.addButton(modeZoom);
tb.addItem(valeurZoom);
//setTopToolbar(tb);
this.add(prev, new BorderLayoutData(RegionPosition.WEST));
this.add(imageConteneur, new BorderLayoutData(RegionPosition.CENTER));
this.add(suiv, new BorderLayoutData(RegionPosition.EAST));
165,7 → 212,7
// on ajoute les listeners
ajouterListeners();
tp.setDismissDelay(1750);
tp.setDismissDelay(1050);
tp.applyTo(image.getElement()) ;
 
}
181,6 → 228,7
public void rafraichir(Object nouvelleDonnees,
boolean repandreRafraichissement) {
 
//niveauZoom = 1;
// si on reçoit une string
if (nouvelleDonnees instanceof String[] && initialise
&& conteneurInitialise) {
238,7 → 286,32
* Ajoute les listeners pour la gestions d'évènement
*/
public void ajouterListeners() {
modeZoom.addListener(new ButtonListenerAdapter() {
 
public void onClick(Button button, EventObject e) {
// TODO Auto-generated method stub
if(modeZoom.isPressed()) {
modeZoom.toggle(false);
} else {
modeZoom.toggle(true);
}
}
public void onToggle(Button button, boolean pressed) {
if(pressed) {
scroll = true;
image.addStyleName("img-curseur-depl");
} else {
scroll = false;
image.removeStyleName("img-curseur-depl");
niveauZoom = 1;
verifierEtRetaillerImage();
Ext.get(image.getElement()).center(imageConteneur.getElement());
}
}
});
image.addLoadListener(new LoadListener() {
 
public void onError(Widget sender) {
247,7 → 320,7
 
public void onLoad(Widget sender) {
int max = Math.min(imageConteneur.getHeight(), imageConteneur.getWidth());
/*int max = Math.min(imageConteneur.getHeight(), imageConteneur.getWidth());
int[] tailleImage = calculerDimensions(getTailleImage(), max, max);
ExtElement imgElement = Ext.get(image.getElement());
if(animerTransition) {
258,7 → 331,9
} else {
imgElement.setHeight(tailleImage[1], false);
imgElement.setWidth(tailleImage[0], false);
}
}*/
verifierEtRetaillerImage();
Ext.get(image.getElement()).center(imageConteneur.getElement());
demasquerChargement();
}
267,7 → 342,7
image.addClickListener(new ClickListener() {
 
public void onClick(Widget sender) {
if(!scroll) {
if(enClic) {
getIMediateur().doubleClicZoomImage();
} else {
280,6 → 355,7
enClic = true;
t.schedule(800);
}
}
}
});
289,14 → 365,76
public void onMouseWheel(Widget sender, MouseWheelVelocity velocity) {
if(velocity.getDeltaY() > 0) {
suiv.click();
if(scroll) {
zoomOut();
} else {
suiv.click();
}
} else {
prev.click();
if(scroll) {
zoomIn();
} else {
prev.click();
}
}
}
});
image.addMouseListener(new MouseListener() {
 
public void onMouseDown(Widget sender, int x, int y) {
if(scroll) {
Event.getCurrentEvent().preventDefault();
scroll = true;
sourisX = x;
sourisY = y;
image.addStyleName("img-curseur-depl");
}
}
 
public void onMouseEnter(Widget sender) {
// TODO Auto-generated method stub
}
 
public void onMouseLeave(Widget sender) {
// TODO Auto-generated method stub
}
 
public void onMouseMove(Widget sender, int x, int y) {
sourisXFin = x;
sourisYFin = y;
Event.getCurrentEvent().preventDefault();
}
 
public void onMouseUp(Widget sender, int x, int y) {
if(scroll) {
Event.getCurrentEvent().preventDefault();
if(sourisX - sourisXFin > 0) {
Ext.get(image.getElement()).move(Direction.LEFT, sourisX - sourisXFin, false);
}
if(sourisXFin - sourisX > 0) {
Ext.get(image.getElement()).move(Direction.RIGHT, sourisXFin - sourisX, false);
}
if(sourisY - sourisYFin > 0) {
Ext.get(image.getElement()).move(Direction.UP, sourisY - sourisYFin, false);
}
if(sourisYFin - sourisY > 0) {
Ext.get(image.getElement()).move(Direction.DOWN, sourisYFin - sourisY, false);
}
}
}
});
// gestion du clic sur le bouton précedent
prev.addClickListener(new ClickListener() {
 
357,7 → 495,7
}
 
// on prend la taille originale de l'image
int originalX = getTailleImage()[0];
/*int originalX = getTailleImage()[0];
int originalY = getTailleImage()[1];
 
// on la transforme en float (la division entre entier donne de curieux
374,7 → 512,7
 
// on prend la taille du conteneur
int tailleConteneurX = imageConteneur.getWidth();
int tailleConteneurY = imageConteneur.getHeight();
int tailleConteneurY = imageConteneur.getHeight();*/
 
// si celle-ci est égale à 0 (conteneur mal initialisé)
/*
384,7 → 522,7
* this.getWidth() - prev.getOffsetWidth() * 2 ;
* }
*/
 
/*
// si l'image ne rentre pas telle quelle (longueur ou hauteur trop
// grande)
if (originalY > tailleConteneurY || originalX > tailleConteneurX) {
405,10 → 543,39
* rapportTaille);
}
}
 
*/
// on modifie enfin la taille de l'image pour qu'elle soit affichée
getImage().setSize("" + nouvelleTailleX + "px",
"" + nouvelleTailleY + "px");
int max = Math.min(imageConteneur.getHeight(), imageConteneur.getWidth());
int[] tailleImage = new int[2];
ExtElement imgElement = Ext.get(image.getElement());
if(max == imageConteneur.getHeight()) {
//tailleImage[0] = getTailleImage()[0];
//tailleImage[1] = max;
imgElement.setHeight(max, false);
} else {
//tailleImage[1] = getTailleImage()[0];
//tailleImage[0] = max;
imgElement.setWidth(max, false);
}
//int[] tailleImage = calculerDimensions(getTailleImage(), max, max);
//imgElement.
/*if(animerTransition) {
AnimationConfig a = new AnimationConfig() ;
a.setDuration((float) dureeAnimation);
imgElement.setHeight(tailleImage[1], a);
imgElement.setWidth(tailleImage[0], a);
} else {
imgElement.setHeight(tailleImage[1], false);
imgElement.setWidth(tailleImage[0], false);
}*/
String strZoom = ""+niveauZoom+"";
strZoom = strZoom.substring(0,3);
valeurZoom.setText("x "+strZoom);
}
public int[] calculerDimensions(int[] tailleXY, double tailleMax, double tailleConteneur) {
428,7 → 595,7
XYresize[0] = tailleOr*rapport ;
}
int[] res = {Math.round(XYresize[0]),Math.round(XYresize[1])} ;
int[] res = {(int)Math.round(XYresize[0]*niveauZoom),(int) Math.round(XYresize[1]*niveauZoom)} ;
return res;
}
550,4 → 717,74
return imageConteneur;
 
}
private void zoomOut() {
if(niveauZoom >= minZoom) {
niveauZoom -= pasZoom;
if(niveauZoom <= minZoom) {
niveauZoom = minZoom;
}
verifierEtRetaillerImage();
gererDecalage(false);
}
}
 
private void zoomIn() {
if(niveauZoom < maxZoom ) {
niveauZoom += pasZoom;
if(niveauZoom >= maxZoom) {
niveauZoom = maxZoom;
}
verifierEtRetaillerImage();
gererDecalage(true);
}
}
private void gererDecalage(boolean in) {
float nZoom = niveauZoom;
if(niveauZoom < 1) {
nZoom = 1/niveauZoom;
}
if(!in) {
int diffX = imageConteneur.getWidth()/2 - sourisX;
int diffY = imageConteneur.getHeight()/2 - sourisY;
if(diffX > 0) {
Ext.get(image.getElement()).move(Direction.RIGHT, (int)((diffX/maxZoom)/nZoom), false);
}
if(-diffX > 0) {
Ext.get(image.getElement()).move(Direction.LEFT, (int)(-(diffX/maxZoom)/nZoom), false);
}
if(diffY > 0) {
Ext.get(image.getElement()).move(Direction.DOWN, (int)((diffY/maxZoom)/nZoom), false);
}
if(-diffY > 0) {
Ext.get(image.getElement()).move(Direction.UP, (int)(-(diffY/maxZoom)/nZoom), false);
}
} else {
int diffX = imageConteneur.getWidth()/2;
int diffY = imageConteneur.getHeight()/2;
if(diffX > 0) {
Ext.get(image.getElement()).move(Direction.LEFT, (int)((diffX/maxZoom)/nZoom), false);
}
if(-diffX > 0) {
Ext.get(image.getElement()).move(Direction.RIGHT, (int)((-diffX/maxZoom)/nZoom), false);
}
if(diffY > 0) {
Ext.get(image.getElement()).move(Direction.UP, (int)((diffY/maxZoom)/nZoom), false);
}
if(-diffY > 0) {
Ext.get(image.getElement()).move(Direction.DOWN, (int)(-(diffY/maxZoom)/nZoom), false);
}
}
}
}
/trunk/src/org/tela_botanica/client/vues/ListeUtilisateurAdminVue.java
9,6 → 9,7
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.RegionPosition;
import com.gwtext.client.data.ArrayReader;
import com.gwtext.client.data.FieldDef;
import com.gwtext.client.data.MemoryProxy;
18,6 → 19,7
import com.gwtext.client.data.StringFieldDef;
import com.gwtext.client.widgets.BoxComponent;
import com.gwtext.client.widgets.Component;
import com.gwtext.client.widgets.Panel;
import com.gwtext.client.widgets.Window;
import com.gwtext.client.widgets.event.ButtonListener;
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
26,6 → 28,10
import com.gwtext.client.widgets.form.event.ComboBoxCallback;
import com.gwtext.client.widgets.form.event.ComboBoxListener;
import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter;
import com.gwtext.client.widgets.layout.BorderLayout;
import com.gwtext.client.widgets.layout.BorderLayoutData;
import com.gwtext.client.widgets.layout.HorizontalLayout;
import com.gwtext.client.widgets.layout.RowLayout;
import com.gwtext.client.widgets.menu.Menu;
 
public class ListeUtilisateurAdminVue extends Window implements Rafraichissable {
34,6 → 40,7
private ComboBox listeUtil = null ;
private Store storeUtil = null ;
private com.gwtext.client.widgets.Button OK = null;
private com.gwtext.client.widgets.Button annuler = null;
private boolean selectionUtilisateur =false;
private final int KEY_ALT = 18;
60,6 → 67,7
listeUtil=new ComboBox("Utilisateurs","utilisateur",280);
this.setLayout(new RowLayout());
final String resultTplUtil = "<div class=\"search-item-utilisateur\">{utilisateur}</div>";
 
74,10 → 82,18
listeUtil.setLoadingText("Recherche...");
OK= new com.gwtext.client.widgets.Button("OK");
annuler = new com.gwtext.client.widgets.Button("Annuler");
Panel boutonPanel = new Panel();
boutonPanel.setLayout(new HorizontalLayout(0));
add(listeUtil);
add(OK);
boutonPanel.add(OK);
boutonPanel.add(annuler);
add(boutonPanel);
this.setSize(300, 75);
OK.addListener(new ButtonListenerAdapter() {
85,10 → 101,19
public void onClick(com.gwtext.client.widgets.Button button,
EventObject e) {
cMediateur.changerIdentite(listeUtil.getValue());
close();
}
});
annuler.addListener(new ButtonListenerAdapter() {
 
public void onClick(com.gwtext.client.widgets.Button button,
EventObject e) {
cMediateur.changerIdentite(listeUtil.getValue());
close();
}
});
final ListeUtilisateurAdminVue l = this ;
listeUtil.addKeyPressListener(new EventCallback() {
172,12 → 197,10
String valeur = listeUtil.getRawValue();
 
cMediateur.obtenirListeUtilisateurs(valeur,this) ;
/*
String esp=espece.getText().replaceAll(" ","/");
esp=esp.replaceAll("%","");
observationMediateur.obtenirListeReferentielNom(this,esp);
*/
}
 
public void focusChampUtilisateur() {
listeUtil.focus();
}
 
}
/trunk/src/org/tela_botanica/client/vues/ArbreMotsClesFiltreVue.java
439,40 → 439,42
 
public void raz() {
// on vide tous les noeuds de l'ancien arbre
Node[] rootChild = arbreMotsCles.getRootNode().getChildNodes();
for (int i = 0; i < rootChild.length; i++) {
if(arbreInitialise) {
// on vide tous les noeuds de l'ancien arbre
Node[] rootChild = arbreMotsCles.getRootNode().getChildNodes();
for (int i = 0; i < rootChild.length; i++) {
rootChild[i].remove();
}
rootChild[i].remove();
}
arbreInitialise = false ;
// on crée une racine pour l'arbre
TreeNode root = new TreeNode("Tags");
root.setId("racine"+prefixe);
String[] usObject = { "Mots clés", "racine" };
root.setUserObject(usObject);
root.setExpandable(true);
arbreMotsCles.setRootNode(root);
arbreMotsCles.getRootNode().addListener(new TreeNodeListenerAdapter() {
 
public void onClick(Node node, EventObject e) {
if(!arbreInitialise) {
expand();
arbreInitialise = false ;
// on crée une racine pour l'arbre
TreeNode root = new TreeNode("Tags");
root.setId("racine"+prefixe);
String[] usObject = { "Mots clés", "racine" };
root.setUserObject(usObject);
root.setExpandable(true);
arbreMotsCles.setRootNode(root);
arbreMotsCles.getRootNode().addListener(new TreeNodeListenerAdapter() {
public void onClick(Node node, EventObject e) {
if(!arbreInitialise) {
expand();
}
}
}
 
public void onExpand(Node node) {
if(!arbreInitialise) {
obtenirArbreMotsCles();
arbreInitialise = true;
public void onExpand(Node node) {
if(!arbreInitialise) {
obtenirArbreMotsCles();
arbreInitialise = true;
}
}
}
});
});
}
}
 
}
/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 = "";
}
}
}
/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;
}
}