Subversion Repositories eFlore/Applications.del

Compare Revisions

Ignore whitespace Rev 334 → Rev 335

/trunk/src/org/tela_botanica/del/client/composants/moteurrecherche/MoteurRechercheVue.ui.xml
1,62 → 1,68
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder' xmlns:g='urn:import:com.google.gwt.user.client.ui'
ui:generateFormat='com.google.gwt.i18n.rebind.format.PropertiesFormat' ui:generateKeys="com.google.gwt.i18n.rebind.keygen.MD5KeyGenerator" ui:generateLocales="default">
<ui:with field='res' type='org.tela_botanica.del.client.Ressources'/>
<ui:with field="constants" type="org.tela_botanica.del.client.i18n.Vocabulary"/>
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui' ui:generateFormat='com.google.gwt.i18n.rebind.format.PropertiesFormat'
ui:generateKeys="com.google.gwt.i18n.rebind.keygen.MD5KeyGenerator"
ui:generateLocales="default">
<ui:with field='res' type='org.tela_botanica.del.client.Ressources' />
<ui:with field="constants" type="org.tela_botanica.del.client.i18n.Vocabulary" />
 
<ui:style src="MoteurRecherche.css" />
<ui:style src="MoteurRecherche.css" />
<g:HTMLPanel>
<g:TextBox styleName="{style.recherchePrincipale}" ui:field="recherchePrincipale">{constants.}</g:TextBox>
<g:Button styleName="{style.boutonRecherche}" ui:field="boutonRecherche">Rechercher</g:Button>
<g:Label styleName="{style.lienRechercheAvancee}" ui:field="lienRechercheAvancee">Recherche avancée</g:Label>
<g:HTMLPanel styleName="{style.rechercheAvancee}" ui:field="rechercheAvancee">
<g:HTMLPanel styleName="{style.champRecherche}">
<g:Label text="Département"/>
<g:TextBox ui:field="departement"/>
</g:HTMLPanel>
<g:HTMLPanel styleName="{style.champRecherche}">
<g:Label text="Commune"/>
<g:TextBox ui:field="commune"/>
</g:HTMLPanel>
<g:HTMLPanel styleName="{style.champRecherche}">
<g:Label text="Taxon"/>
<g:TextBox ui:field="taxon"/>
</g:HTMLPanel>
<g:HTMLPanel styleName="{style.champRecherche}">
<g:Label text="Famille"/>
<g:TextBox ui:field="famille"/>
</g:HTMLPanel>
<g:HTMLPanel styleName="{style.champRecherche}">
<g:Label text="Genre"/>
<g:TextBox ui:field="genre"/>
</g:HTMLPanel>
<g:HTMLPanel styleName="{style.champRecherche}">
<g:Label text="Tag"/>
<g:TextBox ui:field="tag"/>
</g:HTMLPanel>
<g:HTMLPanel styleName="{style.champRecherche}">
<g:Label text="Mot-clé"/>
<g:TextBox ui:field="motCle"/>
</g:HTMLPanel>
<g:HTMLPanel styleName="{style.champRecherche}">
<g:Label text="Auteur"/>
<g:TextBox ui:field="auteur"/>
</g:HTMLPanel>
<g:HTMLPanel styleName="{style.champRecherche}">
<g:Label text="Date"/>
<g:TextBox ui:field="date"/>
</g:HTMLPanel>
<g:Button styleName="{style.boutonRecherche}" ui:field="boutonRechercheAvancee">Rechercher</g:Button>
<g:HTMLPanel styleName="nettoyage" />
<g:TextBox styleName="{style.recherchePrincipale}" ui:field="recherchePrincipale" text="{constants.rechercherObservation}"></g:TextBox>
<g:Button styleName="{style.boutonRecherche}" ui:field="boutonRecherche" text="{constants.rechercher}">
</g:Button>
<g:Label styleName="{style.lienRechercheAvancee}" ui:field="lienRechercheAvancee" text="{constants.rechercheAvancee}"></g:Label>
<g:HTMLPanel styleName="{style.rechercheAvancee}"
ui:field="rechercheAvancee">
<g:HTMLPanel styleName="{style.champRecherche}">
<g:Label text="{constants.departement}" />
<g:TextBox ui:field="departement" />
</g:HTMLPanel>
<g:Label ui:field="recherchePrecedente" styleName="{style.recherchePrecedente}" />
<g:HTMLPanel ui:field="zonePagination" />
 
<g:HTMLPanel styleName="{style.champRecherche}">
<g:Label text="{constants.commune}" />
<g:TextBox ui:field="commune" />
</g:HTMLPanel>
 
<g:HTMLPanel styleName="{style.champRecherche}">
<g:Label text="{constants.taxon}" />
<g:TextBox ui:field="taxon" />
</g:HTMLPanel>
 
