Subversion Repositories eFlore/Applications.del

Compare Revisions

Ignore whitespace Rev 2140 → Rev 2171

/branches/v1.11-magnesium/src/org/tela_botanica/del/client/composants/moteurrecherche/MoteurRecherche.css
New file
0,0 → 1,117
.recherchePrincipale {
width:550px;
font-size: 18px;
padding: 5px;
border: solid 1px #AAA;
float: left;
}
 
.boutonRecherche {
border: solid 1px #AAA;
padding: 5px;
cursor: pointer;
float: left;
margin: 0 10px 0 10px
}
 
.lienRechercheAvancee {
cursor: pointer;
text-decoration: underline;
color: blue;
float: left;
margin-right: 240px;
margin: 5px
}
 
.rechercheAvancee {
border: solid 1px #333;
padding: 15px;
position: absolute;
width: 750px;
margin-top: 0px;
background: white;
z-index: 2000
}
 
.conteneurDeuxPanneaux {
width: 700px;
}
 
.panneauGauche {
float: left;
width: 300px;
}
 
.panneauDroite {
float: left;
width: 300px;
}
 
.champRecherche {
width: 90%;
padding-bottom: 5px
}
 
.champRecherche input {
width: 90%
}
 
.recherchePrecedente {
color: #555;
padding: 5px 5px 10px;
font-style: italic;
clear: left
}
 
.boutonFermer {
float: right;
background: url("./img/cross.png") no-repeat 0 2px;
border: none;
padding: 0 0 0 16px;
color: blue;
text-decoration: underline;
cursor: pointer;
height: 19px;
}
 
.boutonVider {
float: right;
background: url("./img/cancel.png") no-repeat 0 2px;
border: none;
padding: 0 0 0 16px;
color: blue;
text-decoration: underline;
cursor: pointer;
height: 19px
}
 
.rechercherAvance {
margin-top: 0px;
margin-left:0px;
top: 195px;
position: relative;
left: 25px;
}
 
.casePnInscritsSeulement {
float: left;
}
 
.labelPnInscritsSeulement {
margin-top: 4px;
}
 
.zoneRecherche {
}
.zoneRss {
float:right;
margin-top:5px;
}
.zoneRss a {
border:none;
}
 
.nettoyage {
visibility: hidden;
clear: both;
}
/branches/v1.11-magnesium/src/org/tela_botanica/del/client/composants/moteurrecherche/MoteurRechercheVue.ui.xml
New file
0,0 → 1,105
<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.resources.Ressources' />
<ui:with field="constants" type="org.tela_botanica.del.client.i18n.Vocabulary" />
 
<ui:style src="MoteurRecherche.css" />
<g:HTMLPanel styleName="limiteMin {style.zoneRecherche}">
<g:TextBox styleName="{style.recherchePrincipale} arrondi" ui:field="recherchePrincipale" text="{constants.rechercherObservation}"></g:TextBox>
<g:Button styleName="{style.boutonRecherche} arrondi" 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} ombre-forte" ui:field="rechercheAvancee">
<g:Button ui:field="boutonFermer" styleName="{style.boutonFermer}" text="Fermer"></g:Button>
<g:Button ui:field="boutonVider" styleName="{style.boutonVider}" text="Vider"></g:Button>
 
