Subversion Repositories eFlore/Applications.del

Rev

Rev 408 | Rev 445 | 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
419 gduche 29
	Panel rechercheAvancee, taxon;
335 benjamin 30
	@UiField
31
	Label lienRechercheAvancee, recherchePrecedente;
32
	@UiField
419 gduche 33
	Button boutonRecherche, boutonRechercheAvancee, boutonFermer, boutonVider;
335 benjamin 34
	@UiField
386 aurelien 35
	TextBox recherchePrincipale, departement, commune, 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
	@Override
49
	public HasClickHandlers getLienRechercheAvancee() {
50
		return lienRechercheAvancee;
51
	}
52
 
53
	@Override
54
	public void basculerAffichageZoneCache() {
55
		rechercheAvancee.setVisible(!rechercheAvancee.isVisible());
419 gduche 56
		recherchePrincipale.setVisible(!recherchePrincipale.isVisible());
57
		boutonRecherche.setVisible(!boutonRecherche.isVisible());
322 gduche 58
	}
59
 
60
	@Override
61
	public HasClickHandlers getBoutonRechercheSimple() {
62
		return boutonRecherche;
63
	}
408 gduche 64
 
65
	@Override
66
	public HasClickHandlers getBoutonFermer() {
67
		return boutonFermer;
68
	}
419 gduche 69
 
70
	@Override
71
	public HasClickHandlers getBoutonVider() {
72
		return boutonVider;
73
	}
335 benjamin 74
 
322 gduche 75
	@Override
76
	public HasClickHandlers getBoutonRechercheAvancee() {
77
		return boutonRechercheAvancee;
78
	}
79
 
80
	@Override
81
	public HasKeyPressHandlers getChampSaisie() {
82
		return recherchePrincipale;
83
	}
84
 
85
	@Override
86
	public String getValeurRechercheSimple() {
87
		return recherchePrincipale.getText();
88
	}
89
 
90
	@Override
91
	public HasClickHandlers getChampSaisieCliquable() {
92
		return recherchePrincipale;
93
	}
335 benjamin 94
 
322 gduche 95
	@Override
96
	public void setValeurRechercheSimple(String valeurRecherche) {
97
		recherchePrincipale.setText(valeurRecherche);
98
	}
99
 
419 gduche 100
	public void chargerValeursRechercheSimplePrecedente(InformationsRecherche informationsRecherche) {
101
 
102
		this.nettoyer();
103
		if (informationsRecherche.getRechercheLibre() != null && !informationsRecherche.getRechercheLibre().equals("")) {
104
			getRecherchePrincipale().setText(informationsRecherche.getRechercheLibre());
105
		}
106
		afficherLigneInfoRecherche(informationsRecherche);
107
	}
108
 
335 benjamin 109
	public void chargerValeursRecherchePrecedente(InformationsRecherche informationsRecherche) {
419 gduche 110
		informationsRecherche.setRechercheLibre(null);
111
		getRecherchePrincipale().setText("");
112
		getDepartement().setText(informationsRecherche.getDepartement());
335 benjamin 113
		getCommune().setText(informationsRecherche.getCommune());
114
		getFamille().setText(informationsRecherche.getFamille());
419 gduche 115
		getGenre().setText(informationsRecherche.getGenre());
116
		getTag().setText(informationsRecherche.getTag());
335 benjamin 117
		getMotCle().setText(informationsRecherche.getMotClef());
419 gduche 118
		getAuteur().setText(informationsRecherche.getAuteur());
119
		getDate().setText(informationsRecherche.getDate());
322 gduche 120
 
335 benjamin 121
		afficherLigneInfoRecherche(informationsRecherche);
122
	}
123
 
124
	/**
125
	 * Affiche la ligne d'en tête montrant les elements de la requête à
126
	 * l'utilisateur
127
	 *
128
	 * @param informationRecherche
129
	 */
