Subversion Repositories eFlore/Applications.del

Rev

Rev 1426 | Rev 1986 | 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;
335 benjamin 42
 
322 gduche 43
	public MoteurRechercheVue(String labelRecherche) {
44
		initWidget(uiBinder.createAndBindUi(this));
45
		this.labelRecherche = labelRecherche;
46
		recherchePrincipale.setText(labelRecherche);
47
		rechercheAvancee.setVisible(false);
48
	}
1367 aurelien 49
 
50
	@Override
51
	public void remplirListeReferentiels(Map<String, String> listeReferentiels) {
52
		for (Iterator<String> iterator = listeReferentiels.keySet().iterator(); iterator.hasNext();) {
53
			String codeRef = iterator.next();
54
			referentiel.addItem(listeReferentiels.get(codeRef), codeRef);
55
		}
1792 mathias 56
		referentiel.setItemSelected(1, true);
1367 aurelien 57
	}
322 gduche 58
 
59
	public String getLabelRecherche() {
60
		return labelRecherche;
61
	}
335 benjamin 62
 
322 gduche 63
	public HasClickHandlers getLienRechercheAvancee() {
64
		return lienRechercheAvancee;
65
	}
66
 
67
	public HasClickHandlers getBoutonRechercheSimple() {
68
		return boutonRecherche;
69
	}
445 benjamin 70
 
408 gduche 71
	public HasClickHandlers getBoutonFermer() {
72
		return boutonFermer;
73
	}
445 benjamin 74
 
419 gduche 75
	public HasClickHandlers getBoutonVider() {
76
		return boutonVider;
77
	}
335 benjamin 78
 
322 gduche 79
	public HasClickHandlers getBoutonRechercheAvancee() {
80
		return boutonRechercheAvancee;
81
	}
82
 
83
	public HasKeyPressHandlers getChampSaisie() {
84
		return recherchePrincipale;
85
	}
86
 
87
	public String getValeurRechercheSimple() {
88
		return recherchePrincipale.getText();
89
	}
564 benjamin 90
 
545 jpm 91
	public void setValeurRechercheSimple(String valeurRecherche) {
92
		recherchePrincipale.setText(valeurRecherche);
533 jpm 93
	}
564 benjamin 94
 
322 gduche 95
	public HasClickHandlers getChampSaisieCliquable() {
96
		return recherchePrincipale;
97
	}
564 benjamin 98
 
545 jpm 99
	public String getContientMots() {
100
		return contientMots.getText();
101
	}
335 benjamin 102
 
533 jpm 103
	public void setContientMots(String mots) {
104
		contientMots.setText(mots);
105
	}
564 benjamin 106
 
545 jpm 107
	public String getDepartement() {
108
		return departement.getText();
109
	}
110
 
457 aurelien 111
	public void setValeurDepartement(String dpt) {
112
		departement.setValue(dpt);
113
	}
545 jpm 114
 
115
	public HasWidgets getCommune() {
116
		return commune;
117
	}
118
 
119
	public HasWidgets getTaxon() {
120
		return taxon;
121
	}
122
 
123
	public String getFamille() {
124
		return famille.getText();
125
	}
126
 
127
	public String getGenre() {
128
		return genre.getText();
129
	}
130
 
131
	public String getMotCle() {
132
		return motCle.getText();
133
	}
134
 
135
	public String getAuteur() {
136
		return auteur.getText();
137
	}
138
 
139
	public String getDate() {
140
		return date.getText();
141
	}
1367 aurelien 142
 
143
	public String getReferentiel() {
144
		return referentiel.getValue(referentiel.getSelectedIndex());
145
	}
564 benjamin 146
 
545 jpm 147
	public void focusSaisie() {
148
		this.recherchePrincipale.setFocus(true);
149
	}
322 gduche 150
 
545 jpm 151
	public void ajouterVue(HasWidgets composite) {
152
		composite.add(this.asWidget());
153
	}
564 benjamin 154
 
545 jpm 155
	public void basculerAffichageZoneCache() {
156
		rechercheAvancee.setVisible(!rechercheAvancee.isVisible());
157
		recherchePrincipale.setVisible(!recherchePrincipale.isVisible());
158
		boutonRecherche.setVisible(!boutonRecherche.isVisible());
159
	}
