Subversion Repositories eFlore/Applications.del

Rev

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

Rev 1426 Rev 1886
1
package org.tela_botanica.del.client.composants.moteurrecherche;
1
package org.tela_botanica.del.client.composants.moteurrecherche;
2
 
2
 
3
import java.util.Map;
3
import java.util.Map;
4
 
4
 
5
import org.tela_botanica.del.client.cache.CacheClient;
5
import org.tela_botanica.del.client.cache.CacheClient;
6
import org.tela_botanica.del.client.composants.formulaires.autocompletion.AutoCompletionComboBoxPresenteur;
6
import org.tela_botanica.del.client.composants.formulaires.autocompletion.AutoCompletionComboBoxPresenteur;
7
import org.tela_botanica.del.client.composants.formulaires.autocompletion.AutoCompletionComboBoxVue;
7
import org.tela_botanica.del.client.composants.formulaires.autocompletion.AutoCompletionComboBoxVue;
8
import org.tela_botanica.del.client.composants.presenteur.Presenteur;
8
import org.tela_botanica.del.client.composants.presenteur.Presenteur;
9
import org.tela_botanica.del.client.composants.rss.RssPresenteur;
9
import org.tela_botanica.del.client.composants.rss.RssPresenteur;
10
import org.tela_botanica.del.client.composants.rss.RssVue;
10
import org.tela_botanica.del.client.composants.rss.RssVue;
11
import org.tela_botanica.del.client.config.Config;
11
import org.tela_botanica.del.client.config.Config;
12
import org.tela_botanica.del.client.modeles.InformationsRecherche;
12
import org.tela_botanica.del.client.modeles.InformationsRecherche;
13
import org.tela_botanica.del.client.modeles.ModeRecherche;
13
import org.tela_botanica.del.client.modeles.ModeRecherche;
14
import org.tela_botanica.del.client.services.ReferentielService;
14
import org.tela_botanica.del.client.services.ReferentielService;
-
 
15
import org.tela_botanica.del.client.utils.InfosNomPourAutocompletion;
15
import org.tela_botanica.del.client.utils.UtilitairesAutoCompletionService;
16
import org.tela_botanica.del.client.utils.UtilitairesAutoCompletionService;
16
 
17
 
17
import com.google.gwt.event.dom.client.ClickEvent;
18
import com.google.gwt.event.dom.client.ClickEvent;
18
import com.google.gwt.event.dom.client.ClickHandler;
19
import com.google.gwt.event.dom.client.ClickHandler;
19
import com.google.gwt.event.dom.client.HasClickHandlers;
20
import com.google.gwt.event.dom.client.HasClickHandlers;
20
import com.google.gwt.event.dom.client.HasKeyPressHandlers;
21
import com.google.gwt.event.dom.client.HasKeyPressHandlers;
21
import com.google.gwt.event.dom.client.KeyCodes;
22
import com.google.gwt.event.dom.client.KeyCodes;
22
import com.google.gwt.event.dom.client.KeyPressEvent;
23
import com.google.gwt.event.dom.client.KeyPressEvent;
23
import com.google.gwt.event.dom.client.KeyPressHandler;
24
import com.google.gwt.event.dom.client.KeyPressHandler;
24
import com.google.gwt.http.client.Response;
25
import com.google.gwt.http.client.Response;
25
import com.google.gwt.user.client.ui.HasWidgets;
26
import com.google.gwt.user.client.ui.HasWidgets;
26
import com.google.gwt.user.client.ui.IsWidget;
27
import com.google.gwt.user.client.ui.IsWidget;
27
 
28
 
