Subversion Repositories eFlore/Applications.del

Rev

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

Rev 451 Rev 457
Line 14... Line 14...
14
import com.google.gwt.event.dom.client.HasKeyPressHandlers;
14
import com.google.gwt.event.dom.client.HasKeyPressHandlers;
15
import com.google.gwt.event.dom.client.KeyCodes;
15
import com.google.gwt.event.dom.client.KeyCodes;
16
import com.google.gwt.event.dom.client.KeyPressEvent;
16
import com.google.gwt.event.dom.client.KeyPressEvent;
17
import com.google.gwt.event.dom.client.KeyPressHandler;
17
import com.google.gwt.event.dom.client.KeyPressHandler;
18
import com.google.gwt.http.client.Response;
18
import com.google.gwt.http.client.Response;
-
 
19
import com.google.gwt.user.client.Window;
19
import com.google.gwt.user.client.ui.HasText;
20
import com.google.gwt.user.client.ui.HasText;
20
import com.google.gwt.user.client.ui.HasWidgets;
21
import com.google.gwt.user.client.ui.HasWidgets;
21
import com.google.gwt.user.client.ui.IsWidget;
22
import com.google.gwt.user.client.ui.IsWidget;
Line 22... Line 23...
22
 
23
 
Line 33... Line 34...
33
		public abstract HasClickHandlers getBoutonRechercheAvancee();
34
		public abstract HasClickHandlers getBoutonRechercheAvancee();
34
		public abstract HasKeyPressHandlers getChampSaisie();
35
		public abstract HasKeyPressHandlers getChampSaisie();
35
		public abstract HasClickHandlers getChampSaisieCliquable();
36
		public abstract HasClickHandlers getChampSaisieCliquable();
36
		public abstract String getValeurRechercheSimple();
37
		public abstract String getValeurRechercheSimple();
37
		public void setValeurRechercheSimple(String valeurRecherche);
38
		public void setValeurRechercheSimple(String valeurRecherche);
-
 
39
		public void setValeurDepartement(String dpt);
38
		public String getLabelRecherche();
40
		public String getLabelRecherche();
39
		public String getRecherchePrincipale();
41
		public String getRecherchePrincipale();
40
		public String getDepartement();
42
		public String getDepartement();
41
		public String getCommune();
43
		public HasWidgets getCommune();
42
		public HasWidgets getTaxon();
44
		public HasWidgets getTaxon();
43
		public String getFamille();
45
		public String getFamille();
44
		public String getGenre();
46
		public String getGenre();
45
		public String getTag();
47
		public String getTag();
46
		public String getMotCle();
48
		public String getMotCle();
Line 50... Line 52...
50
		public void focusSaisie();
52
		public void focusSaisie();
51
		public void nettoyer();
53
		public void nettoyer();
52
	}
54
	}
Line 53... Line 55...
53
 
55
 
54
	private final Vue vue;
56
	private final Vue vue;
Line 55... Line 57...
55
	private boolean pourRechercheImages = false, pourRechercheObservations= false;
57
	private ModeRecherche modeRecherche;
-
 
58
 
Line 56... Line 59...
56
 
59
	private AutoCompletionComboBoxPresenteur autoCompletionNomTaxonsPresenteur;
Line 57... Line 60...
57
	private AutoCompletionComboBoxPresenteur autoCompletionNomTaxonsPresenteur;
60
	private AutoCompletionComboBoxPresenteur autoCompletionCommunesPresenteur;
Line 72... Line 75...
72
				return UtilitairesAutoCompletionService.parserRetourSimple(response);
75
				return UtilitairesAutoCompletionService.parserRetourSimple(response);
73
				// A décommenter lors de l'utilisation des web services eflore
76
				// A décommenter lors de l'utilisation des web services eflore
74
				// return RetourAutoCompletionService.parserRetourOss(response);
77
				// return RetourAutoCompletionService.parserRetourOss(response);
75
			}
78
			}
76
		};
79
		};
-
 
80
		
-
 
81
		AutoCompletionComboBoxPresenteur completionCommunesPresenteur = new AutoCompletionComboBoxPresenteur(new AutoCompletionComboBoxVue(), UtilitairesAutoCompletionService.urlServiceCompletionCommunes) {
-
 
82
 
-
 
83
			protected String effectuerPreTraitementChaineRequete(String requete) {
-
 
84
				return requete;
-
 
85
			}
-
 
86
			
-
 
87
			@Override
-
 
88
			protected void surSelectionSuggestion(String suggestion) {
-
 
89
				String[] tableauCommuneDpt = suggestion.split(" ");
-
 
90
				if(tableauCommuneDpt.length == 2) {
-
 
91
					String dpt = tableauCommuneDpt[1].replaceAll("\\(", "").replaceAll("\\)", "");
-
 
92
					getVue().setValeurDepartement(dpt);
-
 
93
					setValeur(tableauCommuneDpt[0]);
-
 
94
				}
-
 
95
			}
-
 
96
 
-
 
97
			@Override
-
 
98
			protected String[] parserResultatRequete(Response response) {
-
 
99
				return UtilitairesAutoCompletionService.parserRetourSimple(response);
-
 
100
			}
-
 
101
		};
77
		this.vue = vue;
102
		this.vue = vue;
Line 78... Line 103...
78
		
103
		
Line -... Line 104...
-
 
104
		setMode(mode);
79
		setMode(mode);
105
 
80
 
106
		autoCompletionCommunesPresenteur = completionCommunesPresenteur;
81
		autoCompletionNomTaxonsPresenteur = completionNomTaxonsPresenteur;
107
		autoCompletionNomTaxonsPresenteur = completionNomTaxonsPresenteur;
