16,6 → 16,7 |
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.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; |
35,10 → 36,11 |
public abstract HasClickHandlers getChampSaisieCliquable(); |
public abstract String getValeurRechercheSimple(); |
public void setValeurRechercheSimple(String valeurRecherche); |
public void setValeurDepartement(String dpt); |
public String getLabelRecherche(); |
public String getRecherchePrincipale(); |
public String getDepartement(); |
public String getCommune(); |
public HasWidgets getCommune(); |
public HasWidgets getTaxon(); |
public String getFamille(); |
public String getGenre(); |
52,9 → 54,10 |
} |
|
private final Vue vue; |
private boolean pourRechercheImages = false, pourRechercheObservations= false; |
private ModeRecherche modeRecherche; |
|
private AutoCompletionComboBoxPresenteur autoCompletionNomTaxonsPresenteur; |
private AutoCompletionComboBoxPresenteur autoCompletionCommunesPresenteur; |
|
public MoteurRecherchePresenteur(Vue vue, ModeRecherche mode) { |
|
74,28 → 77,48 |
// return RetourAutoCompletionService.parserRetourOss(response); |
} |
}; |
|
AutoCompletionComboBoxPresenteur completionCommunesPresenteur = new AutoCompletionComboBoxPresenteur(new AutoCompletionComboBoxVue(), UtilitairesAutoCompletionService.urlServiceCompletionCommunes) { |
|
protected String effectuerPreTraitementChaineRequete(String requete) { |
return requete; |
} |
|
@Override |
protected void surSelectionSuggestion(String suggestion) { |
String[] tableauCommuneDpt = suggestion.split(" "); |
if(tableauCommuneDpt.length == 2) { |
String dpt = tableauCommuneDpt[1].replaceAll("\\(", "").replaceAll("\\)", ""); |
getVue().setValeurDepartement(dpt); |
setValeur(tableauCommuneDpt[0]); |
} |
} |
|
@Override |
protected String[] parserResultatRequete(Response response) { |
return UtilitairesAutoCompletionService.parserRetourSimple(response); |
} |
}; |
this.vue = vue; |
|
setMode(mode); |
|
autoCompletionCommunesPresenteur = completionCommunesPresenteur; |
autoCompletionNomTaxonsPresenteur = completionNomTaxonsPresenteur; |
gererEvenements(); |
} |
|
private void setMode(ModeRecherche mode) { |
switch(mode) { |
case MODE_IMAGE: |
this.pourRechercheImages = true; |
break; |
case MODE_OBSERVATION: |
this.pourRechercheObservations = true; |
} |
modeRecherche = mode; |
} |
|
public MoteurRecherchePresenteur(AutoCompletionComboBoxPresenteur presenteurAutoCompletion, Vue vue, ModeRecherche mode) { |
public MoteurRecherchePresenteur(AutoCompletionComboBoxPresenteur presenteurAutoCompletionTaxon, |
AutoCompletionComboBoxPresenteur presenteurAutoCompletionCommunes, |
Vue vue, ModeRecherche mode) { |
this.vue = vue; |
setMode(mode); |
autoCompletionNomTaxonsPresenteur = presenteurAutoCompletion; |
autoCompletionNomTaxonsPresenteur = presenteurAutoCompletionTaxon; |
autoCompletionCommunesPresenteur = presenteurAutoCompletionCommunes; |
gererEvenements(); |
} |
|
103,6 → 126,7 |
public void go(HasWidgets composite) { |
afficherRequeteEtLancerRecherche(); |
autoCompletionNomTaxonsPresenteur.go(vue.getTaxon()); |
autoCompletionCommunesPresenteur.go(vue.getCommune()); |
vue.ajouterVue(composite); |
vue.focusSaisie(); |
} |
135,8 → 159,7 |
@Override |
public void onClick(ClickEvent event) { |
|
autoCompletionNomTaxonsPresenteur.nettoyer(); |
vue.nettoyer(); |
nettoyerChamps(); |
|
InformationsRecherche infosRecherche = new InformationsRecherche(); |
if (estPourRechercheImages()) { |
175,12 → 198,18 |
} |
}); |
} |
|
private void nettoyerChamps() { |
autoCompletionCommunesPresenteur.nettoyer(); |
autoCompletionNomTaxonsPresenteur.nettoyer(); |
vue.nettoyer(); |
} |
|
public void collecterInfosRecherche() { |
InformationsRecherche informationRecherche = new InformationsRecherche(); |
informationRecherche.setTaxon(autoCompletionNomTaxonsPresenteur.getValeur()); |
informationRecherche.setDepartement(vue.getDepartement()); |
informationRecherche.setCommune(vue.getCommune()); |
informationRecherche.setCommune(autoCompletionCommunesPresenteur.getValeur()); |
informationRecherche.setFamille(vue.getFamille()); |
informationRecherche.setGenre(vue.getGenre()); |
informationRecherche.setTag(vue.getTag()); |
217,18 → 246,18 |
public abstract void lancerRecherche(); |
|
public boolean estPourRechercheImages() { |
return pourRechercheImages; |
return (modeRecherche == ModeRecherche.MODE_IMAGE); |
} |
|
public boolean estPourRechercheObservations() { |
return pourRechercheObservations; |
return (modeRecherche == ModeRecherche.MODE_OBSERVATION); |
} |
|
private Vue getVue() { |
return vue; |
} |
|
public ModeRecherche getMode() { |
if(estPourRechercheImages()) { |
return ModeRecherche.MODE_IMAGE; |
} else { |
return ModeRecherche.MODE_OBSERVATION; |
} |
return modeRecherche; |
} |
} |