Subversion Repositories eFlore/Applications.del

Rev

Rev 451 | Rev 533 | 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
457 aurelien 35
	TextBox recherchePrincipale, 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
	@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
	}
445 benjamin 64
 
408 gduche 65
	@Override
66
	public HasClickHandlers getBoutonFermer() {
67
		return boutonFermer;
68
	}
445 benjamin 69
 
419 gduche 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
	}
457 aurelien 99
 
100
	@Override
101
	public void setValeurDepartement(String dpt) {
102
		departement.setValue(dpt);
103
	}
322 gduche 104
 
335 benjamin 105
	public void chargerValeursRecherchePrecedente(InformationsRecherche informationsRecherche) {
451 aurelien 106
		recherchePrincipale.setText(informationsRecherche.getRechercheLibre());
107
		departement.setText(informationsRecherche.getDepartement());
108
		famille.setText(informationsRecherche.getFamille());
109
		genre.setText(informationsRecherche.getGenre());
110
		tag.setText(informationsRecherche.getTag());
111
		motCle.setText(informationsRecherche.getMotClef());
112
		auteur.setText(informationsRecherche.getAuteur());
113
		date.setText(informationsRecherche.getDate());
445 benjamin 114
 
335 benjamin 115
		afficherLigneInfoRecherche(informationsRecherche);
116
	}
117
 
118
	/**
119
	 * Affiche la ligne d'en tête montrant les elements de la requête à
120
	 * l'utilisateur
121
	 *
122
	 * @param informationRecherche
123
	 */
124
	private void afficherLigneInfoRecherche(InformationsRecherche informationRecherche) {
125
 
445 benjamin 126
		// tax dep com fam gen ta mo au date
335 benjamin 127
		StringBuffer texteRecherchePrecedente = new StringBuffer();
445 benjamin 128
 
129
		if (informationRecherche.getRechercheLibre() != null && !informationRecherche.getRechercheLibre().equals("")) {
335 benjamin 130
			texteRecherchePrecedente.append(I18n.getVocabulary().rechercheLibre() + ":" + informationRecherche.getRechercheLibre() + " ");
322 gduche 131
		}
445 benjamin 132
		if (informationRecherche.getTaxon() != null && !informationRecherche.getTaxon().equals("")) {
419 gduche 133
			texteRecherchePrecedente.append(I18n.getVocabulary().taxon() + ":" + informationRecherche.getTaxon() + " ");
322 gduche 134
		}
445 benjamin 135
		if (informationRecherche.getDepartement() != null && !informationRecherche.getDepartement().equals("")) {
419 gduche 136
			texteRecherchePrecedente.append(I18n.getVocabulary().departement() + ":" + informationRecherche.getDepartement() + " ");
137
		}
445 benjamin 138
		if (informationRecherche.getCommune() != null && !informationRecherche.getCommune().equals("")) {
335 benjamin 139
			texteRecherchePrecedente.append(I18n.getVocabulary().commune() + ":" + informationRecherche.getCommune() + " ");
322 gduche 140
		}
445 benjamin 141
		if (informationRecherche.getFamille() != null && !informationRecherche.getFamille().equals("")) {
335 benjamin 142
			texteRecherchePrecedente.append(I18n.getVocabulary().famille() + ":" + informationRecherche.getFamille() + " ");
322 gduche 143
		}
445 benjamin 144
		if (informationRecherche.getGenre() != null && !informationRecherche.getGenre().equals("")) {
335 benjamin 145
			texteRecherchePrecedente.append(I18n.getVocabulary().genre() + ":" + informationRecherche.getGenre() + " ");
322 gduche 146
		}
445 benjamin 147
		if (informationRecherche.getTag() != null && !informationRecherche.getTag().equals("")) {
419 gduche 148
			texteRecherchePrecedente.append(I18n.getVocabulary().tag() + ":" + informationRecherche.getTag() + " ");
149
		}
445 benjamin 150
		if (informationRecherche.getMotClef() != null && !informationRecherche.getMotClef().equals("")) {
335 benjamin 151
			texteRecherchePrecedente.append(I18n.getVocabulary().mot_clef() + ":" + informationRecherche.getMotClef() + " ");
322 gduche 152
		}
445 benjamin 153
		if (informationRecherche.getAuteur() != null && !informationRecherche.getAuteur().equals("")) {
419 gduche 154
			texteRecherchePrecedente.append(I18n.getVocabulary().auteur() + ":" + informationRecherche.getAuteur() + " ");
155
		}
445 benjamin 156
		if (informationRecherche.getDate() != null && !informationRecherche.getDate().equals("")) {
419 gduche 157
			texteRecherchePrecedente.append(I18n.getVocabulary().date() + ":" + informationRecherche.getDate() + " ");
158
		}
445 benjamin 159
 
335 benjamin 160
		recherchePrecedente.setText(texteRecherchePrecedente.toString());
322 gduche 161
	}
335 benjamin 162
 
419 gduche 163
	public void nettoyer() {
164
		chargerValeursRecherchePrecedente(new InformationsRecherche());
165
	}
445 benjamin 166
 
451 aurelien 167
	public String getRecherchePrincipale() {
168
		return recherchePrincipale.getText();
322 gduche 169
	}
170
 
451 aurelien 171
	public String getDepartement() {
172
		return departement.getText();
322 gduche 173
	}
335 benjamin 174
 
457 aurelien 175
	public HasWidgets getCommune() {
176
		return commune;
335 benjamin 177
	}
178
 
386 aurelien 179
	public HasWidgets getTaxon() {
335 benjamin 180
		return taxon;
181
	}
182
 
451 aurelien 183
	public String getFamille() {
184
		return famille.getText();
335 benjamin 185
	}
186
 
451 aurelien 187
	public String getGenre() {
188
		return genre.getText();
335 benjamin 189
	}
190
 
451 aurelien 191
	public String getTag() {
192
		return tag.getText();
335 benjamin 193
	}
194
 
451 aurelien 195
	public String getMotCle() {
196
		return motCle.getText();
335 benjamin 197
	}
198
 
451 aurelien 199
	public String getAuteur() {
200
		return auteur.getText();
335 benjamin 201
	}
202
 
451 aurelien 203
	public String getDate() {
204
		return date.getText();
335 benjamin 205
	}
206
 
407 gduche 207
	public void focusSaisie() {
208
		this.recherchePrincipale.setFocus(true);
209
	}
451 aurelien 210
 
211
	@Override
212
	public void ajouterVue(HasWidgets composite) {
213
		composite.add(this.asWidget());
214
	}
322 gduche 215
}