<g:HTMLPanel styleName="{style.conteneurDeuxPanneaux}">
<g:HTMLPanel styleName="{style.panneauGauche}">
<g:HTMLPanel styleName="{style.champRecherche}">
<g:Label text="{constants.contientMots}" styleName="petit"/>
<g:TextBox ui:field="contientMots" />
</g:HTMLPanel>
<g:HTMLPanel styleName="{style.champRecherche}">
<g:Label text="{constants.referentiel}" styleName="petit"/>
<g:ListBox ui:field="referentiel" />
</g:HTMLPanel>
<g:HTMLPanel styleName="{style.champRecherche}">
<g:Label text="{constants.famille}" styleName="petit"/>
<g:TextBox ui:field="famille" />
</g:HTMLPanel>
<g:HTMLPanel styleName="{style.champRecherche}">
<g:Label text="{constants.genre}" styleName="petit"/>
<g:TextBox ui:field="genre" />
</g:HTMLPanel>
<g:HTMLPanel styleName="{style.champRecherche}">
<g:Label text="{constants.taxon}" styleName="petit"/>
<g:HTMLPanel ui:field="taxon" />
</g:HTMLPanel>
<g:HTMLPanel styleName="{style.champRecherche}">
<g:Label text="{constants.date} {constants.formatDate}" styleName="petit"/>
<g:TextBox ui:field="date" />
</g:HTMLPanel>
</g:HTMLPanel>
<g:HTMLPanel styleName="{style.panneauDroite}">
<g:HTMLPanel styleName="{style.champRecherche}">
<g:Label text="{constants.pays}" styleName="petit"/>
<g:ListBox ui:field="pays" />
</g:HTMLPanel>
<g:HTMLPanel styleName="{style.champRecherche}">
<g:Label text="{constants.departement}" styleName="petit"/>
<g:TextBox ui:field="departement" />
</g:HTMLPanel>
<g:HTMLPanel styleName="{style.champRecherche}">
<g:Label text="{constants.commune}" styleName="petit"/>
<g:HTMLPanel ui:field="commune" />
</g:HTMLPanel>
<g:HTMLPanel styleName="{style.champRecherche}">
<g:Label text="{constants.auteur}" styleName="petit"/>
<g:TextBox ui:field="auteur" />
</g:HTMLPanel>
<g:HTMLPanel ui:field="conteneurMotCle" styleName="{style.champRecherche}">
<g:Label text="{constants.tag}" styleName="petit"/>
<g:TextBox ui:field="motCle" />
</g:HTMLPanel>
<g:HTMLPanel ui:field="conteneurMotCleCel" styleName="{style.champRecherche}">
<g:Label text="{constants.tagCel}" styleName="petit"/>
<g:TextBox ui:field="motCleCel" />
</g:HTMLPanel>
<g:HTMLPanel ui:field="conteneurMotCleDel" styleName="{style.champRecherche}">
<g:Label text="{constants.tagDel}" styleName="petit"/>
<g:TextBox ui:field="motCleDel" />
</g:HTMLPanel>
</g:HTMLPanel>
</g:HTMLPanel>
 
<g:Button styleName="{style.boutonRecherche} {style.rechercherAvance}" ui:field="boutonRechercheAvancee" text="{constants.rechercher}"></g:Button>
<g:HTMLPanel styleName="nettoyage" />
 
<g:CheckBox ui:field="casePnInscritsSeulement" styleName="{style.casePnInscritsSeulement}"></g:CheckBox>
<g:Label text="{constants.pnInscritsSeulement}" ui:field="labelPnInscritsSeulement" styleName="{style.labelPnInscritsSeulement}" />
</g:HTMLPanel>
<g:HTMLPanel styleName="droite">
<g:HTMLPanel ui:field="zoneRss" styleName="{style.zoneRss}"></g:HTMLPanel>
</g:HTMLPanel>
<g:Label ui:field="recherchePrecedente" styleName="{style.recherchePrecedente}" />
<g:HTMLPanel ui:field="zonePagination" />
</g:HTMLPanel>
</ui:UiBinder>
/branches/v1.11-magnesium/src/org/tela_botanica/del/client/composants/moteurrecherche/MoteurRecherchePresenteur.java
New file
0,0 → 1,443
package org.tela_botanica.del.client.composants.moteurrecherche;
 
import java.util.Map;
 
import org.tela_botanica.del.client.cache.CacheClient;
import org.tela_botanica.del.client.composants.formulaires.autocompletion.AutoCompletionComboBoxPresenteur;
import org.tela_botanica.del.client.composants.formulaires.autocompletion.AutoCompletionComboBoxVue;
import org.tela_botanica.del.client.composants.presenteur.Presenteur;
import org.tela_botanica.del.client.composants.rss.RssPresenteur;
import org.tela_botanica.del.client.composants.rss.RssVue;
import org.tela_botanica.del.client.config.Config;
import org.tela_botanica.del.client.modeles.InformationsRecherche;
import org.tela_botanica.del.client.modeles.ModeRecherche;
import org.tela_botanica.del.client.services.ReferentielService;
import org.tela_botanica.del.client.services.rest.PaysService;
import org.tela_botanica.del.client.services.rest.PaysServiceConcret;
import org.tela_botanica.del.client.services.rest.async.PaysCallback;
import org.tela_botanica.del.client.utils.InfosNomPourAutocompletion;
import org.tela_botanica.del.client.utils.UtilitairesAutoCompletionService;
 
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.event.dom.client.HasKeyPressHandlers;
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.http.client.Response;
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 void ajouterVue(HasWidgets composite);
 
