24,31 → 24,57 |
|
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 String getDepartement(); |
|
public HasWidgets getCommune(); |
|
public HasWidgets getTaxon(); |
|
public String getFamille(); |
|
public String getGenre(); |
|
public String getTag(); |
|
public String getMotCle(); |
|
public String getAuteur(); |
|
public String getDate(); |
|
public void setValeurRechercheSimple(String valeurRecherche); |
|
public void setContientMots(String mots); |
|
public void setValeurDepartement(String dpt); |
|
public void chargerValeursRecherchePrecedente(InformationsRecherche informationsRecherche); |
|
public void focusSaisie(); |
|
public void nettoyer(); |
} |
|
55,45 → 81,49 |
private Vue vue; |
private Config config; |
private ModeRecherche modeRecherche; |
public enum TypeMoteur {SIMPLE, AVANCEE}; |
|
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); |
} |
|
public MoteurRecherchePresenteur(AutoCompletionComboBoxPresenteur presenteurAutoCompletionTaxon, |
AutoCompletionComboBoxPresenteur presenteurAutoCompletionCommunes, |
Vue vue, ModeRecherche mode) { |
|
public MoteurRecherchePresenteur(AutoCompletionComboBoxPresenteur presenteurAutoCompletionTaxon, AutoCompletionComboBoxPresenteur presenteurAutoCompletionCommunes, Vue vue, ModeRecherche mode) { |
completionTaxonsPresenteur = presenteurAutoCompletionTaxon; |
completionCommunesPresenteur = presenteurAutoCompletionCommunes; |
initialiser(vue, mode); |
} |
|
|
private void initialiser(Vue vue, ModeRecherche mode) { |
this.vue = vue; |
setMode(mode); |
this.config = new Config(); |
if (completionTaxonsPresenteur == null) this.creerCompletionTaxons(); |
if (completionCommunesPresenteur == null) this.creerCompletionCommunes(); |
if (completionTaxonsPresenteur == null) |
this.creerCompletionTaxons(); |
if (completionCommunesPresenteur == null) |
this.creerCompletionCommunes(); |
gererEvenements(); |
} |
|
|
private Vue getVue() { |
return vue; |
} |
|
|
public ModeRecherche getMode() { |
return modeRecherche; |
} |
|
|
private void setMode(ModeRecherche mode) { |
modeRecherche = mode; |
} |
|
|
public void setTypeMoteur(TypeMoteur typeMoteur) { |
this.typeMoteur = typeMoteur; |
} |
104,7 → 134,7 |
|
public boolean estPourRechercheObservations() { |
return (modeRecherche == ModeRecherche.MODE_OBSERVATION); |
} |
} |
|
private void creerCompletionTaxons() { |
String url = this.config.getUrl("nomSciCompletionService"); |
124,7 → 154,7 |
} |
}; |
} |
|
|
private void creerCompletionCommunes() { |
String url = this.config.getUrl("communeCompletionService"); |
completionCommunesPresenteur = new AutoCompletionComboBoxPresenteur(new AutoCompletionComboBoxVue(), url) { |
131,9 → 161,10 |
protected String effectuerPreTraitementChaineRequete(String requete) { |
return requete; |
} |
|
|
@Override |
protected void surSelectionSuggestion(String suggestion) { |
setValeur(suggestion); |
collecterInfosRecherche(); |
setValeur(getInformationsRechercheEnCache().getCommune()); |
vue.setValeurDepartement(getInformationsRechercheEnCache().getDepartement()); |
145,7 → 176,7 |
} |
}; |
} |
|
|
@Override |
public void go(HasWidgets composite) { |
afficherRequeteEtLancerRecherche(); |
159,6 → 190,7 |
protected void gererEvenements() { |
vue.getLienRechercheAvancee().addClickHandler(new ClickHandler() { |
public void onClick(ClickEvent event) { |
setTypeMoteur(TypeMoteur.AVANCEE); |
vue.setContientMots(vue.getValeurRechercheSimple()); |
vue.basculerAffichageZoneCache(); |
} |
218,7 → 250,7 |
} |
}); |
} |
|
|
private void nettoyerChamps() { |
completionCommunesPresenteur.nettoyer(); |
completionTaxonsPresenteur.nettoyer(); |
240,6 → 272,7 |
informationRecherche.setDate(vue.getDate()); |
} |
|
|
if (estPourRechercheImages()) { |
CacheClient.getInstance().setPageCouranteRechercheImages(1); |
CacheClient.getInstance().setInformationsRechercheImage(informationRecherche); |
248,19 → 281,20 |
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 disponilbe"); |
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 disponilbe"); |
} |
return rechercheLibre; |
} |