Line 82... Line 108...
82
		gererEvenements();
108
		gererEvenements();
83
	}
-
 
84
	
-
 
85
	private void setMode(ModeRecherche mode) {
109
	}
86
		switch(mode) {
-
 
87
		case MODE_IMAGE:
-
 
88
			this.pourRechercheImages = true;
-
 
89
		break;
-
 
90
		case MODE_OBSERVATION:
110
	
Line 91... Line 111...
91
			this.pourRechercheObservations = true;
111
	private void setMode(ModeRecherche mode) {
-
 
112
		modeRecherche = mode;
-
 
113
	}
92
		}
114
	
93
	}
115
	public MoteurRecherchePresenteur(AutoCompletionComboBoxPresenteur presenteurAutoCompletionTaxon, 
94
	
116
									AutoCompletionComboBoxPresenteur presenteurAutoCompletionCommunes,
-
 
117
									Vue vue, ModeRecherche mode) {
95
	public MoteurRecherchePresenteur(AutoCompletionComboBoxPresenteur presenteurAutoCompletion, Vue vue, ModeRecherche mode) {
118
		this.vue = vue;
96
		this.vue = vue;
119
		setMode(mode);
Line 97... Line 120...
97
		setMode(mode);
120
		autoCompletionNomTaxonsPresenteur = presenteurAutoCompletionTaxon;
98
		autoCompletionNomTaxonsPresenteur = presenteurAutoCompletion;
121
		autoCompletionCommunesPresenteur = presenteurAutoCompletionCommunes;
99
		gererEvenements();
122
		gererEvenements();
100
	}
123
	}
-
 
124
 
101
 
125
	@Override
102
	@Override
126
	public void go(HasWidgets composite) {
103
	public void go(HasWidgets composite) {
127
		afficherRequeteEtLancerRecherche();
Line 104... Line 128...
104
		afficherRequeteEtLancerRecherche();
128
		autoCompletionNomTaxonsPresenteur.go(vue.getTaxon());
Line 133... Line 157...
133
		vue.getBoutonVider().addClickHandler(new ClickHandler() {
157
		vue.getBoutonVider().addClickHandler(new ClickHandler() {
Line 134... Line 158...
134
 
158
 
135
			@Override
159
			@Override
Line 136... Line -...
136
			public void onClick(ClickEvent event) {
-
 
137
 
160
			public void onClick(ClickEvent event) {
Line 138... Line 161...
138
				autoCompletionNomTaxonsPresenteur.nettoyer();
161
 
139
				vue.nettoyer();
162
				nettoyerChamps();
140
 
163
 
141
				InformationsRecherche infosRecherche = new InformationsRecherche();
164
				InformationsRecherche infosRecherche = new InformationsRecherche();
Line 173... Line 196...
173
					vue.setValeurRechercheSimple("");
196
					vue.setValeurRechercheSimple("");
174
				}
197
				}
175
			}
198
			}
176
		});
199
		});
177
	}
200
	}
-
 
201
	
-
 
202
	private void nettoyerChamps() {
-
 
203
		autoCompletionCommunesPresenteur.nettoyer();
-
 
204
		autoCompletionNomTaxonsPresenteur.nettoyer();
-
 
205
		vue.nettoyer();
-
 
206
	}
Line 178... Line 207...
178
 
207
 
179
	public void collecterInfosRecherche() {
208
	public void collecterInfosRecherche() {
180
		InformationsRecherche informationRecherche = new InformationsRecherche();
209
		InformationsRecherche informationRecherche = new InformationsRecherche();
181
		informationRecherche.setTaxon(autoCompletionNomTaxonsPresenteur.getValeur());
210
		informationRecherche.setTaxon(autoCompletionNomTaxonsPresenteur.getValeur());
182
		informationRecherche.setDepartement(vue.getDepartement());
211
		informationRecherche.setDepartement(vue.getDepartement());
183
		informationRecherche.setCommune(vue.getCommune());
212
		informationRecherche.setCommune(autoCompletionCommunesPresenteur.getValeur());
184
		informationRecherche.setFamille(vue.getFamille());
213
		informationRecherche.setFamille(vue.getFamille());
185
		informationRecherche.setGenre(vue.getGenre());
214
		informationRecherche.setGenre(vue.getGenre());
186
		informationRecherche.setTag(vue.getTag());
215
		informationRecherche.setTag(vue.getTag());
187
		informationRecherche.setMotClef(vue.getMotCle());
216
		informationRecherche.setMotClef(vue.getMotCle());
Line 215... Line 244...
215
	}
244
	}
Line 216... Line 245...
216
 
245
 
Line 217... Line 246...
217
	public abstract void lancerRecherche();
246
	public abstract void lancerRecherche();
218
 
247
 
219
	public boolean estPourRechercheImages() {
248
	public boolean estPourRechercheImages() {
Line 220... Line 249...
220
		return pourRechercheImages;
249
		return (modeRecherche == ModeRecherche.MODE_IMAGE);
221
	}
250
	}
-
 
251
 
-
 
252
	public boolean estPourRechercheObservations() {
-
 
253
		return (modeRecherche == ModeRecherche.MODE_OBSERVATION);
-
 
254
	}
222
 
255
	
Line 223... Line 256...
223
	public boolean estPourRechercheObservations() {
256
	private Vue getVue() {
224
		return pourRechercheObservations;
-
 
225
	}
257
		return vue;
226
	
-
 
227
	public ModeRecherche getMode() {
-
 
228
		if(estPourRechercheImages()) {
-
 
229
			return ModeRecherche.MODE_IMAGE;
258
	}
230
		} else {
259