<g:HTMLPanel styleName="{style.champRecherche}">
<g:Label text="{constants.famille}" />
<g:TextBox ui:field="famille" />
</g:HTMLPanel>
 
<g:HTMLPanel styleName="{style.champRecherche}">
<g:Label text="{constants.genre}" />
<g:TextBox ui:field="genre" />
</g:HTMLPanel>
 
<g:HTMLPanel styleName="{style.champRecherche}">
<g:Label text="{constants.tag}" />
<g:TextBox ui:field="tag" />
</g:HTMLPanel>
 
<g:HTMLPanel styleName="{style.champRecherche}">
<g:Label text="{constants.mot_clef}" />
<g:TextBox ui:field="motCle" />
</g:HTMLPanel>
 
<g:HTMLPanel styleName="{style.champRecherche}">
<g:Label text="{constants.auteur}" />
<g:TextBox ui:field="auteur" />
</g:HTMLPanel>
 
<g:HTMLPanel styleName="{style.champRecherche}">
<g:Label text="{constants.date}" />
<g:TextBox ui:field="date" />
</g:HTMLPanel>
<g:Button styleName="{style.boutonRecherche}" ui:field="boutonRechercheAvancee" text="{constants.rechercher}">
</g:Button>
<g:HTMLPanel styleName="nettoyage" />
</g:HTMLPanel>
<g:Label ui:field="recherchePrecedente" styleName="{style.recherchePrecedente}" />
<g:HTMLPanel ui:field="zonePagination" />
</g:HTMLPanel>
</ui:UiBinder>
/trunk/src/org/tela_botanica/del/client/composants/moteurrecherche/MoteurRecherchePresenteur.java
1,9 → 1,8
package org.tela_botanica.del.client.composants.moteurrecherche;
 
import java.util.HashMap;
 
import org.tela_botanica.del.client.cache.CacheClient;
import org.tela_botanica.del.client.composants.presenteur.Presenteur;
import org.tela_botanica.del.client.i18n.I18n;
import org.tela_botanica.del.client.modeles.InformationsRecherche;
 
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
12,36 → 11,68
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyPressEvent;
import com.google.gwt.event.dom.client.KeyPressHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.IsWidget;
 
public abstract class MoteurRecherchePresenteur extends Presenteur {
 
public abstract interface Vue extends IsWidget {
 
public abstract HasClickHandlers getLienRechercheAvancee();
 
public abstract void basculerAffichageZoneCache();
 
public abstract HasClickHandlers getBoutonRechercheSimple();
 
public abstract HasClickHandlers getBoutonRechercheAvancee();
 
public abstract HasKeyPressHandlers getChampSaisie();
 
public abstract HasClickHandlers getChampSaisieCliquable();
 
public abstract String getValeurRechercheSimple();
 
public void setValeurRechercheSimple(String valeurRecherche);
 
public String getLabelRecherche();
public abstract HashMap<String, String> collecterFormulaire();
public String getChaineRecherche();
public abstract void setRecherchePrecedente();
 
public HasText getRecherchePrincipale();
 
public HasText getDepartement();
 
public HasText getCommune();
 
public HasText getTaxon();
 
public HasText getFamille();
 
public HasText getGenre();
 
public HasText getTag();
 
public HasText getMotCle();
 
public HasText getAuteur();
 
public HasText getDate();
 
public void chargerValeursRecherchePrecedente(InformationsRecherche informationsRecherche);
}
 
private Vue vue;
public MoteurRecherchePresenteur(Vue vue) {
private final Vue vue;
private final boolean pourRechercheImages, pourRechercheObservations;
 
public MoteurRecherchePresenteur(Vue vue, boolean pourRechercheImages, boolean pourRechercheObservations) {
this.vue = vue;
this.pourRechercheImages = pourRechercheImages;
this.pourRechercheObservations = pourRechercheObservations;
gererEvenements();
}
 
@Override
public void go(HasWidgets composite) {
afficherRequeteEtLancerRecherche();
composite.add(vue.asWidget());
}
 
52,33 → 83,34
vue.basculerAffichageZoneCache();
}
});
 
vue.getBoutonRechercheSimple().addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
afficherInfoRecherche();
lancerRecherche(vue.getChaineRecherche());
collecterInfosRecherche();
afficherRequeteEtLancerRecherche();
}
});
 
vue.getBoutonRechercheAvancee().addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
afficherInfoRecherche();
lancerRecherche(vue.getChaineRecherche());
collecterInfosRecherche();
vue.basculerAffichageZoneCache();
afficherRequeteEtLancerRecherche();
}
});
 
vue.getChampSaisie().addKeyPressHandler(new KeyPressHandler() {
 
public void onKeyPress(KeyPressEvent event) {
if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
afficherInfoRecherche();
lancerRecherche(vue.getChaineRecherche());
collecterInfosRecherche();
afficherRequeteEtLancerRecherche();
}
}
});
 
