Subversion Repositories eFlore/Applications.del

Rev

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

Rev 533 Rev 545
Line 20... Line 20...
20
import com.google.gwt.user.client.ui.IsWidget;
20
import com.google.gwt.user.client.ui.IsWidget;
Line 21... Line 21...
21
 
21
 
Line 22... Line 22...
22
public abstract class MoteurRecherchePresenteur extends Presenteur {
22
public abstract class MoteurRecherchePresenteur extends Presenteur {
23
 
-
 
24
	public abstract interface Vue extends IsWidget {
23
 
25
 
24
	public abstract interface Vue extends IsWidget {
26
		public abstract void ajouterVue(HasWidgets composite);
25
		public void ajouterVue(HasWidgets composite);
27
		public abstract HasClickHandlers getLienRechercheAvancee();
26
		public HasClickHandlers getLienRechercheAvancee();
28
		public abstract void basculerAffichageZoneCache();
27
		public void basculerAffichageZoneCache();
29
		public abstract HasClickHandlers getBoutonRechercheSimple();
28
		public HasClickHandlers getBoutonRechercheSimple();
30
		public abstract HasClickHandlers getBoutonFermer();
29
		public HasClickHandlers getBoutonFermer();
31
		public abstract HasClickHandlers getBoutonVider();
30
		public HasClickHandlers getBoutonVider();
32
		public abstract HasClickHandlers getBoutonRechercheAvancee();
31
		public HasClickHandlers getBoutonRechercheAvancee();
33
		public abstract HasKeyPressHandlers getChampSaisie();
32
		public HasKeyPressHandlers getChampSaisie();
34
		public abstract HasClickHandlers getChampSaisieCliquable();
33
		public HasClickHandlers getChampSaisieCliquable();
35
		public abstract String getValeurRechercheSimple();
34
		public String getValeurRechercheSimple();
36
		public String getLabelRecherche();
35
		public String getLabelRecherche();
37
		public String getContientMots();
36
		public String getContientMots();
38
		public String getDepartement();
37
		public String getDepartement();
Line 55... Line 54...
55
	private final Vue vue;
54
	private final Vue vue;
56
	private ModeRecherche modeRecherche;
55
	private ModeRecherche modeRecherche;
57
	public enum TypeMoteur {SIMPLE, AVANCEE};
56
	public enum TypeMoteur {SIMPLE, AVANCEE};
58
	private TypeMoteur typeMoteur = TypeMoteur.SIMPLE;
57
	private TypeMoteur typeMoteur = TypeMoteur.SIMPLE;
Line 59... Line 58...
59
 
58
 
60
	private AutoCompletionComboBoxPresenteur autoCompletionNomTaxonsPresenteur;
59
	private AutoCompletionComboBoxPresenteur completionTaxonsPresenteur;
Line 61... Line 60...
61
	private AutoCompletionComboBoxPresenteur autoCompletionCommunesPresenteur;
60
	private AutoCompletionComboBoxPresenteur completionCommunesPresenteur;
62
	
-
 
63
	public MoteurRecherchePresenteur(Vue vue, ModeRecherche mode) {
-
 
64
		
-
 
65
		AutoCompletionComboBoxPresenteur completionNomTaxonsPresenteur = new AutoCompletionComboBoxPresenteur(new AutoCompletionComboBoxVue(), UtilitairesAutoCompletionService.urlServiceCompletionNomLocale) {
-
 
66
 
-
 
67
			protected String effectuerPreTraitementChaineRequete(String requete) {
-
 
68
				return UtilitairesAutoCompletionService.effectuerPreTraitementChaineRequeteGenreEspeceSlash(requete);
-
 
69
				// A décommenter lors de l'utilisation des web services eflore
-
 
70
				// return
-
 
71
				// RetourAutoCompletionService.effectuerPreTraitementChaineRequeteGenreEspeceEflore(requete);
-
 
72
			}
-
 
73
 
-
 
74
			@Override
-
 
75
			protected String[] parserResultatRequete(Response response) {
-
 
76
				return UtilitairesAutoCompletionService.parserRetourSimple(response);
-
 
77
				// A décommenter lors de l'utilisation des web services eflore
-
 
78
				// return RetourAutoCompletionService.parserRetourOss(response);
-
 
79
			}
-
 
80
		};
-
 
81
		
-
 
82
		AutoCompletionComboBoxPresenteur completionCommunesPresenteur = new AutoCompletionComboBoxPresenteur(new AutoCompletionComboBoxVue(), UtilitairesAutoCompletionService.urlServiceCompletionCommunes) {
-
 
83
 
-
 
84
			protected String effectuerPreTraitementChaineRequete(String requete) {
-
 
85
				return requete;
-
 
86
			}
-
 
87
			
-
 
88
			@Override
-
 
89
			protected void surSelectionSuggestion(String suggestion) {
-
 
90
				String[] tableauCommuneDpt = suggestion.split(" ");
-
 
91
				if(tableauCommuneDpt.length == 2) {
-
 
92
					String dpt = tableauCommuneDpt[1].replaceAll("\\(", "").replaceAll("\\)", "");
-
 
93
					getVue().setValeurDepartement(dpt);
-
 
94
					setValeur(tableauCommuneDpt[0]);
-
 
95
				}
-
 
96
			}
-
 
97
 
-
 
98
			@Override
-
 
99
			protected String[] parserResultatRequete(Response response) {
-
 
100
				return UtilitairesAutoCompletionService.parserRetourSimple(response);
-
 
101
			}
61
	
102
		};
62
	public MoteurRecherchePresenteur(Vue vue, ModeRecherche mode) {
103
		this.vue = vue;
-
 
104
		setMode(mode);
63
		this.vue = vue;
105
 
64
		setMode(mode);
106
		autoCompletionCommunesPresenteur = completionCommunesPresenteur;
65
		this.creerCompletionTaxons();
107
		autoCompletionNomTaxonsPresenteur = completionNomTaxonsPresenteur;
66
		this.creerCompletionCommunes();
Line 108... Line 67...
108
		gererEvenements();
67
		gererEvenements();
109
	}
68
	}
110
	
69
	
111
	public MoteurRecherchePresenteur(AutoCompletionComboBoxPresenteur presenteurAutoCompletionTaxon, 
70
	public MoteurRecherchePresenteur(AutoCompletionComboBoxPresenteur presenteurAutoCompletionTaxon, 
112
									AutoCompletionComboBoxPresenteur presenteurAutoCompletionCommunes,
71
									AutoCompletionComboBoxPresenteur presenteurAutoCompletionCommunes,
113
									Vue vue, ModeRecherche mode) {
72
									Vue vue, ModeRecherche mode) {
114
		this.vue = vue;
73
		this.vue = vue;
115
		setMode(mode);
74
		setMode(mode);
116
		autoCompletionNomTaxonsPresenteur = presenteurAutoCompletionTaxon;
75
		completionTaxonsPresenteur = presenteurAutoCompletionTaxon;
Line 117... Line 76...
117
		autoCompletionCommunesPresenteur = presenteurAutoCompletionCommunes;
76
		completionCommunesPresenteur = presenteurAutoCompletionCommunes;
118
		gererEvenements();
77
		gererEvenements();
Line 140... Line 99...
140
 
99
 
141
	public boolean estPourRechercheObservations() {
100
	public boolean estPourRechercheObservations() {
142
		return (modeRecherche == ModeRecherche.MODE_OBSERVATION);
101
		return (modeRecherche == ModeRecherche.MODE_OBSERVATION);
Line -... Line 102...
-
 
102
	}	
-
 
103
 
-
 
104
	private void creerCompletionTaxons() {
-
 
105
		completionTaxonsPresenteur = new AutoCompletionComboBoxPresenteur(new AutoCompletionComboBoxVue(), UtilitairesAutoCompletionService.urlServiceCompletionNomLocale) {
-
 
106
			protected String effectuerPreTraitementChaineRequete(String requete) {
-
 
107
				return UtilitairesAutoCompletionService.effectuerPreTraitementChaineRequeteGenreEspeceSlash(requete);
-
 
108
				// A décommenter lors de l'utilisation des web services eflore
-
 
109
				// return
-
 
110
				// RetourAutoCompletionService.effectuerPreTraitementChaineRequeteGenreEspeceEflore(requete);
-
 
111
			}
-
 
112
 
-
 
113
			@Override
-
 
114
			protected String[] parserResultatRequete(Response response) {
-
 
115
				return UtilitairesAutoCompletionService.parserRetourSimple(response);
-
 
116
				// A décommenter lors de l'utilisation des web services eflore
-
 
117
				// return RetourAutoCompletionService.parserRetourOss(response);
-
 
118
			}
-
 
119
		};
-
 
120
	}
-
 
121
	
-
 
122
	private void creerCompletionCommunes() {
-
 
123
		completionCommunesPresenteur = new AutoCompletionComboBoxPresenteur(new AutoCompletionComboBoxVue(), UtilitairesAutoCompletionService.urlServiceCompletionCommunes) {
-
 
124
			protected String effectuerPreTraitementChaineRequete(String requete) {
-
 
125
				return requete;
-
 
126
			}
-
 
127
			
-
 
128
			@Override
-
 
129
			protected void surSelectionSuggestion(String suggestion) {
-
 
130
				String[] tableauCommuneDpt = suggestion.split(" ");
-
 
131
				if(tableauCommuneDpt.length == 2) {
-
 
132
					String dpt = tableauCommuneDpt[1].replaceAll("\\(", "").replaceAll("\\)", "");
-
 
133
					getVue().setValeurDepartement(dpt);
-
 
134
					setValeur(tableauCommuneDpt[0]);
-
 
135
				}
-
 
136
			}
-
 
137
 
-
 
138
			@Override
-
 
139
			protected String[] parserResultatRequete(Response response) {
-
 
140
				return UtilitairesAutoCompletionService.parserRetourSimple(response);
-
 
141
			}
-
 
142
		};
143
	}	
143
	}
144
 
144
	
145
	@Override
145
	@Override
146
	public void go(HasWidgets composite) {
146
	public void go(HasWidgets composite) {
147
		afficherRequeteEtLancerRecherche();
147
		afficherRequeteEtLancerRecherche();
148
		autoCompletionNomTaxonsPresenteur.go(vue.getTaxon());
148
		completionTaxonsPresenteur.go(vue.getTaxon());
149
		autoCompletionCommunesPresenteur.go(vue.getCommune());
149
		completionCommunesPresenteur.go(vue.getCommune());
150
		vue.ajouterVue(composite);
150
		vue.ajouterVue(composite);
Line 151... Line 151...
151
		vue.focusSaisie();
151
		vue.focusSaisie();
Line 214... Line 214...
214
			}
214
			}
215
		});
215
		});
216
	}
216
	}
