Subversion Repositories eFlore/Applications.del

Rev

Rev 1367 | Rev 1792 | 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
1426 aurelien 33
	Panel rechercheAvancee, taxon, commune, zoneRss, conteneurMotCle, conteneurMotCleCel, conteneurMotCleDel  ;
335 benjamin 34
	@UiField
35
	Label lienRechercheAvancee, recherchePrecedente;
36
	@UiField
419 gduche 37
	Button boutonRecherche, boutonRechercheAvancee, boutonFermer, boutonVider;
335 benjamin 38
	@UiField
1426 aurelien 39
	TextBox recherchePrincipale, contientMots, departement, famille, genre, motCle, motCleCel, motCleDel, 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());
1426 aurelien 173
		motCleCel.setText(informationsRecherche.getMotClefCel());
174
		motCleDel.setText(informationsRecherche.getMotClefDel());
451 aurelien 175
		auteur.setText(informationsRecherche.getAuteur());
176
		date.setText(informationsRecherche.getDate());
1367 aurelien 177
 
178
		for(int i = 0; i < referentiel.getItemCount(); i++) {
179
			if(referentiel.getValue(i).equals(informationsRecherche.getReferentiel())) {
180
				referentiel.setSelectedIndex(i);
181
			}
182
		}
445 benjamin 183
 
335 benjamin 184
		afficherLigneInfoRecherche(informationsRecherche);
185
	}
186
 
187
	/**
188
	 * Affiche la ligne d'en tête montrant les elements de la requête à
189
	 * l'utilisateur
190
	 *
191
	 * @param informationRecherche
192
	 */
193
	private void afficherLigneInfoRecherche(InformationsRecherche informationRecherche) {
445 benjamin 194
		// tax dep com fam gen ta mo au date
335 benjamin 195
		StringBuffer texteRecherchePrecedente = new StringBuffer();
445 benjamin 196
 
197
		if (informationRecherche.getRechercheLibre() != null && !informationRecherche.getRechercheLibre().equals("")) {
335 benjamin 198
			texteRecherchePrecedente.append(I18n.getVocabulary().rechercheLibre() + ":" + informationRecherche.getRechercheLibre() + " ");
322 gduche 199
		}
445 benjamin 200
		if (informationRecherche.getTaxon() != null && !informationRecherche.getTaxon().equals("")) {
419 gduche 201
			texteRecherchePrecedente.append(I18n.getVocabulary().taxon() + ":" + informationRecherche.getTaxon() + " ");
322 gduche 202
		}
445 benjamin 203
		if (informationRecherche.getDepartement() != null && !informationRecherche.getDepartement().equals("")) {
419 gduche 204
			texteRecherchePrecedente.append(I18n.getVocabulary().departement() + ":" + informationRecherche.getDepartement() + " ");
205
		}
445 benjamin 206
		if (informationRecherche.getCommune() != null && !informationRecherche.getCommune().equals("")) {
335 benjamin 207
			texteRecherchePrecedente.append(I18n.getVocabulary().commune() + ":" + informationRecherche.getCommune() + " ");
322 gduche 208
		}
445 benjamin 209
		if (informationRecherche.getFamille() != null && !informationRecherche.getFamille().equals("")) {
335 benjamin 210
			texteRecherchePrecedente.append(I18n.getVocabulary().famille() + ":" + informationRecherche.getFamille() + " ");
322 gduche 211
		}
445 benjamin 212
		if (informationRecherche.getGenre() != null && !informationRecherche.getGenre().equals("")) {
335 benjamin 213
			texteRecherchePrecedente.append(I18n.getVocabulary().genre() + ":" + informationRecherche.getGenre() + " ");
322 gduche 214
		}
445 benjamin 215
		if (informationRecherche.getTag() != null && !informationRecherche.getTag().equals("")) {
419 gduche 216
			texteRecherchePrecedente.append(I18n.getVocabulary().tag() + ":" + informationRecherche.getTag() + " ");
217
		}
445 benjamin 218
		if (informationRecherche.getMotClef() != null && !informationRecherche.getMotClef().equals("")) {
335 benjamin 219
			texteRecherchePrecedente.append(I18n.getVocabulary().mot_clef() + ":" + informationRecherche.getMotClef() + " ");
322 gduche 220
		}
1426 aurelien 221
		if (informationRecherche.getMotClefCel() != null && !informationRecherche.getMotClefCel().equals("")) {
222
			texteRecherchePrecedente.append(I18n.getVocabulary().tagCel() + ":" + informationRecherche.getMotClefCel() + " ");
223
		}
224
		if (informationRecherche.getMotClefDel() != null && !informationRecherche.getMotClefDel().equals("")) {
225
			texteRecherchePrecedente.append(I18n.getVocabulary().tagDel() + ":" + informationRecherche.getMotClefDel() + " ");
226
		}
445 benjamin 227
		if (informationRecherche.getAuteur() != null && !informationRecherche.getAuteur().equals("")) {
419 gduche 228
			texteRecherchePrecedente.append(I18n.getVocabulary().auteur() + ":" + informationRecherche.getAuteur() + " ");
229
		}
445 benjamin 230
		if (informationRecherche.getDate() != null && !informationRecherche.getDate().equals("")) {
419 gduche 231
			texteRecherchePrecedente.append(I18n.getVocabulary().date() + ":" + informationRecherche.getDate() + " ");
232
		}
1367 aurelien 233
		if (informationRecherche.getReferentiel() != null && !informationRecherche.getReferentiel().equals("")) {
234
			texteRecherchePrecedente.append(I18n.getVocabulary().referentiel() + ":" + informationRecherche.getReferentiel() + " ");
235
		}
445 benjamin 236
 
335 benjamin 237
		recherchePrecedente.setText(texteRecherchePrecedente.toString());
322 gduche 238
	}
