Subversion Repositories eFlore/Applications.del

Rev

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

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