Subversion Repositories eFlore/Applications.del

Rev

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