Subversion Repositories eFlore/Applications.del

Rev

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