Subversion Repositories eFlore/Applications.del

Rev

Rev 451 | Rev 533 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 451 Rev 457
1
package org.tela_botanica.del.client.composants.moteurrecherche;
1
package org.tela_botanica.del.client.composants.moteurrecherche;
2
 
2
 
3
import org.tela_botanica.del.client.i18n.I18n;
3
import org.tela_botanica.del.client.i18n.I18n;
4
import org.tela_botanica.del.client.modeles.InformationsRecherche;
4
import org.tela_botanica.del.client.modeles.InformationsRecherche;
5
 
5
 
6
import com.google.gwt.core.client.GWT;
6
import com.google.gwt.core.client.GWT;
7
import com.google.gwt.event.dom.client.HasClickHandlers;
7
import com.google.gwt.event.dom.client.HasClickHandlers;
8
import com.google.gwt.event.dom.client.HasKeyPressHandlers;
8
import com.google.gwt.event.dom.client.HasKeyPressHandlers;
9
import com.google.gwt.uibinder.client.UiBinder;
9
import com.google.gwt.uibinder.client.UiBinder;
10
import com.google.gwt.uibinder.client.UiField;
10
import com.google.gwt.uibinder.client.UiField;
11
import com.google.gwt.user.client.ui.Button;
11
import com.google.gwt.user.client.ui.Button;
12
import com.google.gwt.user.client.ui.Composite;
12
import com.google.gwt.user.client.ui.Composite;
13
import com.google.gwt.user.client.ui.HasText;
13
import com.google.gwt.user.client.ui.HasText;
14
import com.google.gwt.user.client.ui.HasWidgets;
14
import com.google.gwt.user.client.ui.HasWidgets;
15
import com.google.gwt.user.client.ui.Label;
15
import com.google.gwt.user.client.ui.Label;
16
import com.google.gwt.user.client.ui.Panel;
16
import com.google.gwt.user.client.ui.Panel;
17
import com.google.gwt.user.client.ui.TextBox;
17
import com.google.gwt.user.client.ui.TextBox;
18
import com.google.gwt.user.client.ui.Widget;
18
import com.google.gwt.user.client.ui.Widget;
19
 
19
 
