Subversion Repositories eFlore/Applications.del

Rev

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