Subversion Repositories eFlore/Applications.del

Rev

Rev 553 | Rev 581 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 553 Rev 560
Line 22... Line 22...
22
 
22
 
Line 23... Line 23...
23
public abstract class MoteurRecherchePresenteur extends Presenteur {
23
public abstract class MoteurRecherchePresenteur extends Presenteur {
24
 
24
 
-
 
25
	public abstract interface Vue extends IsWidget {
25
	public abstract interface Vue extends IsWidget {
26
		public void ajouterVue(HasWidgets composite);
-
 
27
 
26
		public void ajouterVue(HasWidgets composite);
28
		public HasClickHandlers getLienRechercheAvancee();
-
 
29
 
27
		public HasClickHandlers getLienRechercheAvancee();
30
		public void basculerAffichageZoneCache();
-
 
31
 
28
		public void basculerAffichageZoneCache();
32
		public HasClickHandlers getBoutonRechercheSimple();
-
 
33
 
29
		public HasClickHandlers getBoutonRechercheSimple();
34
		public HasClickHandlers getBoutonFermer();
-
 
35
 
30
		public HasClickHandlers getBoutonFermer();
36
		public HasClickHandlers getBoutonVider();
-
 
37
 
31
		public HasClickHandlers getBoutonVider();
38
		public HasClickHandlers getBoutonRechercheAvancee();
-
 
39
 
32
		public HasClickHandlers getBoutonRechercheAvancee();
40
		public HasKeyPressHandlers getChampSaisie();
-
 
41
 
33
		public HasKeyPressHandlers getChampSaisie();
42
		public HasClickHandlers getChampSaisieCliquable();
-
 
43
 
34
		public HasClickHandlers getChampSaisieCliquable();
44
		public String getValeurRechercheSimple();
-
 
45
 
35
		public String getValeurRechercheSimple();
46
		public String getLabelRecherche();
-
 
47
 
36
		public String getLabelRecherche();
48
		public String getContientMots();
-
 
49
 
37
		public String getContientMots();
50
		public String getDepartement();
-
 
51
 
38
		public String getDepartement();
52
		public HasWidgets getCommune();
-
 
53
 
39
		public HasWidgets getCommune();
54
		public HasWidgets getTaxon();
-
 
55
 
40
		public HasWidgets getTaxon();
56
		public String getFamille();
-
 
57
 
41
		public String getFamille();
58
		public String getGenre();
-
 
59
 
42
		public String getGenre();
60
		public String getTag();
-
 
61
 
43
		public String getTag();
62
		public String getMotCle();
-
 
63
 
44
		public String getMotCle();
64
		public String getAuteur();
-
 
65
 
45
		public String getAuteur();
66
		public String getDate();
-
 
67
 
46
		public String getDate();
68
		public void setValeurRechercheSimple(String valeurRecherche);
-
 
69
 
47
		public void setValeurRechercheSimple(String valeurRecherche);
70
		public void setContientMots(String mots);
-
 
71
 
48
		public void setContientMots(String mots);
72
		public void setValeurDepartement(String dpt);
-
 
73
 
49
		public void setValeurDepartement(String dpt);
74
		public void chargerValeursRecherchePrecedente(InformationsRecherche informationsRecherche);
-
 
75
 
50
		public void chargerValeursRecherchePrecedente(InformationsRecherche informationsRecherche);
76
		public void focusSaisie();
51
		public void focusSaisie();
77
 
Line 52... Line 78...
52
		public void nettoyer();
78
		public void nettoyer();
53
	}
79
	}
54
 
80
 
-
 
81
	private Vue vue;
55
	private Vue vue;
82
	private Config config;
-
 
83
	private ModeRecherche modeRecherche;
-
 
84
 
-
 
85
	public enum TypeMoteur {
56
	private Config config;
86
		SIMPLE, AVANCEE
Line 57... Line 87...
57
	private ModeRecherche modeRecherche;
87
	};
58
	public enum TypeMoteur {SIMPLE, AVANCEE};
88
 
59
	private TypeMoteur typeMoteur = TypeMoteur.SIMPLE;
89
	private TypeMoteur typeMoteur = TypeMoteur.SIMPLE;
60
 
90
 
61
	private AutoCompletionComboBoxPresenteur completionTaxonsPresenteur = null;
91
	private AutoCompletionComboBoxPresenteur completionTaxonsPresenteur = null;
62
	private AutoCompletionComboBoxPresenteur completionCommunesPresenteur = null;
92
	private AutoCompletionComboBoxPresenteur completionCommunesPresenteur = null;
63
	
93
 
64
	public MoteurRecherchePresenteur(Vue vue, ModeRecherche mode) {
94
	public MoteurRecherchePresenteur(Vue vue, ModeRecherche mode) {
65
		initialiser(vue, mode);
-
 
66
	}
-
 
67
	
95
		initialiser(vue, mode);
68
	public MoteurRecherchePresenteur(AutoCompletionComboBoxPresenteur presenteurAutoCompletionTaxon, 
96
	}
69
									AutoCompletionComboBoxPresenteur presenteurAutoCompletionCommunes,
97
 
70
									Vue vue, ModeRecherche mode) {
98
	public MoteurRecherchePresenteur(AutoCompletionComboBoxPresenteur presenteurAutoCompletionTaxon, AutoCompletionComboBoxPresenteur presenteurAutoCompletionCommunes, Vue vue, ModeRecherche mode) {
71
		completionTaxonsPresenteur = presenteurAutoCompletionTaxon;
99
		completionTaxonsPresenteur = presenteurAutoCompletionTaxon;
72
		completionCommunesPresenteur = presenteurAutoCompletionCommunes;
100
		completionCommunesPresenteur = presenteurAutoCompletionCommunes;
73
		initialiser(vue, mode);
101
		initialiser(vue, mode);
74
	}
102
	}
75
	
103
 
76
	private void initialiser(Vue vue, ModeRecherche mode) {
104
	private void initialiser(Vue vue, ModeRecherche mode) {
-
 
105
		this.vue = vue;
77
		this.vue = vue;
106
		setMode(mode);
-
 
107
		this.config = new Config();
78
		setMode(mode);
108
		if (completionTaxonsPresenteur == null)
79
		this.config = new Config();
109
			this.creerCompletionTaxons();
80
		if (completionTaxonsPresenteur == null) this.creerCompletionTaxons();
110
		if (completionCommunesPresenteur == null)
81
		if (completionCommunesPresenteur == null) this.creerCompletionCommunes();
111
			this.creerCompletionCommunes();
82
		gererEvenements();
112
		gererEvenements();
83
	}
113
	}
84
	
114
 
85
	private Vue getVue() {
115
	private Vue getVue() {
86
		return vue;
116
		return vue;
87
	}
117
	}
88
	
118
 
89
	public ModeRecherche getMode() {
119
	public ModeRecherche getMode() {
90
		return modeRecherche;
120
		return modeRecherche;
91
	}
121
	}
92
	
122
 
93
	private void setMode(ModeRecherche mode) {
123
	private void setMode(ModeRecherche mode) {
94
		modeRecherche = mode;
124
		modeRecherche = mode;
95
	}
125
	}
Line 96... Line 126...
96
	
126
 
97
	public void setTypeMoteur(TypeMoteur typeMoteur) {
127
	public void setTypeMoteur(TypeMoteur typeMoteur) {
98
		this.typeMoteur = typeMoteur;
128
		this.typeMoteur = typeMoteur;
Line 99... Line 129...
99
	}
129
	}
100
 
130
 
101
	public boolean estPourRechercheImages() {
131
	public boolean estPourRechercheImages() {
Line 102... Line 132...
102
		return (modeRecherche == ModeRecherche.MODE_IMAGE);
132
		return (modeRecherche == ModeRecherche.MODE_IMAGE);
103
	}
133
	}
104
 
134
 
105
	public boolean estPourRechercheObservations() {
135
	public boolean estPourRechercheObservations() {
Line 122... Line 152...
122
				// A décommenter lors de l'utilisation des web services eflore
152
				// A décommenter lors de l'utilisation des web services eflore
123
				// return RetourAutoCompletionService.parserRetourOss(response);
153
				// return RetourAutoCompletionService.parserRetourOss(response);
124
			}
154
			}
125
		};
155
		};