Line 217... Line 217...
217
	
217
	
218
	private void nettoyerChamps() {
218
	private void nettoyerChamps() {
219
		autoCompletionCommunesPresenteur.nettoyer();
219
		completionCommunesPresenteur.nettoyer();
220
		autoCompletionNomTaxonsPresenteur.nettoyer();
220
		completionTaxonsPresenteur.nettoyer();
221
		vue.nettoyer();
221
		vue.nettoyer();
Line 222... Line 222...
222
	}
222
	}
223
 
223
 
224
	public void collecterInfosRecherche() {
-
 
225
		InformationsRecherche informationRecherche = new InformationsRecherche();
-
 
226
		informationRecherche.setTaxon(autoCompletionNomTaxonsPresenteur.getValeur());
-
 
227
		informationRecherche.setDepartement(vue.getDepartement());
-
 
228
		informationRecherche.setCommune(autoCompletionCommunesPresenteur.getValeur());
-
 
229
		informationRecherche.setFamille(vue.getFamille());
-
 
230
		informationRecherche.setGenre(vue.getGenre());
-
 
231
		informationRecherche.setTag(vue.getTag());
-
 
232
		informationRecherche.setMotClef(vue.getMotCle());
-
 
233
		informationRecherche.setAuteur(vue.getAuteur());
224
	public void collecterInfosRecherche() {
-
 
225
		InformationsRecherche informationRecherche = new InformationsRecherche();
-
 
226
		informationRecherche.setRechercheLibre(this.getRechercheLibre());
-
 
227
		if (this.typeMoteur == TypeMoteur.AVANCEE) {
-
 
228
			informationRecherche.setTaxon(completionTaxonsPresenteur.getValeur());
-
 
229
			informationRecherche.setDepartement(vue.getDepartement());
-
 
230
			informationRecherche.setCommune(completionCommunesPresenteur.getValeur());
-
 
231
			informationRecherche.setFamille(vue.getFamille());
-
 
232
			informationRecherche.setGenre(vue.getGenre());
-
 
233
			informationRecherche.setTag(vue.getTag());
-
 
234
			informationRecherche.setMotClef(vue.getMotCle());
-
 
235
			informationRecherche.setAuteur(vue.getAuteur());
Line 234... Line 236...
234
		informationRecherche.setDate(vue.getDate());
236
			informationRecherche.setDate(vue.getDate());
235
		informationRecherche.setRechercheLibre(this.getRechercheLibre());
237
		}
236
 
238
 
237
		if (estPourRechercheImages()) {
239
		if (estPourRechercheImages()) {
Line 269... Line 271...
269
	}
271
	}
Line 270... Line 272...
270
 
272
 
271
	public void afficherRequeteEtLancerRecherche() {
273
	public void afficherRequeteEtLancerRecherche() {
272
		InformationsRecherche informationsRecherche = getInformationsRechercheEnCache();
274
		InformationsRecherche informationsRecherche = getInformationsRechercheEnCache();
273
		if (informationsRecherche != null) {
275
		if (informationsRecherche != null) {
274
			autoCompletionNomTaxonsPresenteur.setValeur(informationsRecherche.getTaxon());
276
			completionTaxonsPresenteur.setValeur(informationsRecherche.getTaxon());
275
			vue.chargerValeursRecherchePrecedente(informationsRecherche);
277
			vue.chargerValeursRecherchePrecedente(informationsRecherche);
276
		}
278
		}
277
		lancerRecherche();
279
		lancerRecherche();