564 benjamin 160
 
545 jpm 161
	public void nettoyer() {
162
		chargerValeursRecherchePrecedente(new InformationsRecherche());
163
	}
564 benjamin 164
 
335 benjamin 165
	public void chargerValeursRecherchePrecedente(InformationsRecherche informationsRecherche) {
451 aurelien 166
		recherchePrincipale.setText(informationsRecherche.getRechercheLibre());
533 jpm 167
		contientMots.setText(informationsRecherche.getRechercheLibre());
451 aurelien 168
		departement.setText(informationsRecherche.getDepartement());
169
		famille.setText(informationsRecherche.getFamille());
170
		genre.setText(informationsRecherche.getGenre());
171
		motCle.setText(informationsRecherche.getMotClef());
1426 aurelien 172
		motCleCel.setText(informationsRecherche.getMotClefCel());
173
		motCleDel.setText(informationsRecherche.getMotClefDel());
451 aurelien 174
		auteur.setText(informationsRecherche.getAuteur());
175
		date.setText(informationsRecherche.getDate());
1367 aurelien 176
 
177
		for(int i = 0; i < referentiel.getItemCount(); i++) {
178
			if(referentiel.getValue(i).equals(informationsRecherche.getReferentiel())) {
179
				referentiel.setSelectedIndex(i);
180
			}
181
		}
445 benjamin 182
 
335 benjamin 183
		afficherLigneInfoRecherche(informationsRecherche);
184
	}
185
 
186
	/**
187
	 * Affiche la ligne d'en tête montrant les elements de la requête à
188
	 * l'utilisateur
189
	 *
190
	 * @param informationRecherche
191
	 */
192
	private void afficherLigneInfoRecherche(InformationsRecherche informationRecherche) {
445 benjamin 193
		// tax dep com fam gen ta mo au date
335 benjamin 194
		StringBuffer texteRecherchePrecedente = new StringBuffer();
445 benjamin 195
 
196
		if (informationRecherche.getRechercheLibre() != null && !informationRecherche.getRechercheLibre().equals("")) {
335 benjamin 197
			texteRecherchePrecedente.append(I18n.getVocabulary().rechercheLibre() + ":" + informationRecherche.getRechercheLibre() + " ");
322 gduche 198
		}
445 benjamin 199
		if (informationRecherche.getTaxon() != null && !informationRecherche.getTaxon().equals("")) {
419 gduche 200
			texteRecherchePrecedente.append(I18n.getVocabulary().taxon() + ":" + informationRecherche.getTaxon() + " ");
322 gduche 201
		}
445 benjamin 202
		if (informationRecherche.getDepartement() != null && !informationRecherche.getDepartement().equals("")) {
419 gduche 203
			texteRecherchePrecedente.append(I18n.getVocabulary().departement() + ":" + informationRecherche.getDepartement() + " ");
204
		}
445 benjamin 205
		if (informationRecherche.getCommune() != null && !informationRecherche.getCommune().equals("")) {
335 benjamin 206
			texteRecherchePrecedente.append(I18n.getVocabulary().commune() + ":" + informationRecherche.getCommune() + " ");
322 gduche 207
		}
445 benjamin 208
		if (informationRecherche.getFamille() != null && !informationRecherche.getFamille().equals("")) {
335 benjamin 209
			texteRecherchePrecedente.append(I18n.getVocabulary().famille() + ":" + informationRecherche.getFamille() + " ");
322 gduche 210
		}
445 benjamin 211
		if (informationRecherche.getGenre() != null && !informationRecherche.getGenre().equals("")) {
335 benjamin 212
			texteRecherchePrecedente.append(I18n.getVocabulary().genre() + ":" + informationRecherche.getGenre() + " ");
322 gduche 213
		}
445 benjamin 214
		if (informationRecherche.getTag() != null && !informationRecherche.getTag().equals("")) {
419 gduche 215
			texteRecherchePrecedente.append(I18n.getVocabulary().tag() + ":" + informationRecherche.getTag() + " ");
216
		}
445 benjamin 217
		if (informationRecherche.getMotClef() != null && !informationRecherche.getMotClef().equals("")) {
335 benjamin 218
			texteRecherchePrecedente.append(I18n.getVocabulary().mot_clef() + ":" + informationRecherche.getMotClef() + " ");
322 gduche 219
		}
1426 aurelien 220
		if (informationRecherche.getMotClefCel() != null && !informationRecherche.getMotClefCel().equals("")) {
221
			texteRecherchePrecedente.append(I18n.getVocabulary().tagCel() + ":" + informationRecherche.getMotClefCel() + " ");
222
		}
223
		if (informationRecherche.getMotClefDel() != null && !informationRecherche.getMotClefDel().equals("")) {
224
			texteRecherchePrecedente.append(I18n.getVocabulary().tagDel() + ":" + informationRecherche.getMotClefDel() + " ");
225
		}
445 benjamin 226
		if (informationRecherche.getAuteur() != null && !informationRecherche.getAuteur().equals("")) {
419 gduche 227
			texteRecherchePrecedente.append(I18n.getVocabulary().auteur() + ":" + informationRecherche.getAuteur() + " ");
228
		}
445 benjamin 229
		if (informationRecherche.getDate() != null && !informationRecherche.getDate().equals("")) {
419 gduche 230
			texteRecherchePrecedente.append(I18n.getVocabulary().date() + ":" + informationRecherche.getDate() + " ");
231
		}
1367 aurelien 232
		if (informationRecherche.getReferentiel() != null && !informationRecherche.getReferentiel().equals("")) {
233
			texteRecherchePrecedente.append(I18n.getVocabulary().referentiel() + ":" + informationRecherche.getReferentiel() + " ");
234
		}
445 benjamin 235
 
335 benjamin 236
		recherchePrecedente.setText(texteRecherchePrecedente.toString());
322 gduche 237
	}
