Subversion Repositories eFlore/Applications.del

Rev

Rev 1120 | Rev 1426 | 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
 
1367 aurelien 3
import java.util.Iterator;
4
import java.util.Map;
5
 
335 benjamin 6
import org.tela_botanica.del.client.i18n.I18n;
7
import org.tela_botanica.del.client.modeles.InformationsRecherche;
322 gduche 8
 
9
import com.google.gwt.core.client.GWT;
10
import com.google.gwt.event.dom.client.HasClickHandlers;
11
import com.google.gwt.event.dom.client.HasKeyPressHandlers;
12
import com.google.gwt.uibinder.client.UiBinder;
13
import com.google.gwt.uibinder.client.UiField;
1367 aurelien 14
import com.google.gwt.user.client.DOM;
322 gduche 15
import com.google.gwt.user.client.ui.Button;
16
import com.google.gwt.user.client.ui.Composite;
386 aurelien 17
import com.google.gwt.user.client.ui.HasWidgets;
322 gduche 18
import com.google.gwt.user.client.ui.Label;
1367 aurelien 19
import com.google.gwt.user.client.ui.ListBox;
322 gduche 20
import com.google.gwt.user.client.ui.Panel;
21
import com.google.gwt.user.client.ui.TextBox;
22
import com.google.gwt.user.client.ui.Widget;
23
 
