Subversion Repositories eFlore/Applications.del

Rev

Rev 457 | Rev 545 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
322 gduche 1
package org.tela_botanica.del.client.composants.moteurrecherche;
2
 
335 benjamin 3
import org.tela_botanica.del.client.i18n.I18n;
4
import org.tela_botanica.del.client.modeles.InformationsRecherche;
322 gduche 5
 
6
import com.google.gwt.core.client.GWT;
7
import com.google.gwt.event.dom.client.HasClickHandlers;
8
import com.google.gwt.event.dom.client.HasKeyPressHandlers;
9
import com.google.gwt.uibinder.client.UiBinder;
10
import com.google.gwt.uibinder.client.UiField;
11
import com.google.gwt.user.client.ui.Button;
12
import com.google.gwt.user.client.ui.Composite;
335 benjamin 13
import com.google.gwt.user.client.ui.HasText;
386 aurelien 14
import com.google.gwt.user.client.ui.HasWidgets;
322 gduche 15
import com.google.gwt.user.client.ui.Label;
16
import com.google.gwt.user.client.ui.Panel;
17
import com.google.gwt.user.client.ui.TextBox;
18
import com.google.gwt.user.client.ui.Widget;
19
 
20
public class MoteurRechercheVue extends Composite implements MoteurRecherchePresenteur.Vue {
21
 
335 benjamin 22
	interface Binder extends UiBinder<Widget, MoteurRechercheVue> {
23
	}
24
 
322 gduche 25
	private static Binder uiBinder = GWT.create(Binder.class);
26
	private String labelRecherche = "";
335 benjamin 27
 
28
	@UiField
457 aurelien 29
	Panel rechercheAvancee, taxon, commune;
335 benjamin 30
	@UiField
31
	Label lienRechercheAvancee, recherchePrecedente;
32
	@UiField
419 gduche 33
	Button boutonRecherche, boutonRechercheAvancee, boutonFermer, boutonVider;
335 benjamin 34
	@UiField
533 jpm 35
	TextBox recherchePrincipale, contientMots, departement, famille, genre, tag, motCle, auteur, date;
335 benjamin 36
 
322 gduche 37
	public MoteurRechercheVue(String labelRecherche) {
38
		initWidget(uiBinder.createAndBindUi(this));
39
		this.labelRecherche = labelRecherche;
40
		recherchePrincipale.setText(labelRecherche);
41
		rechercheAvancee.setVisible(false);
42
	}
43
 
44
	public String getLabelRecherche() {
45
		return labelRecherche;
46
	}
335 benjamin 47
 
322 gduche 48
	public HasClickHandlers getLienRechercheAvancee() {
49
		return lienRechercheAvancee;
50
	}
51
 
52
	public void basculerAffichageZoneCache() {
53
		rechercheAvancee.setVisible(!rechercheAvancee.isVisible());
419 gduche 54
		recherchePrincipale.setVisible(!recherchePrincipale.isVisible());
55
		boutonRecherche.setVisible(!boutonRecherche.isVisible());
322 gduche 56
	}
57
 
58
	public HasClickHandlers getBoutonRechercheSimple() {
59
		return boutonRecherche;
60
	}
445 benjamin 61
 
408 gduche 62
	public HasClickHandlers getBoutonFermer() {
63
		return boutonFermer;
64
	}
445 benjamin 65
 
419 gduche 66
	public HasClickHandlers getBoutonVider() {
67
		return boutonVider;
68
	}
335 benjamin 69
 
322 gduche 70
	public HasClickHandlers getBoutonRechercheAvancee() {
71
		return boutonRechercheAvancee;
72
	}
73
 
74
	public HasKeyPressHandlers getChampSaisie() {
75
		return recherchePrincipale;
76
	}
77
 
78
	public String getValeurRechercheSimple() {
79
		return recherchePrincipale.getText();
80
	}
533 jpm 81
 
82
	public String getContientMots() {
83
		return contientMots.getText();
84
	}
322 gduche 85
 
86
	public HasClickHandlers getChampSaisieCliquable() {
87
		return recherchePrincipale;
88
	}
335 benjamin 89
 
322 gduche 90
	public void setValeurRechercheSimple(String valeurRecherche) {
91
		recherchePrincipale.setText(valeurRecherche);
92
	}
457 aurelien 93
 
533 jpm 94
	public void setContientMots(String mots) {
95
		contientMots.setText(mots);
96
	}
97
 
457 aurelien 98
	public void setValeurDepartement(String dpt) {
99
		departement.setValue(dpt);
100
	}
533 jpm 101
 
322 gduche 102
 
335 benjamin 103
	public void chargerValeursRecherchePrecedente(InformationsRecherche informationsRecherche) {
451 aurelien 104
		recherchePrincipale.setText(informationsRecherche.getRechercheLibre());
533 jpm 105
		contientMots.setText(informationsRecherche.getRechercheLibre());
451 aurelien 106
		departement.setText(informationsRecherche.getDepartement());
107
		famille.setText(informationsRecherche.getFamille());
108
		genre.setText(informationsRecherche.getGenre());
109
		tag.setText(informationsRecherche.getTag());
110
		motCle.setText(informationsRecherche.getMotClef());
111
		auteur.setText(informationsRecherche.getAuteur());
112
		date.setText(informationsRecherche.getDate());
445 benjamin 113
 
335 benjamin 114
		afficherLigneInfoRecherche(informationsRecherche);
115
	}
116
 
117
	/**
118
	 * Affiche la ligne d'en tête montrant les elements de la requête à
119
	 * l'utilisateur
120
	 *
121
	 * @param informationRecherche
122
	 */
123
	private void afficherLigneInfoRecherche(InformationsRecherche informationRecherche) {
124
 
445 benjamin 125
		// tax dep com fam gen ta mo au date
335 benjamin 126
		StringBuffer texteRecherchePrecedente = new StringBuffer();
445 benjamin 127
 
128
		if (informationRecherche.getRechercheLibre() != null && !informationRecherche.getRechercheLibre().equals("")) {
335 benjamin 129
			texteRecherchePrecedente.append(I18n.getVocabulary().rechercheLibre() + ":" + informationRecherche.getRechercheLibre() + " ");
322 gduche 130
		}
445 benjamin 131
		if (informationRecherche.getTaxon() != null && !informationRecherche.getTaxon().equals("")) {
419 gduche 132
			texteRecherchePrecedente.append(I18n.getVocabulary().taxon() + ":" + informationRecherche.getTaxon() + " ");
322 gduche 133
		}
445 benjamin 134
		if (informationRecherche.getDepartement() != null && !informationRecherche.getDepartement().equals("")) {
419 gduche 135
			texteRecherchePrecedente.append(I18n.getVocabulary().departement() + ":" + informationRecherche.getDepartement() + " ");
136
		}
445 benjamin 137
		if (informationRecherche.getCommune() != null && !informationRecherche.getCommune().equals("")) {
335 benjamin 138
			texteRecherchePrecedente.append(I18n.getVocabulary().commune() + ":" + informationRecherche.getCommune() + " ");
322 gduche 139
		}
445 benjamin 140
		if (informationRecherche.getFamille() != null && !informationRecherche.getFamille().equals("")) {
335 benjamin 141
			texteRecherchePrecedente.append(I18n.getVocabulary().famille() + ":" + informationRecherche.getFamille() + " ");
322 gduche 142
		}
445 benjamin 143
		if (informationRecherche.getGenre() != null && !informationRecherche.getGenre().equals("")) {
335 benjamin 144
			texteRecherchePrecedente.append(I18n.getVocabulary().genre() + ":" + informationRecherche.getGenre() + " ");
322 gduche 145
		}
445 benjamin 146
		if (informationRecherche.getTag() != null && !informationRecherche.getTag().equals("")) {
419 gduche 147
			texteRecherchePrecedente.append(I18n.getVocabulary().tag() + ":" + informationRecherche.getTag() + " ");
148
		}
445 benjamin 149
		if (informationRecherche.getMotClef() != null && !informationRecherche.getMotClef().equals("")) {
335 benjamin 150
			texteRecherchePrecedente.append(I18n.getVocabulary().mot_clef() + ":" + informationRecherche.getMotClef() + " ");
322 gduche 151
		}
445 benjamin 152
		if (informationRecherche.getAuteur() != null && !informationRecherche.getAuteur().equals("")) {
419 gduche 153
			texteRecherchePrecedente.append(I18n.getVocabulary().auteur() + ":" + informationRecherche.getAuteur() + " ");
154
		}
445 benjamin 155
		if (informationRecherche.getDate() != null && !informationRecherche.getDate().equals("")) {
419 gduche 156
			texteRecherchePrecedente.append(I18n.getVocabulary().date() + ":" + informationRecherche.getDate() + " ");
157
		}
445 benjamin 158
 
335 benjamin 159
		recherchePrecedente.setText(texteRecherchePrecedente.toString());
322 gduche 160
	}
335 benjamin 161
 
419 gduche 162
	public void nettoyer() {
163
		chargerValeursRecherchePrecedente(new InformationsRecherche());
164
	}
445 benjamin 165
 
451 aurelien 166
	public String getDepartement() {
167
		return departement.getText();
322 gduche 168
	}
335 benjamin 169
 
457 aurelien 170
	public HasWidgets getCommune() {
171
		return commune;
335 benjamin 172
	}
173
 
386 aurelien 174
	public HasWidgets getTaxon() {
335 benjamin 175
		return taxon;
176
	}
177
 
451 aurelien 178
	public String getFamille() {
179
		return famille.getText();
335 benjamin 180
	}
181
 
451 aurelien 182
	public String getGenre() {
183
		return genre.getText();
335 benjamin 184
	}
185
 
451 aurelien 186
	public String getTag() {
187
		return tag.getText();
335 benjamin 188
	}
189
 
451 aurelien 190
	public String getMotCle() {
191
		return motCle.getText();
335 benjamin 192
	}
193
 
451 aurelien 194
	public String getAuteur() {
195
		return auteur.getText();
335 benjamin 196
	}
197
 
451 aurelien 198
	public String getDate() {
199
		return date.getText();
335 benjamin 200
	}
201
 
407 gduche 202
	public void focusSaisie() {
203
		this.recherchePrincipale.setFocus(true);
204
	}
451 aurelien 205
 
206
	@Override
207
	public void ajouterVue(HasWidgets composite) {
208
		composite.add(this.asWidget());
209
	}
322 gduche 210
}