28
public abstract class MoteurRecherchePresenteur extends Presenteur {
29
public abstract class MoteurRecherchePresenteur extends Presenteur {
29
 
30
 
30
	public abstract interface Vue extends IsWidget {
31
	public abstract interface Vue extends IsWidget {
31
		public void ajouterVue(HasWidgets composite);
32
		public void ajouterVue(HasWidgets composite);
32
 
33
 
33
		public HasClickHandlers getLienRechercheAvancee();
34
		public HasClickHandlers getLienRechercheAvancee();
34
 
35
 
35
		public void basculerAffichageZoneCache();
36
		public void basculerAffichageZoneCache();
36
 
37
 
37
		public HasClickHandlers getBoutonRechercheSimple();
38
		public HasClickHandlers getBoutonRechercheSimple();
38
 
39
 
39
		public HasClickHandlers getBoutonFermer();
40
		public HasClickHandlers getBoutonFermer();
40
 
41
 
41
		public HasClickHandlers getBoutonVider();
42
		public HasClickHandlers getBoutonVider();
42
 
43
 
43
		public HasClickHandlers getBoutonRechercheAvancee();
44
		public HasClickHandlers getBoutonRechercheAvancee();
44
 
45
 
45
		public HasKeyPressHandlers getChampSaisie();
46
		public HasKeyPressHandlers getChampSaisie();
46
 
47
 
47
		public HasClickHandlers getChampSaisieCliquable();
48
		public HasClickHandlers getChampSaisieCliquable();
48
 
49
 
49
		public String getValeurRechercheSimple();
50
		public String getValeurRechercheSimple();
50
 
51
 
51
		public String getLabelRecherche();
52
		public String getLabelRecherche();
52
 
53
 
53
		public String getContientMots();
54
		public String getContientMots();
54
 
55
 
55
		public String getDepartement();
56
		public String getDepartement();
56
 
57
 
57
		public HasWidgets getCommune();
58
		public HasWidgets getCommune();
58
 
59
 
59
		public HasWidgets getTaxon();
60
		public HasWidgets getTaxon();
60
 
61
 
61
		public String getFamille();
62
		public String getFamille();
62
 
63
 
63
		public String getGenre();
64
		public String getGenre();
64
 
65
 
65
		public String getMotCle();
66
		public String getMotCle();
66
 
67
 
67
		public String getAuteur();
68
		public String getAuteur();
68
 
69
 
69
		public String getDate();
70
		public String getDate();
70
 
71
 
71
		public void setValeurRechercheSimple(String valeurRecherche);
72
		public void setValeurRechercheSimple(String valeurRecherche);
72
 
73
 
73
		public void setContientMots(String mots);
74
		public void setContientMots(String mots);
74
 
75
 
75
		public void setValeurDepartement(String dpt);
76
		public void setValeurDepartement(String dpt);
76
 
77
 
77
		public void chargerValeursRecherchePrecedente(InformationsRecherche informationsRecherche);
78
		public void chargerValeursRecherchePrecedente(InformationsRecherche informationsRecherche);
78
 
79
 
79
		public void focusSaisie();
80
		public void focusSaisie();
80
 
81
 
81
		public void nettoyer();
82
		public void nettoyer();
82
 
83
 
83
		public HasKeyPressHandlers getChampsFamille();
84
		public HasKeyPressHandlers getChampsFamille();
84
 
85
 
85
		public HasKeyPressHandlers getChampsGenre();
86
		public HasKeyPressHandlers getChampsGenre();
86
 
87
 
87
		public HasKeyPressHandlers getChampsMotCle();
88
		public HasKeyPressHandlers getChampsMotCle();
88
		
89
		
89
		public HasKeyPressHandlers getChampsMotCleDel();
90
		public HasKeyPressHandlers getChampsMotCleDel();
90
		
91
		
91
		public HasKeyPressHandlers getChampsMotCleCel();
92
		public HasKeyPressHandlers getChampsMotCleCel();
92
 
93
 
93
		public HasKeyPressHandlers getChampsAuteur();
94
		public HasKeyPressHandlers getChampsAuteur();
94
 
95
 
95
		public HasKeyPressHandlers getChampsDate();
96
		public HasKeyPressHandlers getChampsDate();
96
		
97
		
97
		public HasKeyPressHandlers getChampsDepartement();
98
		public HasKeyPressHandlers getChampsDepartement();
98
		
99
		
99
		public HasKeyPressHandlers getChampsContientMots();
100
		public HasKeyPressHandlers getChampsContientMots();
100
		
101
		
101
		public HasWidgets getZoneRss();
102
		public HasWidgets getZoneRss();
102
 
103
 
103
		public String getReferentiel();
104
		public String getReferentiel();
104
		
105
		
105
		public void setReferentielLectureSeule(boolean lectureSeule);
106
		public void setReferentielLectureSeule(boolean lectureSeule);
106
 
107
 
107
		void remplirListeReferentiels(Map<String, String> listeReferentiels);
108
		void remplirListeReferentiels(Map<String, String> listeReferentiels);
108
 
109
 
109
		public String getMotCleDel();
110
		public String getMotCleDel();
110
 
111
 
111
		public String getMotCleCel();
112
		public String getMotCleCel();
112
		
113
		
113
		public void cacherChampsTagsImage();
114
		public void cacherChampsTagsImage();
114
		public void cacherChampsTagsObs();
115
		public void cacherChampsTagsObs();
115
 
116
 
116
	}
117
	}
117
 
118
 
118
	private Vue vue;
119
	private Vue vue;
119
	private Config config;
120
	private Config config;
120
	private ModeRecherche modeRecherche;
121
	private ModeRecherche modeRecherche;
121
	private RssPresenteur presenteurRss;
122
	private RssPresenteur presenteurRss;
122
	
123
	
123
	public enum TypeMoteur {
124
	public enum TypeMoteur {
124
		SIMPLE, AVANCEE
125
		SIMPLE, AVANCEE
125
	};
126
	};
126
 
127
 
127
	private TypeMoteur typeMoteur = TypeMoteur.SIMPLE;
128
	private TypeMoteur typeMoteur = TypeMoteur.SIMPLE;
128
 
129
 
129
	private AutoCompletionComboBoxPresenteur completionTaxonsPresenteur = null;
130
	private AutoCompletionComboBoxPresenteur completionTaxonsPresenteur = null;
130
	private AutoCompletionComboBoxPresenteur completionCommunesPresenteur = null;
131
	private AutoCompletionComboBoxPresenteur completionCommunesPresenteur = null;
131
 
132
 
132
	public MoteurRecherchePresenteur(Vue vue, ModeRecherche mode) {
133
	public MoteurRecherchePresenteur(Vue vue, ModeRecherche mode) {
133
		initialiser(vue, mode, new Config());
134
		initialiser(vue, mode, new Config());
134
	}
135
	}
135
 
136
 
136
	public MoteurRecherchePresenteur(AutoCompletionComboBoxPresenteur presenteurAutoCompletionTaxon, AutoCompletionComboBoxPresenteur presenteurAutoCompletionCommunes, Vue vue, ModeRecherche mode, Config configuration) {
137
	public MoteurRecherchePresenteur(AutoCompletionComboBoxPresenteur presenteurAutoCompletionTaxon, AutoCompletionComboBoxPresenteur presenteurAutoCompletionCommunes, Vue vue, ModeRecherche mode, Config configuration) {
137
		completionTaxonsPresenteur = presenteurAutoCompletionTaxon;
138
		completionTaxonsPresenteur = presenteurAutoCompletionTaxon;
138
		completionCommunesPresenteur = presenteurAutoCompletionCommunes;
139
		completionCommunesPresenteur = presenteurAutoCompletionCommunes;
139
		initialiser(vue, mode, configuration);
140
		initialiser(vue, mode, configuration);
140
	}
141
	}
141
 
142
 
142
	private void initialiser(Vue vue, ModeRecherche mode, Config configuration) {
143
	private void initialiser(Vue vue, ModeRecherche mode, Config configuration) {
143
		
144
		
144
		//TODO : fixer le flux avant de le mettre en place
145
		//TODO : fixer le flux avant de le mettre en place
145
		//this.presenteurRss = new RssPresenteur(new RssVue(), CacheClient.getInstance().getInformationsRechercheObservation(), "S'abonner au flux rss des résultats de cette recherche");
146
		//this.presenteurRss = new RssPresenteur(new RssVue(), CacheClient.getInstance().getInformationsRechercheObservation(), "S'abonner au flux rss des résultats de cette recherche");
146
		//presenteurRss.go(vue.getZoneRss());
147
		//presenteurRss.go(vue.getZoneRss());
147
		
148
		
148
		this.vue = vue;
149
		this.vue = vue;
149
		setMode(mode);
150
		setMode(mode);
150
		this.config = configuration;
151
		this.config = configuration;
151
		if (completionTaxonsPresenteur == null)
152
		if (completionTaxonsPresenteur == null)
152
			this.creerCompletionTaxons();
153
			this.creerCompletionTaxons();
153
		if (completionCommunesPresenteur == null)
154
		if (completionCommunesPresenteur == null)
154
			this.creerCompletionCommunes();
155
			this.creerCompletionCommunes();
155
		gererEvenements();
156
		gererEvenements();
156
		
157
		
157
		vue.remplirListeReferentiels(ReferentielService.getReferentiels());
158
		vue.remplirListeReferentiels(ReferentielService.getReferentiels());
158
		if(CacheClient.getInstance().getReferentielNonModifiable()) {
159
		if(CacheClient.getInstance().getReferentielNonModifiable()) {
159
			vue.setReferentielLectureSeule(true);
160
			vue.setReferentielLectureSeule(true);
160
		}
161
		}
161
		
162
		
162
		if(estPourRechercheImages()) {
163
		if(estPourRechercheImages()) {
163
			vue.cacherChampsTagsObs();
164
			vue.cacherChampsTagsObs();
164
		} else {
165
		} else {
165
			vue.cacherChampsTagsImage();
166
			vue.cacherChampsTagsImage();
166
		}
167
		}
167
	}
168
	}
168
 
169
 
169
	public ModeRecherche getMode() {
170
	public ModeRecherche getMode() {
170
		return modeRecherche;
171
		return modeRecherche;
171
	}
172
	}
172
 
173
 
173
	private void setMode(ModeRecherche mode) {
174
	private void setMode(ModeRecherche mode) {
174
		modeRecherche = mode;
175
		modeRecherche = mode;
175
	}
176
	}
176
	
177
	
177
	public TypeMoteur getTypeMoteur() {
178
	public TypeMoteur getTypeMoteur() {
178
		return this.typeMoteur;
179
		return this.typeMoteur;
179
	}
180
	}
180
	
181
	
181
	public void setTypeMoteur(TypeMoteur typeMoteur) {
182
	public void setTypeMoteur(TypeMoteur typeMoteur) {
182
		this.typeMoteur = typeMoteur;
183
		this.typeMoteur = typeMoteur;
183
	}
184
	}
184
 
185
 
185
	public boolean estPourRechercheImages() {
186
	public boolean estPourRechercheImages() {
186
		return (modeRecherche == ModeRecherche.MODE_IMAGE);
187
		return (modeRecherche == ModeRecherche.MODE_IMAGE);
187
	}
188
	}
188
 
189
 
189
	public boolean estPourRechercheObservations() {
190
	public boolean estPourRechercheObservations() {
190
		return (modeRecherche == ModeRecherche.MODE_OBSERVATION);
191
		return (modeRecherche == ModeRecherche.MODE_OBSERVATION);
191
	}
192
	}
192
 
193
 
193
	private void creerCompletionTaxons() {
194
	private void creerCompletionTaxons() {
194
		String url = this.config.getServiceBaseUrl() + "nomstaxons";
195
		String url = this.config.getServiceBaseUrl() + "nomstaxons";
195
		completionTaxonsPresenteur = new AutoCompletionComboBoxPresenteur(new AutoCompletionComboBoxVue(), url) {
196
		completionTaxonsPresenteur = new AutoCompletionComboBoxPresenteur(new AutoCompletionComboBoxVue(), url) {
196
			protected String effectuerPreTraitementChaineRequete(String requete) {
197
			protected String effectuerPreTraitementChaineRequete(String requete) {
197
				// si aucun référentiel selectionné, pas de requete
198
				// si aucun référentiel selectionné, pas de requete
198
				if(vue.getReferentiel() != null && !vue.getReferentiel().equals("")) {
199
				if(vue.getReferentiel() != null && !vue.getReferentiel().equals("")) {
199
					requete = "?masque.nom=" + requete + "&masque.referentiel=" + vue.getReferentiel();
200
					requete = "?masque.nom=" + requete + "&masque.referentiel=" + vue.getReferentiel();
200
					return requete;
201
					return requete;
201
				} else {
202
				} else {
202
					return null;
203
					return null;
203
				}
204
				}
204
				// A décommenter lors de l'utilisation des web services eflore
205
				// A décommenter lors de l'utilisation des web services eflore
205
				// return
206
				// return
206
				// RetourAutoCompletionService.effectuerPreTraitementChaineRequeteGenreEspeceEflore(requete);
207
				// RetourAutoCompletionService.effectuerPreTraitementChaineRequeteGenreEspeceEflore(requete);
207
			}
208
			}
208
 
209
 
209
			@Override
210
			@Override
210
			protected String[] parserResultatRequete(Response response) {
211
			protected InfosNomPourAutocompletion[] parserResultatRequete(Response response) {
211
				return UtilitairesAutoCompletionService.parserResultatRetourSimple(response);
212
				return UtilitairesAutoCompletionService.parserResultatRetourSimple(response);
212
				// A décommenter lors de l'utilisation des web services eflore
213
				// A décommenter lors de l'utilisation des web services eflore
213
				// return RetourAutoCompletionService.parserRetourOss(response);
214
				// return RetourAutoCompletionService.parserRetourOss(response);
214
			}
215
			}
215
		};
216
		};
216
	}
217
	}
217
 
218
 
218
	private void creerCompletionCommunes() {
219
	private void creerCompletionCommunes() {
219
		String url = this.config.getServiceBaseUrl() + "communes";
220
		String url = this.config.getServiceBaseUrl() + "communes";
220
		completionCommunesPresenteur = new AutoCompletionComboBoxPresenteur(new AutoCompletionComboBoxVue(), url) {
221
		completionCommunesPresenteur = new AutoCompletionComboBoxPresenteur(new AutoCompletionComboBoxVue(), url) {
221
			protected String effectuerPreTraitementChaineRequete(String requete) {
222
			protected String effectuerPreTraitementChaineRequete(String requete) {
222
				requete = "?masque.nom=" + requete;
223
				requete = "?masque.nom=" + requete;
223
				return requete;
224
				return requete;
224
			}
225
			}
225
 
226
 
226
			@Override
227
			@Override
227
			protected void surSelectionSuggestion(String suggestion) {
228
			protected void surSelectionSuggestion(String suggestion) {
228
				setValeur(suggestion);
229
				setValeur(suggestion);
229
				collecterInfosRecherche();
230
				collecterInfosRecherche();
230
				setValeur(getInformationsRechercheEnCache().getCommune());
231
				setValeur(getInformationsRechercheEnCache().getCommune());
231
				vue.setValeurDepartement(getInformationsRechercheEnCache().getDepartement());
232
				vue.setValeurDepartement(getInformationsRechercheEnCache().getDepartement());
232
			}
233
			}
233
 
234
 
234
			@Override
235
			@Override
235
			protected String[] parserResultatRequete(Response response) {
236
			protected InfosNomPourAutocompletion[] parserResultatRequete(Response response) {
236
				return UtilitairesAutoCompletionService.parserResultatRetourSimple(response);
237
				return UtilitairesAutoCompletionService.parserResultatRetourSimple(response);
237
			}
238
			}
238
		};
239
		};
239
	}
240
	}
240
 
241
 
241
	@Override
242
	@Override
242
	public void go(HasWidgets composite) {
243
	public void go(HasWidgets composite) {
243
		afficherRequeteEtLancerRecherche();
244
		afficherRequeteEtLancerRecherche();
244
		completionTaxonsPresenteur.go(vue.getTaxon());
245
		completionTaxonsPresenteur.go(vue.getTaxon());
245
		completionCommunesPresenteur.go(vue.getCommune());
246
		completionCommunesPresenteur.go(vue.getCommune());
246
		vue.ajouterVue(composite);
247
		vue.ajouterVue(composite);
247
		vue.focusSaisie();
248
		vue.focusSaisie();
248
	}
249
	}
249
 
250
 
250
	@Override
251
	@Override
251
	protected void gererEvenements() {
252
	protected void gererEvenements() {
252
		vue.getLienRechercheAvancee().addClickHandler(new ClickHandler() {
253
		vue.getLienRechercheAvancee().addClickHandler(new ClickHandler() {
253
			public void onClick(ClickEvent event) {
254
			public void onClick(ClickEvent event) {
254
				setTypeMoteur(TypeMoteur.AVANCEE);
255
				setTypeMoteur(TypeMoteur.AVANCEE);
255
				vue.setContientMots(vue.getValeurRechercheSimple());
256
				vue.setContientMots(vue.getValeurRechercheSimple());
256
				vue.basculerAffichageZoneCache();
257
				vue.basculerAffichageZoneCache();
257
			}
258
			}
258
		});
259
		});
259
 
260
 
260
		vue.getBoutonRechercheSimple().addClickHandler(new ClickHandler() {
261
		vue.getBoutonRechercheSimple().addClickHandler(new ClickHandler() {
261
			public void onClick(ClickEvent event) {
262
			public void onClick(ClickEvent event) {
262
				setTypeMoteur(TypeMoteur.SIMPLE);
263
				setTypeMoteur(TypeMoteur.SIMPLE);
263
				collecterInfosRecherche();
264
				collecterInfosRecherche();
264
				afficherRequeteEtLancerRecherche();
265
				afficherRequeteEtLancerRecherche();
265
			}
266
			}
266
		});
267
		});
267
 
268
 
268
		vue.getBoutonFermer().addClickHandler(new ClickHandler() {
269
		vue.getBoutonFermer().addClickHandler(new ClickHandler() {
269
			public void onClick(ClickEvent event) {
270
			public void onClick(ClickEvent event) {
270
				vue.setValeurRechercheSimple(vue.getContientMots());
271
				vue.setValeurRechercheSimple(vue.getContientMots());
271
				vue.basculerAffichageZoneCache();
272
				vue.basculerAffichageZoneCache();
272
			}
273
			}
273
		});
274
		});
274
 
275
 
275
		vue.getBoutonVider().addClickHandler(new ClickHandler() {
276
		vue.getBoutonVider().addClickHandler(new ClickHandler() {
276
			public void onClick(ClickEvent event) {
277
			public void onClick(ClickEvent event) {
277
				nettoyerChamps();
278
				nettoyerChamps();
278
				InformationsRecherche infosRecherche = new InformationsRecherche();
279
				InformationsRecherche infosRecherche = new InformationsRecherche();
279
				if (estPourRechercheImages()) {
280
				if (estPourRechercheImages()) {
280
					CacheClient.getInstance().setInformationsRechercheImage(infosRecherche);
281
					CacheClient.getInstance().setInformationsRechercheImage(infosRecherche);
281
				} else if (estPourRechercheObservations()) {
282
				} else if (estPourRechercheObservations()) {
282
					CacheClient.getInstance().setInformationsRechercheObservation(infosRecherche);
283
					CacheClient.getInstance().setInformationsRechercheObservation(infosRecherche);
283
				}
284
				}
284
			}
285
			}
285
		});
286
		});
286
 
287
 
287
		vue.getBoutonRechercheAvancee().addClickHandler(new ClickHandler() {
288
		vue.getBoutonRechercheAvancee().addClickHandler(new ClickHandler() {
288
			public void onClick(ClickEvent event) {
289
			public void onClick(ClickEvent event) {
289
				setTypeMoteur(TypeMoteur.AVANCEE);
290
				setTypeMoteur(TypeMoteur.AVANCEE);
290
				collecterInfosRecherche();
291
				collecterInfosRecherche();
291
				vue.basculerAffichageZoneCache();
292
				vue.basculerAffichageZoneCache();
292
				afficherRequeteEtLancerRecherche();
293
				afficherRequeteEtLancerRecherche();
293
			}
294
			}
294
		});
295
		});
295
 
296
 
296
		vue.getChampSaisie().addKeyPressHandler(new KeyPressHandler() {
297
		vue.getChampSaisie().addKeyPressHandler(new KeyPressHandler() {
297
			public void onKeyPress(KeyPressEvent event) {
298
			public void onKeyPress(KeyPressEvent event) {
298
				if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
299
				if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
299
					setTypeMoteur(TypeMoteur.SIMPLE);
300
					setTypeMoteur(TypeMoteur.SIMPLE);
300
					collecterInfosRecherche();
301
					collecterInfosRecherche();
301
					afficherRequeteEtLancerRecherche();
302
					afficherRequeteEtLancerRecherche();
302
				}
303
				}
303
			}
304
			}
304
		});
305
		});
305
 
306
 
306
		vue.getChampSaisieCliquable().addClickHandler(new ClickHandler() {
307
		vue.getChampSaisieCliquable().addClickHandler(new ClickHandler() {
307
			public void onClick(ClickEvent event) {
308
			public void onClick(ClickEvent event) {
308
				if (vue.getValeurRechercheSimple().equals(vue.getLabelRecherche())) {
309
				if (vue.getValeurRechercheSimple().equals(vue.getLabelRecherche())) {
309
					vue.setValeurRechercheSimple("");
310
					vue.setValeurRechercheSimple("");
310
				}
311
				}
311
			}
312
			}
312
		});
313
		});
313
 
314
 
314
		vue.getChampsAuteur().addKeyPressHandler(creerGestionnaireEvenementToucheEntree());
315
		vue.getChampsAuteur().addKeyPressHandler(creerGestionnaireEvenementToucheEntree());
315
		vue.getChampsDate().addKeyPressHandler(creerGestionnaireEvenementToucheEntree());
316
		vue.getChampsDate().addKeyPressHandler(creerGestionnaireEvenementToucheEntree());
316
		vue.getChampsFamille().addKeyPressHandler(creerGestionnaireEvenementToucheEntree());
317
		vue.getChampsFamille().addKeyPressHandler(creerGestionnaireEvenementToucheEntree());
317
		vue.getChampsGenre().addKeyPressHandler(creerGestionnaireEvenementToucheEntree());
318
		vue.getChampsGenre().addKeyPressHandler(creerGestionnaireEvenementToucheEntree());
318
		vue.getChampsMotCle().addKeyPressHandler(creerGestionnaireEvenementToucheEntree());
319
		vue.getChampsMotCle().addKeyPressHandler(creerGestionnaireEvenementToucheEntree());
319
		vue.getChampsMotCleCel().addKeyPressHandler(creerGestionnaireEvenementToucheEntree());
320
		vue.getChampsMotCleCel().addKeyPressHandler(creerGestionnaireEvenementToucheEntree());
320
		vue.getChampsMotCleDel().addKeyPressHandler(creerGestionnaireEvenementToucheEntree());
321
		vue.getChampsMotCleDel().addKeyPressHandler(creerGestionnaireEvenementToucheEntree());
321
		vue.getChampsDepartement().addKeyPressHandler(creerGestionnaireEvenementToucheEntree());
322
		vue.getChampsDepartement().addKeyPressHandler(creerGestionnaireEvenementToucheEntree());
322
		vue.getChampsContientMots().addKeyPressHandler(creerGestionnaireEvenementToucheEntree());
323
		vue.getChampsContientMots().addKeyPressHandler(creerGestionnaireEvenementToucheEntree());
323
 
324
 
324
	}
325
	}
