33,8 → 33,10 |
public abstract HasKeyPressHandlers getChampSaisie(); |
public abstract HasClickHandlers getChampSaisieCliquable(); |
public abstract String getValeurRechercheSimple(); |
public void setValeurRechercheSimple(String valeurRecherche); |
public void setValeurDepartement(String dpt); |
public String getLabelRecherche(); |
public String getContientMots(); |
public String getRecherchePrincipale(); |
public String getDepartement(); |
public HasWidgets getCommune(); |
public HasWidgets getTaxon(); |
44,9 → 46,6 |
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(); |
54,8 → 53,6 |
|
private final Vue vue; |
private ModeRecherche modeRecherche; |
public enum TypeMoteur {SIMPLE, AVANCEE}; |
private TypeMoteur typeMoteur = TypeMoteur.SIMPLE; |
|
private AutoCompletionComboBoxPresenteur autoCompletionNomTaxonsPresenteur; |
private AutoCompletionComboBoxPresenteur autoCompletionCommunesPresenteur; |
101,6 → 98,7 |
} |
}; |
this.vue = vue; |
|
setMode(mode); |
|
autoCompletionCommunesPresenteur = completionCommunesPresenteur; |
108,6 → 106,10 |
gererEvenements(); |
} |
|
private void setMode(ModeRecherche mode) { |
modeRecherche = mode; |
} |
|
public MoteurRecherchePresenteur(AutoCompletionComboBoxPresenteur presenteurAutoCompletionTaxon, |
AutoCompletionComboBoxPresenteur presenteurAutoCompletionCommunes, |
Vue vue, ModeRecherche mode) { |
117,31 → 119,7 |
autoCompletionCommunesPresenteur = presenteurAutoCompletionCommunes; |
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; |
} |
|
public boolean estPourRechercheImages() { |
return (modeRecherche == ModeRecherche.MODE_IMAGE); |
} |
|
public boolean estPourRechercheObservations() { |
return (modeRecherche == ModeRecherche.MODE_OBSERVATION); |
} |
|
@Override |
public void go(HasWidgets composite) { |
afficherRequeteEtLancerRecherche(); |
155,7 → 133,6 |
protected void gererEvenements() { |
vue.getLienRechercheAvancee().addClickHandler(new ClickHandler() { |
public void onClick(ClickEvent event) { |
vue.setContientMots(vue.getValeurRechercheSimple()); |
vue.basculerAffichageZoneCache(); |
} |
}); |
162,7 → 139,6 |
|
vue.getBoutonRechercheSimple().addClickHandler(new ClickHandler() { |
public void onClick(ClickEvent event) { |
setTypeMoteur(TypeMoteur.SIMPLE); |
collecterInfosRecherche(); |
afficherRequeteEtLancerRecherche(); |
} |
169,15 → 145,20 |
}); |
|
vue.getBoutonFermer().addClickHandler(new ClickHandler() { |
|
@Override |
public void onClick(ClickEvent event) { |
vue.setValeurRechercheSimple(vue.getContientMots()); |
vue.basculerAffichageZoneCache(); |
} |
}); |
|
vue.getBoutonVider().addClickHandler(new ClickHandler() { |
|
@Override |
public void onClick(ClickEvent event) { |
|
nettoyerChamps(); |
|
InformationsRecherche infosRecherche = new InformationsRecherche(); |
if (estPourRechercheImages()) { |
CacheClient.getInstance().setInformationsRechercheImage(infosRecherche); |
189,7 → 170,6 |
|
vue.getBoutonRechercheAvancee().addClickHandler(new ClickHandler() { |
public void onClick(ClickEvent event) { |
setTypeMoteur(TypeMoteur.AVANCEE); |
collecterInfosRecherche(); |
vue.basculerAffichageZoneCache(); |
afficherRequeteEtLancerRecherche(); |
197,9 → 177,9 |
}); |
|
vue.getChampSaisie().addKeyPressHandler(new KeyPressHandler() { |
|
public void onKeyPress(KeyPressEvent event) { |
if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) { |
setTypeMoteur(TypeMoteur.SIMPLE); |
collecterInfosRecherche(); |
afficherRequeteEtLancerRecherche(); |
} |
207,6 → 187,8 |
}); |
|
vue.getChampSaisieCliquable().addClickHandler(new ClickHandler() { |
|
@Override |
public void onClick(ClickEvent event) { |
if (vue.getValeurRechercheSimple().equals(vue.getLabelRecherche())) { |
vue.setValeurRechercheSimple(""); |
232,7 → 214,7 |
informationRecherche.setMotClef(vue.getMotCle()); |
informationRecherche.setAuteur(vue.getAuteur()); |
informationRecherche.setDate(vue.getDate()); |
informationRecherche.setRechercheLibre(this.getRechercheLibre()); |
informationRecherche.setRechercheLibre(vue.getRecherchePrincipale()); |
|
if (estPourRechercheImages()) { |
CacheClient.getInstance().setPageCouranteRechercheImages(1); |
242,22 → 224,6 |
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"); |
} |
return rechercheLibre; |
} |
|
private InformationsRecherche getInformationsRechercheEnCache() { |
if (estPourRechercheImages()) { |
278,4 → 244,20 |
} |
|
public abstract void lancerRecherche(); |
|
public boolean estPourRechercheImages() { |
return (modeRecherche == ModeRecherche.MODE_IMAGE); |
} |
|
public boolean estPourRechercheObservations() { |
return (modeRecherche == ModeRecherche.MODE_OBSERVATION); |
} |
|
private Vue getVue() { |
return vue; |
} |
|
public ModeRecherche getMode() { |
return modeRecherche; |
} |
} |