126
	}
156
	}
127
	
157
 
128
	private void creerCompletionCommunes() {
158
	private void creerCompletionCommunes() {
129
		String url = this.config.getUrl("communeCompletionService");
159
		String url = this.config.getUrl("communeCompletionService");
130
		completionCommunesPresenteur = new AutoCompletionComboBoxPresenteur(new AutoCompletionComboBoxVue(), url) {
160
		completionCommunesPresenteur = new AutoCompletionComboBoxPresenteur(new AutoCompletionComboBoxVue(), url) {
131
			protected String effectuerPreTraitementChaineRequete(String requete) {
161
			protected String effectuerPreTraitementChaineRequete(String requete) {
132
				return requete;
162
				return requete;
133
			}
163
			}
134
			
164
 
135
			@Override
165
			@Override
136
			protected void surSelectionSuggestion(String suggestion) {
166
			protected void surSelectionSuggestion(String suggestion) {
-
 
167
				setValeur(suggestion);
137
				collecterInfosRecherche();
168
				collecterInfosRecherche();
138
				setValeur(getInformationsRechercheEnCache().getCommune());
169
				setValeur(getInformationsRechercheEnCache().getCommune());
139
				vue.setValeurDepartement(getInformationsRechercheEnCache().getDepartement());
170
				vue.setValeurDepartement(getInformationsRechercheEnCache().getDepartement());
140
			}
171
			}
Line 143... Line 174...
143
			protected String[] parserResultatRequete(Response response) {
174
			protected String[] parserResultatRequete(Response response) {
144
				return UtilitairesAutoCompletionService.parserRetourSimple(response);
175
				return UtilitairesAutoCompletionService.parserRetourSimple(response);
145
			}
176
			}
146
		};
177
		};
147
	}
178
	}