vue.getChampSaisieCliquable().addClickHandler(new ClickHandler() {
 
@Override
public void onClick(ClickEvent event) {
if (vue.getValeurRechercheSimple().equals(vue.getLabelRecherche())) {
86,12 → 118,52
}
}
});
}
private void afficherInfoRecherche() {
vue.setRecherchePrecedente();
 
private void collecterInfosRecherche() {
InformationsRecherche informationRecherche = new InformationsRecherche();
informationRecherche.setAuteur(vue.getAuteur().getText());
informationRecherche.setCommune(vue.getCommune().getText());
informationRecherche.setDate(vue.getDate().getText());
informationRecherche.setDepartement(vue.getDepartement().getText());
informationRecherche.setFamille(vue.getFamille().getText());
informationRecherche.setGenre(vue.getGenre().getText());
informationRecherche.setMotClef(vue.getMotCle().getText());
 
if (!vue.getRecherchePrincipale().getText().equals(vue.getLabelRecherche())) {
informationRecherche.setRechercheLibre(vue.getRecherchePrincipale().getText());
}
if (isPourRechercheImages()) {
CacheClient.getInstance().setInformationsRechercheImage(informationRecherche);
} else if (isPourRechercheObservations()) {
CacheClient.getInstance().setInformationsRechercheObservation(informationRecherche);
}
}
public abstract void lancerRecherche(String termeRecherche);
 
private InformationsRecherche getInformationsRechercheEnCache() {
if (isPourRechercheImages()) {
return CacheClient.getInstance().getInformationsRechercheImage();
} else if (isPourRechercheObservations()) {
return CacheClient.getInstance().getInformationsRechercheObservation();
}
return null;
}
 
public void afficherRequeteEtLancerRecherche() {
InformationsRecherche informationsRecherche = getInformationsRechercheEnCache();
if (informationsRecherche != null) {
vue.chargerValeursRecherchePrecedente(informationsRecherche);
}
lancerRecherche();
}
 
public abstract void lancerRecherche();
 
public boolean isPourRechercheImages() {
return pourRechercheImages;
}
 
public boolean isPourRechercheObservations() {
return pourRechercheObservations;
}
}
/trunk/src/org/tela_botanica/del/client/composants/moteurrecherche/MoteurRechercheVue.java
1,7 → 1,7
package org.tela_botanica.del.client.composants.moteurrecherche;
 
import java.util.HashMap;
import java.util.Iterator;
import org.tela_botanica.del.client.i18n.I18n;
import org.tela_botanica.del.client.modeles.InformationsRecherche;
 
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.HasClickHandlers;
8,10 → 8,9
import com.google.gwt.event.dom.client.HasKeyPressHandlers;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.TextBox;
19,15 → 18,21
 