public HasClickHandlers getLienRechercheAvancee();
 
public void basculerAffichageZoneCache();
 
public HasClickHandlers getBoutonRechercheSimple();
 
public HasClickHandlers getBoutonFermer();
 
public HasClickHandlers getBoutonVider();
 
public HasClickHandlers getBoutonRechercheAvancee();
 
public HasKeyPressHandlers getChampSaisie();
 
public HasClickHandlers getChampSaisieCliquable();
 
public String getValeurRechercheSimple();
 
public String getLabelRecherche();
 
public String getContientMots();
 
public boolean getPnInscritsSeulement();
 
public String getDepartement();
 
public HasWidgets getCommune();
 
public HasWidgets getTaxon();
 
public String getFamille();
 
public String getGenre();
 
public String getMotCle();
 
public String getAuteur();
 
public String getDate();
public String getPays();
 
public void setValeurRechercheSimple(String valeurRecherche);
 
public void setContientMots(String mots);
 
public void setPnInscritsSeulement(boolean valeur);
 
public void setValeurDepartement(String dpt);
 
public void chargerValeursRecherchePrecedente(InformationsRecherche informationsRecherche);
 
public void focusSaisie();
 
public void nettoyer();
 
public HasKeyPressHandlers getChampsFamille();
 
public HasKeyPressHandlers getChampsGenre();
 
public HasKeyPressHandlers getChampsMotCle();
public HasKeyPressHandlers getChampsMotCleDel();
public HasKeyPressHandlers getChampsMotCleCel();
 
public HasKeyPressHandlers getChampsAuteur();
 
public HasKeyPressHandlers getChampsDate();
public HasKeyPressHandlers getChampsDepartement();
public HasKeyPressHandlers getChampsContientMots();
public HasWidgets getZoneRss();
 
public String getReferentiel();
public void setReferentielLectureSeule(boolean lectureSeule);
 
void remplirListeReferentiels(Map<String, String> listeReferentiels);
 
public String getMotCleDel();
 
public String getMotCleCel();
public void cacherChampsTagsImage();
public void cacherChampsTagsObs();
 
void remplirListePays(Map<String, String> listePays);
 
}
 
private Vue vue;
private Config config;
private ModeRecherche modeRecherche;
private RssPresenteur presenteurRss;
public enum TypeMoteur {
SIMPLE, AVANCEE
};
 
private TypeMoteur typeMoteur = TypeMoteur.SIMPLE;
 
private AutoCompletionComboBoxPresenteur completionTaxonsPresenteur = null;
private AutoCompletionComboBoxPresenteur completionCommunesPresenteur = null;
 
public MoteurRecherchePresenteur(Vue vue, ModeRecherche mode) {
initialiser(vue, mode, new Config());
}
 
public MoteurRecherchePresenteur(AutoCompletionComboBoxPresenteur presenteurAutoCompletionTaxon, AutoCompletionComboBoxPresenteur presenteurAutoCompletionCommunes, Vue vue, ModeRecherche mode, Config configuration) {
completionTaxonsPresenteur = presenteurAutoCompletionTaxon;
completionCommunesPresenteur = presenteurAutoCompletionCommunes;
initialiser(vue, mode, configuration);
}
 
private void initialiser(Vue vue, ModeRecherche mode, Config configuration) {
//TODO : fixer le flux avant de le mettre en place
//this.presenteurRss = new RssPresenteur(new RssVue(), CacheClient.getInstance().getInformationsRechercheObservation(), "S'abonner au flux rss des résultats de cette recherche");
//presenteurRss.go(vue.getZoneRss());
this.vue = vue;
setMode(mode);
this.config = configuration;
if (completionTaxonsPresenteur == null)
this.creerCompletionTaxons();
if (completionCommunesPresenteur == null)
this.creerCompletionCommunes();
gererEvenements();
vue.remplirListeReferentiels(ReferentielService.getReferentiels());
if(CacheClient.getInstance().getReferentielNonModifiable()) {
vue.setReferentielLectureSeule(true);
}
if(CacheClient.getInstance().getListePays() != null) {
vue.remplirListePays(CacheClient.getInstance().getListePays());
} else {
PaysService paysService = new PaysServiceConcret();
paysService.getPays(new PaysCallback() {
@Override
public void surRetour(Map<String, String> listePays) {
CacheClient.getInstance().setListePays(listePays);
MoteurRecherchePresenteur.this.vue.remplirListePays(listePays);
}
});
}
if(estPourRechercheImages()) {
vue.cacherChampsTagsObs();
} else {
vue.cacherChampsTagsImage();
}
}
 