325
 
326
 
326
	public KeyPressHandler creerGestionnaireEvenementToucheEntree() {
327
	public KeyPressHandler creerGestionnaireEvenementToucheEntree() {
327
		return new KeyPressHandler() {
328
		return new KeyPressHandler() {
328
			public void onKeyPress(KeyPressEvent event) {
329
			public void onKeyPress(KeyPressEvent event) {
329
				if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
330
				if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
330
					vue.basculerAffichageZoneCache();
331
					vue.basculerAffichageZoneCache();
331
					collecterInfosRecherche();
332
					collecterInfosRecherche();
332
					afficherRequeteEtLancerRecherche();
333
					afficherRequeteEtLancerRecherche();
333
				}
334
				}
334
			}
335
			}
335
		};
336
		};
336
	}
337
	}
337
 
338
 
338
	private void nettoyerChamps() {
339
	private void nettoyerChamps() {
339
		completionCommunesPresenteur.nettoyer();
340
		completionCommunesPresenteur.nettoyer();
340
		completionTaxonsPresenteur.nettoyer();
341
		completionTaxonsPresenteur.nettoyer();
341
		vue.nettoyer();
342
		vue.nettoyer();
342
	}
343
	}
343
 
344
 
344
	public void collecterInfosRecherche() {
345
	public void collecterInfosRecherche() {
345
		InformationsRecherche informationRecherche = new InformationsRecherche();
346
		InformationsRecherche informationRecherche = new InformationsRecherche();
346
		informationRecherche.setRechercheLibre(this.getRechercheLibre());
347
		informationRecherche.setRechercheLibre(this.getRechercheLibre());
347
		if (this.typeMoteur == TypeMoteur.AVANCEE) {
348
		if (this.typeMoteur == TypeMoteur.AVANCEE) {
348
			informationRecherche.setTaxon(completionTaxonsPresenteur.getValeur());
349
			informationRecherche.setTaxon(completionTaxonsPresenteur.getValeur());
349
			informationRecherche.setDepartement(vue.getDepartement());
350
			informationRecherche.setDepartement(vue.getDepartement());
350
			informationRecherche.setCommune(completionCommunesPresenteur.getValeur());
351
			informationRecherche.setCommune(completionCommunesPresenteur.getValeur());
351
			informationRecherche.setFamille(vue.getFamille());
352
			informationRecherche.setFamille(vue.getFamille());
352
			informationRecherche.setGenre(vue.getGenre());
353
			informationRecherche.setGenre(vue.getGenre());
353
			if(estPourRechercheObservations()) {
354
			if(estPourRechercheObservations()) {
354
				informationRecherche.setMotClef(vue.getMotCle());
355
				informationRecherche.setMotClef(vue.getMotCle());
355
			} else {
356
			} else {
356
				informationRecherche.setMotClefDel(vue.getMotCleDel());
357
				informationRecherche.setMotClefDel(vue.getMotCleDel());
357
				informationRecherche.setMotClefCel(vue.getMotCleCel());
358
				informationRecherche.setMotClefCel(vue.getMotCleCel());
358
			}
359
			}
359
			informationRecherche.setTag(vue.getMotCle());
360
			informationRecherche.setTag(vue.getMotCle());
360
			informationRecherche.setAuteur(vue.getAuteur());
361
			informationRecherche.setAuteur(vue.getAuteur());
361
			informationRecherche.setDate(vue.getDate());
362
			informationRecherche.setDate(vue.getDate());
362
			informationRecherche.setReferentiel(vue.getReferentiel());
363
			informationRecherche.setReferentiel(vue.getReferentiel());
363
		}
364
		}
364
		
365
		
365
		if(CacheClient.getInstance().getReferentielNonModifiable()) {
366
		if(CacheClient.getInstance().getReferentielNonModifiable()) {
366
			informationRecherche.setReferentiel(CacheClient.getInstance().getReferentielCourant());
367
			informationRecherche.setReferentiel(CacheClient.getInstance().getReferentielCourant());
367
		}
368
		}
368
 
369
 
369
		if (estPourRechercheImages()) {
370
		if (estPourRechercheImages()) {
370
			CacheClient.getInstance().setPageCouranteRechercheImages(1);
371
			CacheClient.getInstance().setPageCouranteRechercheImages(1);
371
			CacheClient.getInstance().setInformationsRechercheImage(informationRecherche);
372
			CacheClient.getInstance().setInformationsRechercheImage(informationRecherche);
372
		} else if (estPourRechercheObservations()) {
373
		} else if (estPourRechercheObservations()) {
373
			CacheClient.getInstance().setPageCouranteRechercheObservations(1);
374
			CacheClient.getInstance().setPageCouranteRechercheObservations(1);
374
			CacheClient.getInstance().setInformationsRechercheObservation(informationRecherche);
375
			CacheClient.getInstance().setInformationsRechercheObservation(informationRecherche);
375
		}
376
		}
376
	}
377
	}