public class MoteurRechercheVue extends Composite implements MoteurRecherchePresenteur.Vue {
 
interface Binder extends UiBinder<Widget, MoteurRechercheVue> {}
interface Binder extends UiBinder<Widget, MoteurRechercheVue> {
}
 
private static Binder uiBinder = GWT.create(Binder.class);
private String labelRecherche = "";
@UiField Panel rechercheAvancee;
@UiField Label lienRechercheAvancee, recherchePrecedente;
@UiField Button boutonRecherche, boutonRechercheAvancee;
@UiField TextBox recherchePrincipale, departement, commune, taxon, famille, genre, tag, motCle, auteur, date;
 
@UiField
Panel rechercheAvancee;
@UiField
Label lienRechercheAvancee, recherchePrecedente;
@UiField
Button boutonRecherche, boutonRechercheAvancee;
@UiField
TextBox recherchePrincipale, departement, commune, taxon, famille, genre, tag, motCle, auteur, date;
 
public MoteurRechercheVue(String labelRecherche) {
initWidget(uiBinder.createAndBindUi(this));
this.labelRecherche = labelRecherche;
38,7 → 43,7
public String getLabelRecherche() {
return labelRecherche;
}
 
@Override
public HasClickHandlers getLienRechercheAvancee() {
return lienRechercheAvancee;
53,7 → 58,7
public HasClickHandlers getBoutonRechercheSimple() {
return boutonRecherche;
}
 
@Override
public HasClickHandlers getBoutonRechercheAvancee() {
return boutonRechercheAvancee;
73,70 → 78,102
public HasClickHandlers getChampSaisieCliquable() {
return recherchePrincipale;
}
 
@Override
public void setValeurRechercheSimple(String valeurRecherche) {
recherchePrincipale.setText(valeurRecherche);
}
 
@Override
public HashMap<String, String> collecterFormulaire() {
public void chargerValeursRecherchePrecedente(InformationsRecherche informationsRecherche) {
getAuteur().setText(informationsRecherche.getAuteur());
getCommune().setText(informationsRecherche.getCommune());
getDate().setText(informationsRecherche.getDate());
getDepartement().setText(informationsRecherche.getDepartement());
getFamille().setText(informationsRecherche.getFamille());
getMotCle().setText(informationsRecherche.getMotClef());
 
HashMap<String, String> champsRecherche = new HashMap<String, String>();
if (!recherchePrincipale.getText().equals("")) {
champsRecherche.put("search", recherchePrincipale.getText());
}
if (!departement.getText().equals("")) {
champsRecherche.put("dept", departement.getText());
if (informationsRecherche.getRechercheLibre() != null && !informationsRecherche.getRechercheLibre().equals("")) {
getRecherchePrincipale().setText(informationsRecherche.getRechercheLibre());
}
if (!commune.getText().equals("")) {
champsRecherche.put("com", commune.getText());
 
afficherLigneInfoRecherche(informationsRecherche);
}
 
/**
* Affiche la ligne d'en tête montrant les elements de la requête à
* l'utilisateur
*
* @param informationRecherche
*/
private void afficherLigneInfoRecherche(InformationsRecherche informationRecherche) {
 
StringBuffer texteRecherchePrecedente = new StringBuffer();
if (informationRecherche.getRechercheLibre()!=null&&!informationRecherche.getRechercheLibre().equals("")) {
texteRecherchePrecedente.append(I18n.getVocabulary().rechercheLibre() + ":" + informationRecherche.getRechercheLibre() + " ");
}
if (!taxon.getText().equals("")) {
champsRecherche.put("taxon", taxon.getText());
if (!informationRecherche.getAuteur().equals("")) {
texteRecherchePrecedente.append(I18n.getVocabulary().auteur() + ":" + informationRecherche.getAuteur() + " ");
}
if (!famille.getText().equals("")) {
champsRecherche.put("fam", famille.getText());
if (!informationRecherche.getCommune().equals("")) {
texteRecherchePrecedente.append(I18n.getVocabulary().commune() + ":" + informationRecherche.getCommune() + " ");
}
if (!genre.getText().equals("")) {
champsRecherche.put("gen", genre.getText());
if (!informationRecherche.getDate().equals("")) {
texteRecherchePrecedente.append(I18n.getVocabulary().date() + ":" + informationRecherche.getDate() + " ");
}
if (!tag.getText().equals("")) {
champsRecherche.put("tag", tag.getText());
if (!informationRecherche.getDepartement().equals("")) {
texteRecherchePrecedente.append(I18n.getVocabulary().departement() + ":" + informationRecherche.getDepartement() + " ");
}
if (!motCle.getText().equals("")) {
champsRecherche.put("motCle", motCle.getText());
if (!informationRecherche.getFamille().equals("")) {
texteRecherchePrecedente.append(I18n.getVocabulary().famille() + ":" + informationRecherche.getFamille() + " ");
}
if (!auteur.getText().equals("")) {
champsRecherche.put("auteur", auteur.getText());
if (!informationRecherche.getGenre().equals("")) {
texteRecherchePrecedente.append(I18n.getVocabulary().genre() + ":" + informationRecherche.getGenre() + " ");
}
if (!date.getText().equals("")) {
champsRecherche.put("date", date.getText());
if (!informationRecherche.getMotClef().equals("")) {
texteRecherchePrecedente.append(I18n.getVocabulary().mot_clef() + ":" + informationRecherche.getMotClef() + " ");
}
return champsRecherche;
recherchePrecedente.setText(texteRecherchePrecedente.toString());
}
@Override
public String getChaineRecherche() {
HashMap<String, String> valeursRecherche = collecterFormulaire();
String chaineRecherche = "";
if (valeursRecherche != null) {
Iterator<String> itCles = valeursRecherche.keySet().iterator();
while (itCles.hasNext()) {
String cle = itCles.next();
String valeur = valeursRecherche.get(cle);
if (valeur != "") {
chaineRecherche += cle + ":=" + valeur + " ";
}
}
}
return chaineRecherche;
 
public HasText getRecherchePrincipale() {
return recherchePrincipale;
}
 
@Override
public void setRecherchePrecedente() {
recherchePrecedente.setText(getChaineRecherche());
public HasText getDepartement() {
return departement;
}
 
public HasText getCommune() {
return commune;
}
 
public HasText getTaxon() {
return taxon;
}
 
public HasText getFamille() {
return famille;
}
 
public HasText getGenre() {
return genre;
}
 
public HasText getTag() {
return tag;
}
 
public HasText getMotCle() {
return motCle;
}
 
public HasText getAuteur() {
return auteur;
}
 
public HasText getDate() {
return date;
}
 
}