public ModeRecherche getMode() {
return modeRecherche;
}
 
private void setMode(ModeRecherche mode) {
modeRecherche = mode;
}
public TypeMoteur getTypeMoteur() {
return this.typeMoteur;
}
public void setTypeMoteur(TypeMoteur typeMoteur) {
this.typeMoteur = typeMoteur;
}
 
public boolean estPourRechercheImages() {
return (modeRecherche == ModeRecherche.MODE_IMAGE);
}
 
public boolean estPourRechercheObservations() {
return (modeRecherche == ModeRecherche.MODE_OBSERVATION);
}
 
private void creerCompletionTaxons() {
String url = this.config.getServiceBaseUrl() + "nomstaxons";
completionTaxonsPresenteur = new AutoCompletionComboBoxPresenteur(new AutoCompletionComboBoxVue(), url) {
protected String effectuerPreTraitementChaineRequete(String requete) {
// si aucun référentiel selectionné, pas de requete
if(vue.getReferentiel() != null && !vue.getReferentiel().equals("")) {
requete = "?masque.nom=" + requete + "&masque.referentiel=" + vue.getReferentiel();
return requete;
} else {
return null;
}
// A décommenter lors de l'utilisation des web services eflore
// return
// RetourAutoCompletionService.effectuerPreTraitementChaineRequeteGenreEspeceEflore(requete);
}
 
@Override
protected InfosNomPourAutocompletion[] parserResultatRequete(Response response) {
return UtilitairesAutoCompletionService.parserResultatRetourSimple(response);
// A décommenter lors de l'utilisation des web services eflore
// return RetourAutoCompletionService.parserRetourOss(response);
}
};
}
 
private void creerCompletionCommunes() {
String url = this.config.getServiceBaseUrl() + "communes";
completionCommunesPresenteur = new AutoCompletionComboBoxPresenteur(new AutoCompletionComboBoxVue(), url) {
protected String effectuerPreTraitementChaineRequete(String requete) {
requete = "?masque.nom=" + requete;
return requete;
}
 
@Override
protected void surSelectionSuggestion(String suggestion) {
setValeur(suggestion);
collecterInfosRecherche();
setValeur(getInformationsRechercheEnCache().getCommune());
vue.setValeurDepartement(getInformationsRechercheEnCache().getDepartement());
}
 
@Override
protected InfosNomPourAutocompletion[] parserResultatRequete(Response response) {
return UtilitairesAutoCompletionService.parserResultatRetourSimple(response);
}
};
}
 
@Override
public void go(HasWidgets composite) {
afficherRequeteEtLancerRecherche();
completionTaxonsPresenteur.go(vue.getTaxon());
completionCommunesPresenteur.go(vue.getCommune());
vue.ajouterVue(composite);
vue.focusSaisie();
}
 
@Override
protected void gererEvenements() {
vue.getLienRechercheAvancee().addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
setTypeMoteur(TypeMoteur.AVANCEE);
vue.setContientMots(vue.getValeurRechercheSimple());
vue.basculerAffichageZoneCache();
}
});
 
vue.getBoutonRechercheSimple().addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
setTypeMoteur(TypeMoteur.SIMPLE);
collecterInfosRecherche();
afficherRequeteEtLancerRecherche();
}
});
 
vue.getBoutonFermer().addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
vue.setValeurRechercheSimple(vue.getContientMots());
vue.basculerAffichageZoneCache();
}
});
 
vue.getBoutonVider().addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
nettoyerChamps();
InformationsRecherche infosRecherche = new InformationsRecherche();
if (estPourRechercheImages()) {
CacheClient.getInstance().setInformationsRechercheImage(infosRecherche);
} else if (estPourRechercheObservations()) {
CacheClient.getInstance().setInformationsRechercheObservation(infosRecherche);
}
}
});
 