20
public class MoteurRechercheVue extends Composite implements MoteurRecherchePresenteur.Vue {
20
public class MoteurRechercheVue extends Composite implements MoteurRecherchePresenteur.Vue {
21
 
21
 
22
	interface Binder extends UiBinder<Widget, MoteurRechercheVue> {
22
	interface Binder extends UiBinder<Widget, MoteurRechercheVue> {
23
	}
23
	}
24
 
24
 
25
	private static Binder uiBinder = GWT.create(Binder.class);
25
	private static Binder uiBinder = GWT.create(Binder.class);
26
	private String labelRecherche = "";
26
	private String labelRecherche = "";
27
 
27
 
28
	@UiField
28
	@UiField
29
	Panel rechercheAvancee, taxon;
29
	Panel rechercheAvancee, taxon, commune;
30
	@UiField
30
	@UiField
31
	Label lienRechercheAvancee, recherchePrecedente;
31
	Label lienRechercheAvancee, recherchePrecedente;
32
	@UiField
32
	@UiField
33
	Button boutonRecherche, boutonRechercheAvancee, boutonFermer, boutonVider;
33
	Button boutonRecherche, boutonRechercheAvancee, boutonFermer, boutonVider;
34
	@UiField
34
	@UiField
35
	TextBox recherchePrincipale, departement, commune, famille, genre, tag, motCle, auteur, date;
35
	TextBox recherchePrincipale, departement, famille, genre, tag, motCle, auteur, date;
36
 
36
 
37
	public MoteurRechercheVue(String labelRecherche) {
37
	public MoteurRechercheVue(String labelRecherche) {
38
		initWidget(uiBinder.createAndBindUi(this));
38
		initWidget(uiBinder.createAndBindUi(this));
39
		this.labelRecherche = labelRecherche;
39
		this.labelRecherche = labelRecherche;
40
		recherchePrincipale.setText(labelRecherche);
40
		recherchePrincipale.setText(labelRecherche);
41
		rechercheAvancee.setVisible(false);
41
		rechercheAvancee.setVisible(false);
42
	}
42
	}
43
 
43
 
44
	public String getLabelRecherche() {
44
	public String getLabelRecherche() {
45
		return labelRecherche;
45
		return labelRecherche;
46
	}
46
	}
47
 
47
 
48
	@Override
48
	@Override
49
	public HasClickHandlers getLienRechercheAvancee() {
49
	public HasClickHandlers getLienRechercheAvancee() {
50
		return lienRechercheAvancee;
50
		return lienRechercheAvancee;
51
	}
51
	}
52
 
52
 
53
	@Override
53
	@Override
54
	public void basculerAffichageZoneCache() {
54
	public void basculerAffichageZoneCache() {
55
		rechercheAvancee.setVisible(!rechercheAvancee.isVisible());
55
		rechercheAvancee.setVisible(!rechercheAvancee.isVisible());
56
		recherchePrincipale.setVisible(!recherchePrincipale.isVisible());
56
		recherchePrincipale.setVisible(!recherchePrincipale.isVisible());
57
		boutonRecherche.setVisible(!boutonRecherche.isVisible());
57
		boutonRecherche.setVisible(!boutonRecherche.isVisible());
58
	}
58
	}
59
 
59
 
60
	@Override
60
	@Override
61
	public HasClickHandlers getBoutonRechercheSimple() {
61
	public HasClickHandlers getBoutonRechercheSimple() {
62
		return boutonRecherche;
62
		return boutonRecherche;
63
	}
63
	}
64
 
64
 
65
	@Override
65
	@Override
66
	public HasClickHandlers getBoutonFermer() {
66
	public HasClickHandlers getBoutonFermer() {
67
		return boutonFermer;
67
		return boutonFermer;
68
	}
68
	}
69
 
69
 
70
	@Override
70
	@Override
71
	public HasClickHandlers getBoutonVider() {
71
	public HasClickHandlers getBoutonVider() {
72
		return boutonVider;
72
		return boutonVider;
73
	}
73
	}
74
 
74
 
75
	@Override
75
	@Override
76
	public HasClickHandlers getBoutonRechercheAvancee() {
76
	public HasClickHandlers getBoutonRechercheAvancee() {
77
		return boutonRechercheAvancee;
77
		return boutonRechercheAvancee;
78
	}
78
	}
79
 
79
 
80
	@Override
80
	@Override
81
	public HasKeyPressHandlers getChampSaisie() {
81
	public HasKeyPressHandlers getChampSaisie() {
82
		return recherchePrincipale;
82
		return recherchePrincipale;
83
	}
83
	}
84
 
84
 
85
	@Override
85
	@Override
86
	public String getValeurRechercheSimple() {
86
	public String getValeurRechercheSimple() {
87
		return recherchePrincipale.getText();
87
		return recherchePrincipale.getText();
88
	}
88
	}
89
 
89
 
90
	@Override
90
	@Override
91
	public HasClickHandlers getChampSaisieCliquable() {
91
	public HasClickHandlers getChampSaisieCliquable() {
92
		return recherchePrincipale;
92
		return recherchePrincipale;
93
	}
93
	}
94
 
94
 
95
	@Override
95
	@Override
96
	public void setValeurRechercheSimple(String valeurRecherche) {
96
	public void setValeurRechercheSimple(String valeurRecherche) {
97
		recherchePrincipale.setText(valeurRecherche);
97
		recherchePrincipale.setText(valeurRecherche);
98
	}
98
	}
-
 
99
	
-
 
100
	@Override
-
 
101
	public void setValeurDepartement(String dpt) {
-
 
102
		departement.setValue(dpt);
-
 
103
	}
99
 
104
 
100
	public void chargerValeursRecherchePrecedente(InformationsRecherche informationsRecherche) {
105
	public void chargerValeursRecherchePrecedente(InformationsRecherche informationsRecherche) {
101
		recherchePrincipale.setText(informationsRecherche.getRechercheLibre());
106
		recherchePrincipale.setText(informationsRecherche.getRechercheLibre());
102
		departement.setText(informationsRecherche.getDepartement());
107
		departement.setText(informationsRecherche.getDepartement());
103
		commune.setText(informationsRecherche.getCommune());
-
 
104
		famille.setText(informationsRecherche.getFamille());
108
		famille.setText(informationsRecherche.getFamille());
105
		genre.setText(informationsRecherche.getGenre());
109
		genre.setText(informationsRecherche.getGenre());
106
		tag.setText(informationsRecherche.getTag());
110
		tag.setText(informationsRecherche.getTag());
107
		motCle.setText(informationsRecherche.getMotClef());
111
		motCle.setText(informationsRecherche.getMotClef());
108
		auteur.setText(informationsRecherche.getAuteur());
112
		auteur.setText(informationsRecherche.getAuteur());
109
		date.setText(informationsRecherche.getDate());
113
		date.setText(informationsRecherche.getDate());
110
 
114
 
111
		afficherLigneInfoRecherche(informationsRecherche);
115
		afficherLigneInfoRecherche(informationsRecherche);
112
	}
116
	}
113
 
117
 
114
	/**
118
	/**
115
	 * Affiche la ligne d'en tête montrant les elements de la requête à
119
	 * Affiche la ligne d'en tête montrant les elements de la requête à
116
	 * l'utilisateur
120
	 * l'utilisateur
117
	 * 
121
	 * 
118
	 * @param informationRecherche
122
	 * @param informationRecherche
119
	 */
123
	 */
120
	private void afficherLigneInfoRecherche(InformationsRecherche informationRecherche) {
124
	private void afficherLigneInfoRecherche(InformationsRecherche informationRecherche) {
121
 
125
 
122
		// tax dep com fam gen ta mo au date
126
		// tax dep com fam gen ta mo au date
123
		StringBuffer texteRecherchePrecedente = new StringBuffer();
127
		StringBuffer texteRecherchePrecedente = new StringBuffer();
124
 
128
 
125
		if (informationRecherche.getRechercheLibre() != null && !informationRecherche.getRechercheLibre().equals("")) {
129
		if (informationRecherche.getRechercheLibre() != null && !informationRecherche.getRechercheLibre().equals("")) {
126
			texteRecherchePrecedente.append(I18n.getVocabulary().rechercheLibre() + ":" + informationRecherche.getRechercheLibre() + " ");
130
			texteRecherchePrecedente.append(I18n.getVocabulary().rechercheLibre() + ":" + informationRecherche.getRechercheLibre() + " ");
127
		}
131
		}
128
		if (informationRecherche.getTaxon() != null && !informationRecherche.getTaxon().equals("")) {
132
		if (informationRecherche.getTaxon() != null && !informationRecherche.getTaxon().equals("")) {
129
			texteRecherchePrecedente.append(I18n.getVocabulary().taxon() + ":" + informationRecherche.getTaxon() + " ");
133
			texteRecherchePrecedente.append(I18n.getVocabulary().taxon() + ":" + informationRecherche.getTaxon() + " ");
130
		}
134
		}
131
		if (informationRecherche.getDepartement() != null && !informationRecherche.getDepartement().equals("")) {
135
		if (informationRecherche.getDepartement() != null && !informationRecherche.getDepartement().equals("")) {
132
			texteRecherchePrecedente.append(I18n.getVocabulary().departement() + ":" + informationRecherche.getDepartement() + " ");
136
			texteRecherchePrecedente.append(I18n.getVocabulary().departement() + ":" + informationRecherche.getDepartement() + " ");
133
		}
137
		}
134
		if (informationRecherche.getCommune() != null && !informationRecherche.getCommune().equals("")) {
138
		if (informationRecherche.getCommune() != null && !informationRecherche.getCommune().equals("")) {
135
			texteRecherchePrecedente.append(I18n.getVocabulary().commune() + ":" + informationRecherche.getCommune() + " ");
139
			texteRecherchePrecedente.append(I18n.getVocabulary().commune() + ":" + informationRecherche.getCommune() + " ");
136
		}
140
		}
137
		if (informationRecherche.getFamille() != null && !informationRecherche.getFamille().equals("")) {
141
		if (informationRecherche.getFamille() != null && !informationRecherche.getFamille().equals("")) {
138
			texteRecherchePrecedente.append(I18n.getVocabulary().famille() + ":" + informationRecherche.getFamille() + " ");
142
			texteRecherchePrecedente.append(I18n.getVocabulary().famille() + ":" + informationRecherche.getFamille() + " ");
139
		}
143
		}
140
		if (informationRecherche.getGenre() != null && !informationRecherche.getGenre().equals("")) {
144
		if (informationRecherche.getGenre() != null && !informationRecherche.getGenre().equals("")) {
141
			texteRecherchePrecedente.append(I18n.getVocabulary().genre() + ":" + informationRecherche.getGenre() + " ");
145
			texteRecherchePrecedente.append(I18n.getVocabulary().genre() + ":" + informationRecherche.getGenre() + " ");
142
		}
146
		}
143
		if (informationRecherche.getTag() != null && !informationRecherche.getTag().equals("")) {
147
		if (informationRecherche.getTag() != null && !informationRecherche.getTag().equals("")) {
144
			texteRecherchePrecedente.append(I18n.getVocabulary().tag() + ":" + informationRecherche.getTag() + " ");
148
			texteRecherchePrecedente.append(I18n.getVocabulary().tag() + ":" + informationRecherche.getTag() + " ");
145
		}
149
		}
146
		if (informationRecherche.getMotClef() != null && !informationRecherche.getMotClef().equals("")) {
150
		if (informationRecherche.getMotClef() != null && !informationRecherche.getMotClef().equals("")) {
147
			texteRecherchePrecedente.append(I18n.getVocabulary().mot_clef() + ":" + informationRecherche.getMotClef() + " ");
151
			texteRecherchePrecedente.append(I18n.getVocabulary().mot_clef() + ":" + informationRecherche.getMotClef() + " ");
148
		}
152
		}
149
		if (informationRecherche.getAuteur() != null && !informationRecherche.getAuteur().equals("")) {
153
		if (informationRecherche.getAuteur() != null && !informationRecherche.getAuteur().equals("")) {
150
			texteRecherchePrecedente.append(I18n.getVocabulary().auteur() + ":" + informationRecherche.getAuteur() + " ");
154
			texteRecherchePrecedente.append(I18n.getVocabulary().auteur() + ":" + informationRecherche.getAuteur() + " ");
151
		}
155
		}
152
		if (informationRecherche.getDate() != null && !informationRecherche.getDate().equals("")) {
156
		if (informationRecherche.getDate() != null && !informationRecherche.getDate().equals("")) {
153
			texteRecherchePrecedente.append(I18n.getVocabulary().date() + ":" + informationRecherche.getDate() + " ");
157
			texteRecherchePrecedente.append(I18n.getVocabulary().date() + ":" + informationRecherche.getDate() + " ");
154
		}
158
		}
155
 
159
 
156
		recherchePrecedente.setText(texteRecherchePrecedente.toString());
160
		recherchePrecedente.setText(texteRecherchePrecedente.toString());
157
	}
161
	}
158
 
162
 
159
	public void nettoyer() {
163
	public void nettoyer() {
160
		chargerValeursRecherchePrecedente(new InformationsRecherche());
164
		chargerValeursRecherchePrecedente(new InformationsRecherche());
161
	}
165
	}
162
 
166
 
163
	public String getRecherchePrincipale() {
167
	public String getRecherchePrincipale() {
164
		return recherchePrincipale.getText();
168
		return recherchePrincipale.getText();
165
	}
169
	}
166
 
170
 
167
	public String getDepartement() {
171
	public String getDepartement() {
168
		return departement.getText();
172
		return departement.getText();
169
	}
173
	}
170
 
174
 
171
	public String getCommune() {
175
	public HasWidgets getCommune() {
172
		return commune.getText();
176
		return commune;
173
	}
177
	}
174
 
178
 
175
	public HasWidgets getTaxon() {
179
	public HasWidgets getTaxon() {
176
		return taxon;
180
		return taxon;
177
	}
181
	}
178
 
182
 
179
	public String getFamille() {
183
	public String getFamille() {
180
		return famille.getText();
184
		return famille.getText();
181
	}
185
	}
182
 
186
 
183
	public String getGenre() {
187
	public String getGenre() {
184
		return genre.getText();
188
		return genre.getText();
185
	}
189
	}
186
 
190
 
187
	public String getTag() {
191
	public String getTag() {
188
		return tag.getText();
192
		return tag.getText();
189
	}
193
	}
190
 
194
 
191
	public String getMotCle() {
195
	public String getMotCle() {
192
		return motCle.getText();
196
		return motCle.getText();
193
	}
197
	}
194
 
198
 
195
	public String getAuteur() {
199
	public String getAuteur() {
196
		return auteur.getText();
200
		return auteur.getText();
197
	}
201
	}
198
 
202
 
199
	public String getDate() {
203
	public String getDate() {
200
		return date.getText();
204
		return date.getText();
201
	}
205
	}
202
 
206
 
203
	public void focusSaisie() {
207
	public void focusSaisie() {
204
		this.recherchePrincipale.setFocus(true);
208
		this.recherchePrincipale.setFocus(true);
205
	}
209
	}
206
 
210
 
207
	@Override
211
	@Override
208
	public void ajouterVue(HasWidgets composite) {
212
	public void ajouterVue(HasWidgets composite) {
209
		composite.add(this.asWidget());
213
		composite.add(this.asWidget());
210
	}
214
	}
211
}
215
}