Subversion Repositories eFlore/Applications.del

Rev

Rev 1986 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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