Subversion Repositories eFlore/Applications.del

Rev

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

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