Subversion Repositories eFlore/Applications.del

Compare Revisions

Ignore whitespace Rev 532 → Rev 533

/trunk/src/org/tela_botanica/del/client/composants/moteurrecherche/MoteurRechercheVue.ui.xml
17,6 → 17,11
<g:Button ui:field="boutonVider" styleName="{style.boutonVider}" text="Vider"></g:Button>
 
<g:HTMLPanel styleName="{style.champRecherche}">
<g:Label text="{constants.contientMots}" />
<g:TextBox ui:field="contientMots" />
</g:HTMLPanel>
 
<g:HTMLPanel styleName="{style.champRecherche}">
<g:Label text="{constants.taxon}" />
<g:HTMLPanel ui:field="taxon" />
</g:HTMLPanel>
/trunk/src/org/tela_botanica/del/client/composants/moteurrecherche/MoteurRecherchePresenteur.java
33,10 → 33,8
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 getRecherchePrincipale();
public String getContientMots();
public String getDepartement();
public HasWidgets getCommune();
public HasWidgets getTaxon();
46,6 → 44,9
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();
53,6 → 54,8
 
private final Vue vue;
private ModeRecherche modeRecherche;
public enum TypeMoteur {SIMPLE, AVANCEE};
private TypeMoteur typeMoteur = TypeMoteur.SIMPLE;
 
private AutoCompletionComboBoxPresenteur autoCompletionNomTaxonsPresenteur;
private AutoCompletionComboBoxPresenteur autoCompletionCommunesPresenteur;
98,7 → 101,6
}
};
this.vue = vue;
setMode(mode);
 
autoCompletionCommunesPresenteur = completionCommunesPresenteur;
106,10 → 108,6
gererEvenements();
}
private void setMode(ModeRecherche mode) {
modeRecherche = mode;
}
public MoteurRecherchePresenteur(AutoCompletionComboBoxPresenteur presenteurAutoCompletionTaxon,
AutoCompletionComboBoxPresenteur presenteurAutoCompletionCommunes,
Vue vue, ModeRecherche mode) {
119,7 → 117,31
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();
133,6 → 155,7
protected void gererEvenements() {
vue.getLienRechercheAvancee().addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
vue.setContientMots(vue.getValeurRechercheSimple());
vue.basculerAffichageZoneCache();
}
});
139,6 → 162,7
 
vue.getBoutonRechercheSimple().addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
setTypeMoteur(TypeMoteur.SIMPLE);
collecterInfosRecherche();
afficherRequeteEtLancerRecherche();
}
145,20 → 169,15
});
 
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);
170,6 → 189,7
 
vue.getBoutonRechercheAvancee().addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
setTypeMoteur(TypeMoteur.AVANCEE);
collecterInfosRecherche();
vue.basculerAffichageZoneCache();
afficherRequeteEtLancerRecherche();
177,9 → 197,9
});
 
vue.getChampSaisie().addKeyPressHandler(new KeyPressHandler() {
 
public void onKeyPress(KeyPressEvent event) {
if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
setTypeMoteur(TypeMoteur.SIMPLE);
collecterInfosRecherche();
afficherRequeteEtLancerRecherche();
}
187,8 → 207,6
});
 
vue.getChampSaisieCliquable().addClickHandler(new ClickHandler() {
 
@Override
public void onClick(ClickEvent event) {
if (vue.getValeurRechercheSimple().equals(vue.getLabelRecherche())) {
vue.setValeurRechercheSimple("");
214,7 → 232,7
informationRecherche.setMotClef(vue.getMotCle());
informationRecherche.setAuteur(vue.getAuteur());
informationRecherche.setDate(vue.getDate());
informationRecherche.setRechercheLibre(vue.getRecherchePrincipale());
informationRecherche.setRechercheLibre(this.getRechercheLibre());
 
if (estPourRechercheImages()) {
CacheClient.getInstance().setPageCouranteRechercheImages(1);
224,6 → 242,22
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()) {
244,20 → 278,4
}
 
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;
}
}
/trunk/src/org/tela_botanica/del/client/composants/moteurrecherche/MoteurRechercheVue.java
32,7 → 32,7
@UiField
Button boutonRecherche, boutonRechercheAvancee, boutonFermer, boutonVider;
@UiField
TextBox recherchePrincipale, departement, famille, genre, tag, motCle, auteur, date;
TextBox recherchePrincipale, contientMots, departement, famille, genre, tag, motCle, auteur, date;
 
public MoteurRechercheVue(String labelRecherche) {
initWidget(uiBinder.createAndBindUi(this));
45,12 → 45,10
return labelRecherche;
}
 
@Override
public HasClickHandlers getLienRechercheAvancee() {
return lienRechercheAvancee;
}
 
@Override
public void basculerAffichageZoneCache() {
rechercheAvancee.setVisible(!rechercheAvancee.isVisible());
recherchePrincipale.setVisible(!recherchePrincipale.isVisible());
57,53 → 55,54
boutonRecherche.setVisible(!boutonRecherche.isVisible());
}
 
@Override
public HasClickHandlers getBoutonRechercheSimple() {
return boutonRecherche;
}
 
@Override
public HasClickHandlers getBoutonFermer() {
return boutonFermer;
}
 
@Override
public HasClickHandlers getBoutonVider() {
return boutonVider;
}
 
@Override
public HasClickHandlers getBoutonRechercheAvancee() {
return boutonRechercheAvancee;
}
 
@Override
public HasKeyPressHandlers getChampSaisie() {
return recherchePrincipale;
}
 
@Override
public String getValeurRechercheSimple() {
return recherchePrincipale.getText();
}
public String getContientMots() {
return contientMots.getText();
}
 
@Override
public HasClickHandlers getChampSaisieCliquable() {
return recherchePrincipale;
}
 
@Override
public void setValeurRechercheSimple(String valeurRecherche) {
recherchePrincipale.setText(valeurRecherche);
}
@Override
public void setContientMots(String mots) {
contientMots.setText(mots);
}
public void setValeurDepartement(String dpt) {
departement.setValue(dpt);
}
 
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());
164,10 → 163,6
chargerValeursRecherchePrecedente(new InformationsRecherche());
}
 
public String getRecherchePrincipale() {
return recherchePrincipale.getText();
}
 
public String getDepartement() {
return departement.getText();
}
/trunk/src/org/tela_botanica/del/test/composants/moteurrecherche/MoteurRecherchePresenteurTest.java
134,7 → 134,7
@Test
public void testLancerRechercheLibreObs() {
presenteurRechercheObservation.go(container);
Mockito.when(vueRechercheObservation.getRecherchePrincipale()).thenReturn("Essai");
Mockito.when(vueRechercheObservation.getValeurRechercheSimple()).thenReturn("Essai");
presenteurRechercheObservation.collecterInfosRecherche();
presenteurRechercheObservation.afficherRequeteEtLancerRecherche();
244,7 → 244,7
@Test
public void testLancerRechercheLibreImage() {
presenteurRechercheImage.go(container);
Mockito.when(vueRechercheImage.getRecherchePrincipale()).thenReturn("Essai");
Mockito.when(vueRechercheImage.getValeurRechercheSimple()).thenReturn("Essai");
presenteurRechercheImage.collecterInfosRecherche();
presenteurRechercheImage.afficherRequeteEtLancerRecherche();