New file |
0,0 → 1,316 |
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.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 = ""; |
|
@UiField |
Panel rechercheAvancee, taxon, commune, zoneRss, conteneurMotCle, conteneurMotCleCel, conteneurMotCleDel ; |
@UiField |
Label lienRechercheAvancee, recherchePrecedente; |
@UiField |
Button boutonRecherche, boutonRechercheAvancee, boutonFermer, boutonVider; |
@UiField |
TextBox recherchePrincipale, contientMots, departement, famille, genre, motCle, motCleCel, motCleDel, auteur, date; |
@UiField |
ListBox referentiel; |
|
private boolean referentielLectureSeule = false; |
|
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); |
} |
} |
|
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 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() { |
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()); |
|
for(int i = 0; i < referentiel.getItemCount(); i++) { |
if(referentiel.getValue(i).equals(informationsRecherche.getReferentiel())) { |
referentiel.setSelectedIndex(i); |
} |
} |
|
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) { |
// 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 (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() + " "); |
} |
|
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) { |
referentielLectureSeule = true; |
// 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); |
} |
} |