Subversion Repositories eFlore/Applications.del

Rev

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

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