Subversion Repositories eFlore/Applications.del

Rev

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

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