130
	private void afficherLigneInfoRecherche(InformationsRecherche informationRecherche) {
131
 
419 gduche 132
		//tax dep com fam gen ta mo au date
335 benjamin 133
		StringBuffer texteRecherchePrecedente = new StringBuffer();
419 gduche 134
 
335 benjamin 135
		if (informationRecherche.getRechercheLibre()!=null&&!informationRecherche.getRechercheLibre().equals("")) {
136
			texteRecherchePrecedente.append(I18n.getVocabulary().rechercheLibre() + ":" + informationRecherche.getRechercheLibre() + " ");
322 gduche 137
		}
419 gduche 138
		if (informationRecherche.getTaxon() != null&&!informationRecherche.getTaxon().equals("")) {
139
			texteRecherchePrecedente.append(I18n.getVocabulary().taxon() + ":" + informationRecherche.getTaxon() + " ");
322 gduche 140
		}
419 gduche 141
		if (informationRecherche.getDepartement()!=null && !informationRecherche.getDepartement().equals("")) {
142
			texteRecherchePrecedente.append(I18n.getVocabulary().departement() + ":" + informationRecherche.getDepartement() + " ");
143
		}
144
		if (informationRecherche.getCommune()!=null && !informationRecherche.getCommune().equals("")) {
335 benjamin 145
			texteRecherchePrecedente.append(I18n.getVocabulary().commune() + ":" + informationRecherche.getCommune() + " ");
322 gduche 146
		}
419 gduche 147
		if (informationRecherche.getFamille()!=null && !informationRecherche.getFamille().equals("")) {
335 benjamin 148
			texteRecherchePrecedente.append(I18n.getVocabulary().famille() + ":" + informationRecherche.getFamille() + " ");
322 gduche 149
		}
419 gduche 150
		if (informationRecherche.getGenre()!=null && !informationRecherche.getGenre().equals("")) {
335 benjamin 151
			texteRecherchePrecedente.append(I18n.getVocabulary().genre() + ":" + informationRecherche.getGenre() + " ");
322 gduche 152
		}
419 gduche 153
		if (informationRecherche.getTag()!=null && !informationRecherche.getTag().equals("")) {
154
			texteRecherchePrecedente.append(I18n.getVocabulary().tag() + ":" + informationRecherche.getTag() + " ");
155
		}
156
		if (informationRecherche.getMotClef()!=null && !informationRecherche.getMotClef().equals("")) {
335 benjamin 157
			texteRecherchePrecedente.append(I18n.getVocabulary().mot_clef() + ":" + informationRecherche.getMotClef() + " ");
322 gduche 158
		}
419 gduche 159
		if (informationRecherche.getAuteur()!=null && !informationRecherche.getAuteur().equals("")) {
160
			texteRecherchePrecedente.append(I18n.getVocabulary().auteur() + ":" + informationRecherche.getAuteur() + " ");
161
		}
162
		if (informationRecherche.getDate()!=null && !informationRecherche.getDate().equals("")) {
163
			texteRecherchePrecedente.append(I18n.getVocabulary().date() + ":" + informationRecherche.getDate() + " ");
164
		}
165
 
166
 
167
 
335 benjamin 168
		recherchePrecedente.setText(texteRecherchePrecedente.toString());
322 gduche 169
	}
335 benjamin 170
 
419 gduche 171
	public void nettoyer() {
172
		chargerValeursRecherchePrecedente(new InformationsRecherche());
173
	}
174
 
335 benjamin 175
	public HasText getRecherchePrincipale() {
176
		return recherchePrincipale;
322 gduche 177
	}
178
 
335 benjamin 179
	public HasText getDepartement() {
180
		return departement;
322 gduche 181
	}
335 benjamin 182
 
183
	public HasText getCommune() {
184
		return commune;
185
	}
186
 
386 aurelien 187
	public HasWidgets getTaxon() {
335 benjamin 188
		return taxon;
189
	}
190
 
191
	public HasText getFamille() {
192
		return famille;
193
	}
194
 
195
	public HasText getGenre() {
196
		return genre;
197
	}
198
 
199
	public HasText getTag() {
200
		return tag;
201
	}
202
 
203
	public HasText getMotCle() {
204
		return motCle;
205
	}
206
 
207
	public HasText getAuteur() {
208
		return auteur;
209
	}
210
 
211
	public HasText getDate() {
212
		return date;
213
	}
214
 
407 gduche 215
	public void focusSaisie() {
216
		this.recherchePrincipale.setFocus(true);
217
	}
322 gduche 218
}