vue.getBoutonRechercheAvancee().addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
setTypeMoteur(TypeMoteur.AVANCEE);
collecterInfosRecherche();
vue.basculerAffichageZoneCache();
afficherRequeteEtLancerRecherche();
}
});
 
vue.getChampSaisie().addKeyPressHandler(new KeyPressHandler() {
public void onKeyPress(KeyPressEvent event) {
if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
setTypeMoteur(TypeMoteur.SIMPLE);
collecterInfosRecherche();
afficherRequeteEtLancerRecherche();
}
}
});
 
vue.getChampSaisieCliquable().addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (vue.getValeurRechercheSimple().equals(vue.getLabelRecherche())) {
vue.setValeurRechercheSimple("");
}
}
});
 
vue.getChampsAuteur().addKeyPressHandler(creerGestionnaireEvenementToucheEntree());
vue.getChampsDate().addKeyPressHandler(creerGestionnaireEvenementToucheEntree());
vue.getChampsFamille().addKeyPressHandler(creerGestionnaireEvenementToucheEntree());
vue.getChampsGenre().addKeyPressHandler(creerGestionnaireEvenementToucheEntree());
vue.getChampsMotCle().addKeyPressHandler(creerGestionnaireEvenementToucheEntree());
vue.getChampsMotCleCel().addKeyPressHandler(creerGestionnaireEvenementToucheEntree());
vue.getChampsMotCleDel().addKeyPressHandler(creerGestionnaireEvenementToucheEntree());
vue.getChampsDepartement().addKeyPressHandler(creerGestionnaireEvenementToucheEntree());
vue.getChampsContientMots().addKeyPressHandler(creerGestionnaireEvenementToucheEntree());
 
}
 
public KeyPressHandler creerGestionnaireEvenementToucheEntree() {
return new KeyPressHandler() {
public void onKeyPress(KeyPressEvent event) {
if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
vue.basculerAffichageZoneCache();
collecterInfosRecherche();
afficherRequeteEtLancerRecherche();
}
}
};
}
 
private void nettoyerChamps() {
completionCommunesPresenteur.nettoyer();
completionTaxonsPresenteur.nettoyer();
vue.nettoyer();
}
 
public void collecterInfosRecherche() {
InformationsRecherche informationRecherche = new InformationsRecherche();
informationRecherche.setRechercheLibre(this.getRechercheLibre());
if (this.typeMoteur == TypeMoteur.AVANCEE) {
informationRecherche.setTaxon(completionTaxonsPresenteur.getValeur());
informationRecherche.setDepartement(vue.getDepartement());
informationRecherche.setCommune(completionCommunesPresenteur.getValeur());
informationRecherche.setFamille(vue.getFamille());
informationRecherche.setGenre(vue.getGenre());
if(estPourRechercheObservations()) {
informationRecherche.setMotClef(vue.getMotCle());
} else {
informationRecherche.setMotClefDel(vue.getMotCleDel());
informationRecherche.setMotClefCel(vue.getMotCleCel());
}
informationRecherche.setTag(vue.getMotCle());
informationRecherche.setAuteur(vue.getAuteur());
informationRecherche.setDate(vue.getDate());
informationRecherche.setReferentiel(vue.getReferentiel());
informationRecherche.setPays(vue.getPays());
informationRecherche.setPnInscritsSeulement(vue.getPnInscritsSeulement());
}
if(CacheClient.getInstance().getReferentielNonModifiable()) {
informationRecherche.setReferentiel(CacheClient.getInstance().getReferentielCourant());
}
 
if (estPourRechercheImages()) {
CacheClient.getInstance().setPageCouranteRechercheImages(1);
CacheClient.getInstance().setInformationsRechercheImage(informationRecherche);
} else if (estPourRechercheObservations()) {
CacheClient.getInstance().setPageCouranteRechercheObservations(1);
CacheClient.getInstance().setInformationsRechercheObservation(informationRecherche);
}
}
 
private String getRechercheLibre() {
String rechercheLibre = "";
switch (this.typeMoteur) {
case SIMPLE:
rechercheLibre = vue.getValeurRechercheSimple();
break;
case AVANCEE:
rechercheLibre = vue.getContientMots();
break;
default:
// TODO : voir comment gérer les exceptions proprement
// throw new
// Exception("Le type de moteur de recherche indiqué n'est pas disponible");
}
return rechercheLibre;
}
 
