Subversion Repositories eFlore/Applications.del

Rev

Rev 1120 | Rev 1426 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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