24
public class MoteurRechercheVue extends Composite implements MoteurRecherchePresenteur.Vue {
25
 
564 benjamin 26
	interface Binder extends UiBinder<Widget, MoteurRechercheVue> {
27
	}
335 benjamin 28
 
322 gduche 29
	private static Binder uiBinder = GWT.create(Binder.class);
30
	private String labelRecherche = "";
335 benjamin 31
 
32
	@UiField
1120 gduche 33
	Panel rechercheAvancee, taxon, commune, zoneRss;
335 benjamin 34
	@UiField
35
	Label lienRechercheAvancee, recherchePrecedente;
36
	@UiField
419 gduche 37
	Button boutonRecherche, boutonRechercheAvancee, boutonFermer, boutonVider;
335 benjamin 38
	@UiField
581 gduche 39
	TextBox recherchePrincipale, contientMots, departement, famille, genre, motCle, auteur, date;
1367 aurelien 40
	@UiField
41
	ListBox referentiel;
42
 
43
	private boolean referentielLectureSeule = false;
335 benjamin 44
 
322 gduche 45
	public MoteurRechercheVue(String labelRecherche) {
46
		initWidget(uiBinder.createAndBindUi(this));
47
		this.labelRecherche = labelRecherche;
48
		recherchePrincipale.setText(labelRecherche);
49
		rechercheAvancee.setVisible(false);
50
	}
1367 aurelien 51
 
52
	@Override
53
	public void remplirListeReferentiels(Map<String, String> listeReferentiels) {
54
		for (Iterator<String> iterator = listeReferentiels.keySet().iterator(); iterator.hasNext();) {
55
			String codeRef = iterator.next();
56
			referentiel.addItem(listeReferentiels.get(codeRef), codeRef);
57
		}
58
	}
322 gduche 59
 
60
	public String getLabelRecherche() {
61
		return labelRecherche;
62
	}
335 benjamin 63
 
322 gduche 64
	public HasClickHandlers getLienRechercheAvancee() {
65
		return lienRechercheAvancee;
66
	}
67
 
68
	public HasClickHandlers getBoutonRechercheSimple() {
69
		return boutonRecherche;
70
	}
445 benjamin 71
 
408 gduche 72
	public HasClickHandlers getBoutonFermer() {
73
		return boutonFermer;
74
	}
445 benjamin 75
 
419 gduche 76
	public HasClickHandlers getBoutonVider() {
77
		return boutonVider;
78
	}
335 benjamin 79
 
322 gduche 80
	public HasClickHandlers getBoutonRechercheAvancee() {
81
		return boutonRechercheAvancee;
82
	}
83
 
84
	public HasKeyPressHandlers getChampSaisie() {
85
		return recherchePrincipale;
86
	}
87
 
88
	public String getValeurRechercheSimple() {
89
		return recherchePrincipale.getText();
90
	}
564 benjamin 91
 
545 jpm 92
	public void setValeurRechercheSimple(String valeurRecherche) {
93
		recherchePrincipale.setText(valeurRecherche);
533 jpm 94
	}
564 benjamin 95
 
322 gduche 96
	public HasClickHandlers getChampSaisieCliquable() {
97
		return recherchePrincipale;
98
	}
564 benjamin 99
 
545 jpm 100
	public String getContientMots() {
101
		return contientMots.getText();
102
	}
335 benjamin 103
 
533 jpm 104
	public void setContientMots(String mots) {
105
		contientMots.setText(mots);
106
	}
564 benjamin 107
 
545 jpm 108
	public String getDepartement() {
109
		return departement.getText();
110
	}
111
 
457 aurelien 112
	public void setValeurDepartement(String dpt) {
113
		departement.setValue(dpt);
114
	}
545 jpm 115
 
116
	public HasWidgets getCommune() {
117
		return commune;
118
	}
119
 
120
	public HasWidgets getTaxon() {
121
		return taxon;
122
	}
123
 
124
	public String getFamille() {
125
		return famille.getText();
126
	}
127
 
128
	public String getGenre() {
129
		return genre.getText();
130
	}
131
 
132
	public String getMotCle() {
133
		return motCle.getText();
134
	}
135
 
136
	public String getAuteur() {
137
		return auteur.getText();
138
	}
139
 
140
	public String getDate() {
141
		return date.getText();
142
	}
1367 aurelien 143
 
144
	public String getReferentiel() {
145
		return referentiel.getValue(referentiel.getSelectedIndex());
146
	}
564 benjamin 147
 
545 jpm 148
	public void focusSaisie() {
149
		this.recherchePrincipale.setFocus(true);
150
	}
322 gduche 151
 
545 jpm 152
	public void ajouterVue(HasWidgets composite) {
153
		composite.add(this.asWidget());
154
	}
564 benjamin 155
 
545 jpm 156
	public void basculerAffichageZoneCache() {
157
		rechercheAvancee.setVisible(!rechercheAvancee.isVisible());
158
		recherchePrincipale.setVisible(!recherchePrincipale.isVisible());
159
		boutonRecherche.setVisible(!boutonRecherche.isVisible());
160
	}
564 benjamin 161
 
545 jpm 162
	public void nettoyer() {
163
		chargerValeursRecherchePrecedente(new InformationsRecherche());
164
	}
564 benjamin 165
 
335 benjamin 166
	public void chargerValeursRecherchePrecedente(InformationsRecherche informationsRecherche) {
451 aurelien 167
		recherchePrincipale.setText(informationsRecherche.getRechercheLibre());
533 jpm 168
		contientMots.setText(informationsRecherche.getRechercheLibre());
451 aurelien 169
		departement.setText(informationsRecherche.getDepartement());
170
		famille.setText(informationsRecherche.getFamille());
171
		genre.setText(informationsRecherche.getGenre());
172
		motCle.setText(informationsRecherche.getMotClef());
173
		auteur.setText(informationsRecherche.getAuteur());
174
		date.setText(informationsRecherche.getDate());
1367 aurelien 175
 
176
		for(int i = 0; i < referentiel.getItemCount(); i++) {
177
			if(referentiel.getValue(i).equals(informationsRecherche.getReferentiel())) {
178
				referentiel.setSelectedIndex(i);
179
			}
180
		}
445 benjamin 181
 
335 benjamin 182
		afficherLigneInfoRecherche(informationsRecherche);
183
	}
184
 
185
	/**
186
	 * Affiche la ligne d'en tête montrant les elements de la requête à
187
	 * l'utilisateur
188
	 *
189
	 * @param informationRecherche
190
	 */
191
	private void afficherLigneInfoRecherche(InformationsRecherche informationRecherche) {
445 benjamin 192
		// tax dep com fam gen ta mo au date
335 benjamin 193
		StringBuffer texteRecherchePrecedente = new StringBuffer();
445 benjamin 194
 
195
		if (informationRecherche.getRechercheLibre() != null && !informationRecherche.getRechercheLibre().equals("")) {
335 benjamin 196
			texteRecherchePrecedente.append(I18n.getVocabulary().rechercheLibre() + ":" + informationRecherche.getRechercheLibre() + " ");
322 gduche 197
		}
445 benjamin 198
		if (informationRecherche.getTaxon() != null && !informationRecherche.getTaxon().equals("")) {
419 gduche 199
			texteRecherchePrecedente.append(I18n.getVocabulary().taxon() + ":" + informationRecherche.getTaxon() + " ");
322 gduche 200
		}
445 benjamin 201
		if (informationRecherche.getDepartement() != null && !informationRecherche.getDepartement().equals("")) {
419 gduche 202
			texteRecherchePrecedente.append(I18n.getVocabulary().departement() + ":" + informationRecherche.getDepartement() + " ");
203
		}
445 benjamin 204
		if (informationRecherche.getCommune() != null && !informationRecherche.getCommune().equals("")) {
335 benjamin 205
			texteRecherchePrecedente.append(I18n.getVocabulary().commune() + ":" + informationRecherche.getCommune() + " ");
322 gduche 206
		}
445 benjamin 207
		if (informationRecherche.getFamille() != null && !informationRecherche.getFamille().equals("")) {
335 benjamin 208
			texteRecherchePrecedente.append(I18n.getVocabulary().famille() + ":" + informationRecherche.getFamille() + " ");
322 gduche 209
		}
445 benjamin 210
		if (informationRecherche.getGenre() != null && !informationRecherche.getGenre().equals("")) {
335 benjamin 211
			texteRecherchePrecedente.append(I18n.getVocabulary().genre() + ":" + informationRecherche.getGenre() + " ");
322 gduche 212
		}
445 benjamin 213
		if (informationRecherche.getTag() != null && !informationRecherche.getTag().equals("")) {
419 gduche 214
			texteRecherchePrecedente.append(I18n.getVocabulary().tag() + ":" + informationRecherche.getTag() + " ");
215
		}
445 benjamin 216
		if (informationRecherche.getMotClef() != null && !informationRecherche.getMotClef().equals("")) {
335 benjamin 217
			texteRecherchePrecedente.append(I18n.getVocabulary().mot_clef() + ":" + informationRecherche.getMotClef() + " ");
322 gduche 218
		}
445 benjamin 219
		if (informationRecherche.getAuteur() != null && !informationRecherche.getAuteur().equals("")) {
419 gduche 220
			texteRecherchePrecedente.append(I18n.getVocabulary().auteur() + ":" + informationRecherche.getAuteur() + " ");
221
		}
445 benjamin 222
		if (informationRecherche.getDate() != null && !informationRecherche.getDate().equals("")) {
419 gduche 223
			texteRecherchePrecedente.append(I18n.getVocabulary().date() + ":" + informationRecherche.getDate() + " ");
224
		}
1367 aurelien 225
		if (informationRecherche.getReferentiel() != null && !informationRecherche.getReferentiel().equals("")) {
226
			texteRecherchePrecedente.append(I18n.getVocabulary().referentiel() + ":" + informationRecherche.getReferentiel() + " ");
227
		}
445 benjamin 228
 
335 benjamin 229
		recherchePrecedente.setText(texteRecherchePrecedente.toString());
322 gduche 230
	}
564 benjamin 231
 
232
	@Override
233
	public HasKeyPressHandlers getChampsFamille() {
234
		return famille;
235
	}
236
 
237
	@Override
238
	public HasKeyPressHandlers getChampsGenre() {
239
		return genre;
240
	}
241
 
242
	@Override
243
	public HasKeyPressHandlers getChampsMotCle() {
244
		return motCle;
245
	}
246
 
247
	@Override
248
	public HasKeyPressHandlers getChampsAuteur() {
249
		return auteur;
250
	}
251
 
252
	@Override
253
	public HasKeyPressHandlers getChampsDate() {
254
		return date;
255
	}
671 aurelien 256
 
257
	@Override
258
	public HasKeyPressHandlers getChampsDepartement() {
259
		return departement;
260
	}
261
 
262
	@Override
263
	public HasKeyPressHandlers getChampsContientMots() {
264
		return contientMots;
265
	}
1120 gduche 266
 
267
	public HasWidgets getZoneRss() {
268
		return zoneRss;
269
	}
1367 aurelien 270
 
271
	@Override
272
	public void setReferentielLectureSeule(boolean lectureSeule) {
273
		referentielLectureSeule = true;
274
		// la listbox ne possède aucun méthode directe pour être désactivée
275
		DOM.setElementProperty(referentiel.getElement(), "disabled", "disabled");
276
	}
545 jpm 277
}