148
	
179
 
149
	@Override
180
	@Override
150
	public void go(HasWidgets composite) {
181
	public void go(HasWidgets composite) {
151
		afficherRequeteEtLancerRecherche();
182
		afficherRequeteEtLancerRecherche();
152
		completionTaxonsPresenteur.go(vue.getTaxon());
183
		completionTaxonsPresenteur.go(vue.getTaxon());
153
		completionCommunesPresenteur.go(vue.getCommune());
184
		completionCommunesPresenteur.go(vue.getCommune());
Line 157... Line 188...
157
 
188
 
158
	@Override
189
	@Override
159
	protected void gererEvenements() {
190
	protected void gererEvenements() {
160
		vue.getLienRechercheAvancee().addClickHandler(new ClickHandler() {
191
		vue.getLienRechercheAvancee().addClickHandler(new ClickHandler() {
-
 
192
			public void onClick(ClickEvent event) {
161
			public void onClick(ClickEvent event) {
193
				setTypeMoteur(TypeMoteur.AVANCEE);
162
				vue.setContientMots(vue.getValeurRechercheSimple());
194
				vue.setContientMots(vue.getValeurRechercheSimple());
163
				vue.basculerAffichageZoneCache();
195
				vue.basculerAffichageZoneCache();
164
			}
196
			}
Line 216... Line 248...
216
					vue.setValeurRechercheSimple("");
248
					vue.setValeurRechercheSimple("");
217
				}
249
				}
218
			}
250
			}
219
		});
251
		});
220
	}
252
	}
221
	
253
 
222
	private void nettoyerChamps() {
254
	private void nettoyerChamps() {
223
		completionCommunesPresenteur.nettoyer();
255
		completionCommunesPresenteur.nettoyer();
224
		completionTaxonsPresenteur.nettoyer();
256
		completionTaxonsPresenteur.nettoyer();
225
		vue.nettoyer();
257
		vue.nettoyer();
226
	}
258
	}
Line 238... Line 270...
238
			informationRecherche.setMotClef(vue.getMotCle());
270
			informationRecherche.setMotClef(vue.getMotCle());
239
			informationRecherche.setAuteur(vue.getAuteur());
271
			informationRecherche.setAuteur(vue.getAuteur());
240
			informationRecherche.setDate(vue.getDate());
272
			informationRecherche.setDate(vue.getDate());
241
		}
273
		}
Line -... Line 274...
-
 
274
 
242
 
275
 
243
		if (estPourRechercheImages()) {
276
		if (estPourRechercheImages()) {
244
			CacheClient.getInstance().setPageCouranteRechercheImages(1);
277
			CacheClient.getInstance().setPageCouranteRechercheImages(1);
245
			CacheClient.getInstance().setInformationsRechercheImage(informationRecherche);
278
			CacheClient.getInstance().setInformationsRechercheImage(informationRecherche);
246
		} else if (estPourRechercheObservations()) {
279
		} else if (estPourRechercheObservations()) {
247
			CacheClient.getInstance().setPageCouranteRechercheObservations(1);
280
			CacheClient.getInstance().setPageCouranteRechercheObservations(1);
248
			CacheClient.getInstance().setInformationsRechercheObservation(informationRecherche);
281
			CacheClient.getInstance().setInformationsRechercheObservation(informationRecherche);
249
		}
282
		}
250
	}
283
	}
251
	
284
 
252
	private String getRechercheLibre() {
285
	private String getRechercheLibre() {
253
		String rechercheLibre = "";
286
		String rechercheLibre = "";
254
		switch (this.typeMoteur) {
287
		switch (this.typeMoteur) {
255
			case SIMPLE : 
288
		case SIMPLE:
256
				rechercheLibre = vue.getValeurRechercheSimple();
289
			rechercheLibre = vue.getValeurRechercheSimple();
257
				break;
290
			break;
258
			case AVANCEE : 
291
		case AVANCEE:
259
				rechercheLibre = vue.getContientMots();
292
			rechercheLibre = vue.getContientMots();
260
				break;
293
			break;
261
			default:
294
		default:
-
 
295
			// TODO : voir comment gérer les exceptions proprement
262
				// TODO : voir comment gérer les exceptions proprement
296
			// throw new
263
				//throw new Exception("Le type de moteur de recherche indiqué n'est pas disponilbe");
297
			// Exception("Le type de moteur de recherche indiqué n'est pas disponilbe");
264
		}
298
		}
265
		return rechercheLibre;
299
		return rechercheLibre;
Line 266... Line 300...
266
	}
300
	}