private InformationsRecherche getInformationsRechercheEnCache() {
if (estPourRechercheImages()) {
return CacheClient.getInstance().getInformationsRechercheImage();
} else if (estPourRechercheObservations()) {
return CacheClient.getInstance().getInformationsRechercheObservation();
}
return null;
}
 
public void afficherRequeteEtLancerRecherche() {
InformationsRecherche informationsRecherche = getInformationsRechercheEnCache();
if (informationsRecherche != null) {
completionTaxonsPresenteur.setValeur(informationsRecherche.getTaxon());
completionCommunesPresenteur.setValeur(informationsRecherche.getCommune());
vue.chargerValeursRecherchePrecedente(informationsRecherche);
}
lancerRecherche();
//presenteurRss.genererLien(informationsRecherche);
}
 
public abstract void lancerRecherche();
}
/branches/v1.11-magnesium/src/org/tela_botanica/del/client/composants/moteurrecherche/MoteurRechercheVue.java
New file
0,0 → 1,383
package org.tela_botanica.del.client.composants.moteurrecherche;
 
import java.util.Iterator;
import java.util.Map;
 
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;
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.DOM;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;
 
public class MoteurRechercheVue extends Composite implements MoteurRecherchePresenteur.Vue {
 
interface Binder extends UiBinder<Widget, MoteurRechercheVue> {
}
 
private static Binder uiBinder = GWT.create(Binder.class);
private String labelRecherche = "";
private Map<String,String> listePays;
private InformationsRecherche informationRecherche;
// Si l'on charge une recherche précédente et que la liste des pays n'est
// pas encore arrivée, on stocke le pays pour l'afficher quand la liste arrive
private String paysEnAttente;
 
@UiField
Panel rechercheAvancee, taxon, commune, zoneRss, conteneurMotCle, conteneurMotCleCel, conteneurMotCleDel ;
@UiField
Label lienRechercheAvancee, recherchePrecedente, labelPnInscritsSeulement;
@UiField
Button boutonRecherche, boutonRechercheAvancee, boutonFermer, boutonVider;
@UiField
TextBox recherchePrincipale, contientMots, departement, famille, genre, motCle, motCleCel, motCleDel, auteur, date;
@UiField
ListBox referentiel, pays;
@UiField
CheckBox casePnInscritsSeulement;
 
public MoteurRechercheVue(String labelRecherche) {
initWidget(uiBinder.createAndBindUi(this));
this.labelRecherche = labelRecherche;
recherchePrincipale.setText(labelRecherche);
rechercheAvancee.setVisible(false);
}
@Override
public void remplirListeReferentiels(Map<String, String> listeReferentiels) {
for (Iterator<String> iterator = listeReferentiels.keySet().iterator(); iterator.hasNext();) {
String codeRef = iterator.next();
referentiel.addItem(listeReferentiels.get(codeRef), codeRef);
}
referentiel.setItemSelected(1, true);
}
@Override
public void remplirListePays(Map<String, String> listePays) {
this.listePays = listePays;
pays.clear();
// Pour pouvoir annuler la selection de pays, on ajoute un item vide
pays.addItem("", "");
int index = 1;
for (Iterator<String> iterator = listePays.keySet().iterator(); iterator.hasNext();) {
String codePays = iterator.next();
pays.addItem(listePays.get(codePays), codePays);
if(paysEnAttente != null && codePays.equals(paysEnAttente)) {
pays.setItemSelected(index, true);
}
index++;
}
if(paysEnAttente != null) {
afficherLigneInfoRecherche(informationRecherche);
}
paysEnAttente = null;
}
 
public String getLabelRecherche() {
return labelRecherche;
}
 
public HasClickHandlers getLienRechercheAvancee() {
return lienRechercheAvancee;
}
 
public HasClickHandlers getBoutonRechercheSimple() {
return boutonRecherche;
}
 
public HasClickHandlers getBoutonFermer() {
return boutonFermer;
}
 
public HasClickHandlers getBoutonVider() {
return boutonVider;
}
 
public HasClickHandlers getBoutonRechercheAvancee() {
return boutonRechercheAvancee;
}
 
public HasKeyPressHandlers getChampSaisie() {
return recherchePrincipale;
}
 
public String getValeurRechercheSimple() {
return recherchePrincipale.getText();
}
 
public void setValeurRechercheSimple(String valeurRecherche) {
recherchePrincipale.setText(valeurRecherche);
}
 
public HasClickHandlers getChampSaisieCliquable() {
return recherchePrincipale;
}
 
public String getContientMots() {
return contientMots.getText();
}
 
public void setContientMots(String mots) {
contientMots.setText(mots);
}
 
public boolean getPnInscritsSeulement() {
return casePnInscritsSeulement.getValue();
}
 
public void setPnInscritsSeulement(boolean valeur) {
casePnInscritsSeulement.setValue(valeur);
}
public String getPays() {
return pays.getValue(pays.getSelectedIndex());
}
 
public String getDepartement() {
return departement.getText();
}
 
public void setValeurDepartement(String dpt) {
departement.setValue(dpt);
}
 
public HasWidgets getCommune() {
return commune;
}
 
public HasWidgets getTaxon() {
return taxon;
}
 
public String getFamille() {
return famille.getText();
}
 
public String getGenre() {
return genre.getText();
}
 
public String getMotCle() {
return motCle.getText();
}
 
public String getAuteur() {
return auteur.getText();
}
 
public String getDate() {
return date.getText();
}
public String getReferentiel() {
return referentiel.getValue(referentiel.getSelectedIndex());
}
 
public void focusSaisie() {
this.recherchePrincipale.setFocus(true);
}
 
public void ajouterVue(HasWidgets composite) {
composite.add(this.asWidget());
}
 
public void basculerAffichageZoneCache() {
rechercheAvancee.setVisible(!rechercheAvancee.isVisible());
recherchePrincipale.setVisible(!recherchePrincipale.isVisible());
boutonRecherche.setVisible(!boutonRecherche.isVisible());
}
 
public void nettoyer() {
pays.setSelectedIndex(0);
chargerValeursRecherchePrecedente(new InformationsRecherche());
}
 
public void chargerValeursRecherchePrecedente(InformationsRecherche informationsRecherche) {
recherchePrincipale.setText(informationsRecherche.getRechercheLibre());
contientMots.setText(informationsRecherche.getRechercheLibre());
departement.setText(informationsRecherche.getDepartement());
famille.setText(informationsRecherche.getFamille());
genre.setText(informationsRecherche.getGenre());
motCle.setText(informationsRecherche.getMotClef());
motCleCel.setText(informationsRecherche.getMotClefCel());
motCleDel.setText(informationsRecherche.getMotClefDel());
auteur.setText(informationsRecherche.getAuteur());
date.setText(informationsRecherche.getDate());
casePnInscritsSeulement.setValue(informationsRecherche.getPnInscritsSeulement());
for(int i = 0; i < referentiel.getItemCount(); i++) {
if(referentiel.getValue(i).equals(informationsRecherche.getReferentiel())) {
referentiel.setSelectedIndex(i);
}
}
// la liste des pays du champs de recherche est asynchrone
// donc elle peut ne pas avoir encore été chargée
if(listePays != null) {
for(int i = 0; i < pays.getItemCount(); i++) {
if(pays.getValue(i).equals(paysEnAttente)) {
pays.setSelectedIndex(i);
}
}
} else {
paysEnAttente = informationsRecherche.getPays();
}
 
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) {
this.informationRecherche = informationRecherche;
// tax dep com fam gen ta mo au date
StringBuffer texteRecherchePrecedente = new StringBuffer();
 
if (informationRecherche.getRechercheLibre() != null && !informationRecherche.getRechercheLibre().equals("")) {
texteRecherchePrecedente.append(I18n.getVocabulary().rechercheLibre() + ":" + informationRecherche.getRechercheLibre() + " ");
}
if (informationRecherche.getTaxon() != null && !informationRecherche.getTaxon().equals("")) {
texteRecherchePrecedente.append(I18n.getVocabulary().taxon() + ":" + informationRecherche.getTaxon() + " ");
}
if (informationRecherche.getDepartement() != null && !informationRecherche.getDepartement().equals("")) {
texteRecherchePrecedente.append(I18n.getVocabulary().departement() + ":" + informationRecherche.getDepartement() + " ");
}
if (listePays != null && informationRecherche.getPays() != null && !informationRecherche.getPays().equals("")) {
texteRecherchePrecedente.append(I18n.getVocabulary().pays() + ":" + listePays.get(informationRecherche.getPays()) + " ");
}
if (informationRecherche.getCommune() != null && !informationRecherche.getCommune().equals("")) {
texteRecherchePrecedente.append(I18n.getVocabulary().commune() + ":" + informationRecherche.getCommune() + " ");
}
if (informationRecherche.getFamille() != null && !informationRecherche.getFamille().equals("")) {
texteRecherchePrecedente.append(I18n.getVocabulary().famille() + ":" + informationRecherche.getFamille() + " ");
}
if (informationRecherche.getGenre() != null && !informationRecherche.getGenre().equals("")) {
texteRecherchePrecedente.append(I18n.getVocabulary().genre() + ":" + informationRecherche.getGenre() + " ");
}
if (informationRecherche.getTag() != null && !informationRecherche.getTag().equals("")) {
texteRecherchePrecedente.append(I18n.getVocabulary().tag() + ":" + informationRecherche.getTag() + " ");
}
if (informationRecherche.getMotClef() != null && !informationRecherche.getMotClef().equals("")) {
texteRecherchePrecedente.append(I18n.getVocabulary().mot_clef() + ":" + informationRecherche.getMotClef() + " ");
}
if (informationRecherche.getMotClefCel() != null && !informationRecherche.getMotClefCel().equals("")) {
texteRecherchePrecedente.append(I18n.getVocabulary().tagCel() + ":" + informationRecherche.getMotClefCel() + " ");
}
if (informationRecherche.getMotClefDel() != null && !informationRecherche.getMotClefDel().equals("")) {
texteRecherchePrecedente.append(I18n.getVocabulary().tagDel() + ":" + informationRecherche.getMotClefDel() + " ");
}
if (informationRecherche.getAuteur() != null && !informationRecherche.getAuteur().equals("")) {
texteRecherchePrecedente.append(I18n.getVocabulary().auteur() + ":" + informationRecherche.getAuteur() + " ");
}
if (informationRecherche.getDate() != null && !informationRecherche.getDate().equals("")) {
texteRecherchePrecedente.append(I18n.getVocabulary().date() + ":" + informationRecherche.getDate() + " ");
}
if (informationRecherche.getReferentiel() != null && !informationRecherche.getReferentiel().equals("")) {
texteRecherchePrecedente.append(I18n.getVocabulary().referentiel() + ":" + informationRecherche.getReferentiel() + " ");
}
if (informationRecherche.getPnInscritsSeulement()) {
texteRecherchePrecedente.append(I18n.getVocabulary().pnISCourt() + ":non");
}
recherchePrecedente.setText(texteRecherchePrecedente.toString());
}
 
@Override
public HasKeyPressHandlers getChampsFamille() {
return famille;
}
 
@Override
public HasKeyPressHandlers getChampsGenre() {
return genre;
}
 
@Override
public HasKeyPressHandlers getChampsMotCle() {
return motCle;
}
 
@Override
public HasKeyPressHandlers getChampsAuteur() {
return auteur;
}
 
@Override
public HasKeyPressHandlers getChampsDate() {
return date;
}
 
@Override
public HasKeyPressHandlers getChampsDepartement() {
return departement;
}
 
@Override
public HasKeyPressHandlers getChampsContientMots() {
return contientMots;
}
public HasWidgets getZoneRss() {
return zoneRss;
}
 
@Override
public void setReferentielLectureSeule(boolean lectureSeule) {
// la listbox ne possède aucun méthode directe pour être désactivée
DOM.setElementProperty(referentiel.getElement(), "disabled", "disabled");
}
 
@Override
public HasKeyPressHandlers getChampsMotCleDel() {
return motCleDel;
}
 
@Override
public HasKeyPressHandlers getChampsMotCleCel() {
return motCleCel;
}
 
@Override
public String getMotCleDel() {
return motCleDel.getText();
}
 
@Override
public String getMotCleCel() {
return motCleCel.getText();
}
 
@Override
public void cacherChampsTagsImage() {
conteneurMotCleCel.setVisible(false);
conteneurMotCleDel.setVisible(false);
}
 
@Override
public void cacherChampsTagsObs() {
conteneurMotCle.setVisible(false);
}
}