564 benjamin 238
 
239
	@Override
240
	public HasKeyPressHandlers getChampsFamille() {
241
		return famille;
242
	}
243
 
244
	@Override
245
	public HasKeyPressHandlers getChampsGenre() {
246
		return genre;
247
	}
248
 
249
	@Override
250
	public HasKeyPressHandlers getChampsMotCle() {
251
		return motCle;
252
	}
253
 
254
	@Override
255
	public HasKeyPressHandlers getChampsAuteur() {
256
		return auteur;
257
	}
258
 
259
	@Override
260
	public HasKeyPressHandlers getChampsDate() {
261
		return date;
262
	}
671 aurelien 263
 
264
	@Override
265
	public HasKeyPressHandlers getChampsDepartement() {
266
		return departement;
267
	}
268
 
269
	@Override
270
	public HasKeyPressHandlers getChampsContientMots() {
271
		return contientMots;
272
	}
1120 gduche 273
 
274
	public HasWidgets getZoneRss() {
275
		return zoneRss;
276
	}
1367 aurelien 277
 
278
	@Override
279
	public void setReferentielLectureSeule(boolean lectureSeule) {
1792 mathias 280
		// la listbox ne possède aucun méthode directe pour être désactivée
1367 aurelien 281
		DOM.setElementProperty(referentiel.getElement(), "disabled", "disabled");
282
	}
1426 aurelien 283
 
284
	@Override
285
	public HasKeyPressHandlers getChampsMotCleDel() {
286
		return motCleDel;
287
	}
288
 
289
	@Override
290
	public HasKeyPressHandlers getChampsMotCleCel() {
291
		return motCleCel;
292
	}
293
 
294
	@Override
295
	public String getMotCleDel() {
296
		return motCleDel.getText();
297
	}
298
 
299
	@Override
300
	public String getMotCleCel() {
301
		return motCleCel.getText();
302
	}
303
 
304
	@Override
305
	public void cacherChampsTagsImage() {
306
		conteneurMotCleCel.setVisible(false);
307
		conteneurMotCleDel.setVisible(false);
308
	}
309
 
310
	@Override
311
	public void cacherChampsTagsObs() {
312
		conteneurMotCle.setVisible(false);
313
	}
545 jpm 314
}