377
 
378
 
378
	private String getRechercheLibre() {
379
	private String getRechercheLibre() {
379
		String rechercheLibre = "";
380
		String rechercheLibre = "";
380
		switch (this.typeMoteur) {
381
		switch (this.typeMoteur) {
381
		case SIMPLE:
382
		case SIMPLE:
382
			rechercheLibre = vue.getValeurRechercheSimple();
383
			rechercheLibre = vue.getValeurRechercheSimple();
383
			break;
384
			break;
384
		case AVANCEE:
385
		case AVANCEE:
385
			rechercheLibre = vue.getContientMots();
386
			rechercheLibre = vue.getContientMots();
386
			break;
387
			break;
387
		default:
388
		default:
388
			// TODO : voir comment gérer les exceptions proprement
389
			// TODO : voir comment gérer les exceptions proprement
389
			// throw new
390
			// throw new
390
			// Exception("Le type de moteur de recherche indiqué n'est pas disponible");
391
			// Exception("Le type de moteur de recherche indiqué n'est pas disponible");
391
		}
392
		}
392
		return rechercheLibre;
393
		return rechercheLibre;
393
	}
394
	}
394
 
395
 
395
	private InformationsRecherche getInformationsRechercheEnCache() {
396
	private InformationsRecherche getInformationsRechercheEnCache() {
396
		if (estPourRechercheImages()) {
397
		if (estPourRechercheImages()) {
397
			return CacheClient.getInstance().getInformationsRechercheImage();
398
			return CacheClient.getInstance().getInformationsRechercheImage();
398
		} else if (estPourRechercheObservations()) {
399
		} else if (estPourRechercheObservations()) {
399
			return CacheClient.getInstance().getInformationsRechercheObservation();
400
			return CacheClient.getInstance().getInformationsRechercheObservation();
400
		}
401
		}
401
		return null;
402
		return null;
402
	}
403
	}
403
 
404
 
404
	public void afficherRequeteEtLancerRecherche() {
405
	public void afficherRequeteEtLancerRecherche() {
405
		InformationsRecherche informationsRecherche = getInformationsRechercheEnCache();
406
		InformationsRecherche informationsRecherche = getInformationsRechercheEnCache();
406
		if (informationsRecherche != null) {
407
		if (informationsRecherche != null) {
407
			completionTaxonsPresenteur.setValeur(informationsRecherche.getTaxon());
408
			completionTaxonsPresenteur.setValeur(informationsRecherche.getTaxon());
408
			completionCommunesPresenteur.setValeur(informationsRecherche.getCommune());
409
			completionCommunesPresenteur.setValeur(informationsRecherche.getCommune());
409
			vue.chargerValeursRecherchePrecedente(informationsRecherche);
410
			vue.chargerValeursRecherchePrecedente(informationsRecherche);
410
		}
411
		}
411
		lancerRecherche();
412
		lancerRecherche();
412
		//presenteurRss.genererLien(informationsRecherche);
413
		//presenteurRss.genererLien(informationsRecherche);
413
	}
414
	}
414
 
415
 
415
	public abstract void lancerRecherche();
416
	public abstract void lancerRecherche();
416
}
417
}