564 benjamin 239
 
240
	@Override
241
	public HasKeyPressHandlers getChampsFamille() {
242
		return famille;
243
	}
244
 
245
	@Override
246
	public HasKeyPressHandlers getChampsGenre() {
247
		return genre;
248
	}
249
 
250
	@Override
251
	public HasKeyPressHandlers getChampsMotCle() {
252
		return motCle;
253
	}
254
 
255
	@Override
256
	public HasKeyPressHandlers getChampsAuteur() {
257
		return auteur;
258
	}
259
 
260
	@Override
261
	public HasKeyPressHandlers getChampsDate() {
262
		return date;
263
	}
671 aurelien 264
 
265
	@Override
266
	public HasKeyPressHandlers getChampsDepartement() {
267
		return departement;
268
	}
269
 
270
	@Override
271
	public HasKeyPressHandlers getChampsContientMots() {
272
		return contientMots;
273
	}
1120 gduche 274
 
275
	public HasWidgets getZoneRss() {
276
		return zoneRss;
277
	}
1367 aurelien 278
 
279
	@Override
280
	public void setReferentielLectureSeule(boolean lectureSeule) {
281
		referentielLectureSeule = true;
282
		// la listbox ne possède aucun méthode directe pour être désactivée
283
		DOM.setElementProperty(referentiel.getElement(), "disabled", "disabled");
284
	}
1426 aurelien 285
 
286
	@Override
287
	public HasKeyPressHandlers getChampsMotCleDel() {
288
		return motCleDel;
289
	}
290
 
291
	@Override
292
	public HasKeyPressHandlers getChampsMotCleCel() {
293
		return motCleCel;
294
	}
295
 
296
	@Override
297
	public String getMotCleDel() {
298
		return motCleDel.getText();
299
	}
300
 
301
	@Override
302
	public String getMotCleCel() {
303
		return motCleCel.getText();
304
	}
305
 
306
	@Override
307
	public void cacherChampsTagsImage() {
308
		conteneurMotCleCel.setVisible(false);
309
		conteneurMotCleDel.setVisible(false);
310
	}
311
 
312
	@Override
313
	public void cacherChampsTagsObs() {
314
		conteneurMotCle.setVisible(false);
315
	}
545 jpm 316
}