Subversion Repositories eFlore/Applications.del

Rev

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

Rev 1496 Rev 1501
1
package org.tela_botanica.del.client.vues.pictoflora.resultats;
1
package org.tela_botanica.del.client.vues.pictoflora.resultats;
2
 
2
 
3
import java.util.List;
3
import java.util.List;
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.pagination.PaginationPresenteur;
6
import org.tela_botanica.del.client.composants.pagination.PaginationPresenteur;
7
import org.tela_botanica.del.client.composants.pagination.PaginationVue;
7
import org.tela_botanica.del.client.composants.pagination.PaginationVue;
8
import org.tela_botanica.del.client.modeles.Image;
8
import org.tela_botanica.del.client.modeles.Image;
9
import org.tela_botanica.del.client.modeles.ImageServiceResultat;
9
import org.tela_botanica.del.client.modeles.ImageServiceResultat;
10
import org.tela_botanica.del.client.modeles.InformationsRecherche;
10
import org.tela_botanica.del.client.modeles.InformationsRecherche;
11
import org.tela_botanica.del.client.modeles.ModeTri;
11
import org.tela_botanica.del.client.modeles.ModeTri;
12
import org.tela_botanica.del.client.modeles.Protocole;
12
import org.tela_botanica.del.client.modeles.Protocole;
13
import org.tela_botanica.del.client.modeles.ProtocoleServiceResultat;
13
import org.tela_botanica.del.client.modeles.ProtocoleServiceResultat;
14
import org.tela_botanica.del.client.navigation.evenement.BusEvenementiel;
14
import org.tela_botanica.del.client.navigation.evenement.BusEvenementiel;
15
import org.tela_botanica.del.client.navigation.evenement.changementprotocole.EvenementChangementProtocole;
15
import org.tela_botanica.del.client.navigation.evenement.changementprotocole.EvenementChangementProtocole;
16
import org.tela_botanica.del.client.navigation.evenement.changementprotocole.GestionnaireEvenementChangementProtocole;
16
import org.tela_botanica.del.client.navigation.evenement.changementprotocole.GestionnaireEvenementChangementProtocole;
17
import org.tela_botanica.del.client.services.rest.ImageService;
17
import org.tela_botanica.del.client.services.rest.ImageService;
18
import org.tela_botanica.del.client.services.rest.ProtocoleService;
18
import org.tela_botanica.del.client.services.rest.ProtocoleService;
19
import org.tela_botanica.del.client.services.rest.async.ImagesParTaxonCallback;
19
import org.tela_botanica.del.client.services.rest.async.ImagesParTaxonCallback;
20
import org.tela_botanica.del.client.services.rest.async.ProtocolesCallback;
20
import org.tela_botanica.del.client.services.rest.async.ProtocolesCallback;
21
import org.tela_botanica.del.client.vues.pictoflora.resultats.images.ImagePresenteur;
21
import org.tela_botanica.del.client.vues.pictoflora.resultats.images.ImagePresenteur;
22
import org.tela_botanica.del.client.vues.pictoflora.resultats.images.ImageVue;
22
import org.tela_botanica.del.client.vues.pictoflora.resultats.images.ImageVue;
23
 
23
 
24
import com.google.gwt.dom.client.NodeList;
24
import com.google.gwt.dom.client.NodeList;
25
import com.google.gwt.dom.client.OptionElement;
25
import com.google.gwt.dom.client.OptionElement;
26
import com.google.gwt.dom.client.SelectElement;
26
import com.google.gwt.dom.client.SelectElement;
27
import com.google.gwt.event.dom.client.ChangeEvent;
27
import com.google.gwt.event.dom.client.ChangeEvent;
28
import com.google.gwt.event.dom.client.ChangeHandler;
28
import com.google.gwt.event.dom.client.ChangeHandler;
29
import com.google.gwt.event.dom.client.ClickEvent;
29
import com.google.gwt.event.dom.client.ClickEvent;
30
import com.google.gwt.event.dom.client.ClickHandler;
30
import com.google.gwt.event.dom.client.ClickHandler;
31
import com.google.gwt.event.dom.client.HasChangeHandlers;
31
import com.google.gwt.event.dom.client.HasChangeHandlers;
32
import com.google.gwt.event.dom.client.HasClickHandlers;
32
import com.google.gwt.event.dom.client.HasClickHandlers;
33
import com.google.gwt.user.client.Window;
33
import com.google.gwt.user.client.Window;
34
import com.google.gwt.user.client.ui.HTMLPanel;
34
import com.google.gwt.user.client.ui.HTMLPanel;
35
import com.google.gwt.user.client.ui.HasWidgets;
35
import com.google.gwt.user.client.ui.HasWidgets;
36
import com.google.gwt.user.client.ui.IsWidget;
36
import com.google.gwt.user.client.ui.IsWidget;
37
import com.google.gwt.user.client.ui.ListBox;
37
import com.google.gwt.user.client.ui.ListBox;
38
 
38
 
39
public class ResultatPictofloraPresenteur {
39
public class ResultatPictofloraPresenteur {
40
	public interface Vue extends IsWidget {
40
	public interface Vue extends IsWidget {
41
		
41
		
42
		
42
		
43
		public void startChargement();
43
		public void startChargement();
44
 
44
 
45
		public void nettoyer();
45
		public void nettoyer();
46
 
46
 
47
		public void creerPanneauxObservations(int size);
47
		public void creerPanneauxObservations(int size);
48
 
48
 
49
		public void stopChargement();
49
		public void stopChargement();
50
 
50
 
51
		public List<HasWidgets> getPanneauxImages();
51
		public List<HasWidgets> getPanneauxImages();
52
 
52
 
53
		public HasWidgets getPanneauPagination();
53
		public HasWidgets getPanneauPagination();
54
 
54
 
55
		public HasWidgets getPanneauPaginationHaut();
55
		public HasWidgets getPanneauPaginationHaut();
56
 
56
 
57
		public HasClickHandlers getTriParNbVotesAscendant();
57
		public HasClickHandlers getTriParNbVotesAscendant();
58
 
58
 
59
		public HasClickHandlers getTriParNbVotesDescendant();
59
		public HasClickHandlers getTriParNbVotesDescendant();
60
 
60
 
61
		public HasClickHandlers getTriParDateAscendant();
61
		public HasClickHandlers getTriParDateAscendant();
62
 
62
 
63
		public HasClickHandlers getTriParDateDescendant();
63
		public HasClickHandlers getTriParDateDescendant();
64
		
64
		
65
		public HasClickHandlers getTriParNbTagsAscendant();
65
		public HasClickHandlers getTriParNbTagsAscendant();
66
 
66
 
67
		public HasClickHandlers getTriParNbTagsDescendant();
67
		public HasClickHandlers getTriParNbTagsDescendant();
68
 
68
 
69
		public void afficherElementsAucunResultatTrouve();
69
		public void afficherElementsAucunResultatTrouve();
70
 
70
 
71
		public void afficherElementsResultatsTrouve();
71
		public void afficherElementsResultatsTrouve();
72
 
72
 
73
		public HTMLPanel getImageTable();
73
		public HTMLPanel getImageTable();
74
 
74
 
75
		public HasClickHandlers getLabelVote();
75
		public HasClickHandlers getLabelVote();
76
 
76
 
77
		public void masquerVoteAscendant();
77
		public void masquerVoteAscendant();
78
 
78
 
79
		public void masquerVoteDescendant();
79
		public void masquerVoteDescendant();
80
 
80
 
81
		public void afficherVoteAscendant();
81
		public void afficherVoteAscendant();
82
 
82
 
83
		public void afficherVoteDescendant();
83
		public void afficherVoteDescendant();
84
 
84
 
85
		public HasClickHandlers getLabelDate();
85
		public HasClickHandlers getLabelDate();
86
	
86
	
87
		public HasClickHandlers getLabelTag();
87
		public HasClickHandlers getLabelTag();
88
 
88
 
89
		public void masquerDateAscendant();
89
		public void masquerDateAscendant();
90
 
90
 
91
		public void masquerDateDescendant();
91
		public void masquerDateDescendant();
92
 
92
 
93
		public void afficherDateAscendant();
93
		public void afficherDateAscendant();
94
 
94
 
95
		public void afficherDateDescendant();
95
		public void afficherDateDescendant();
96
 
96
 
97
		public void masquerTagAscendant();
97
		public void masquerTagAscendant();
98
 
98
 
99
		public void afficherTagDescendant();
99
		public void afficherTagDescendant();
100
 
100
 
101
		public void masquerTagDescendant();
101
		public void masquerTagDescendant();
102
 
102
 
103
		public void afficherTagAscendant();
103
		public void afficherTagAscendant();
104
 
104
 
105
	}
105
	}
106
 
106
 
107
	private Vue vue;
107
	private Vue vue;
108
	private ImageService imageService;
108
	private ImageService imageService;
109
	private final ProtocoleService protocoleService;
109
	private final ProtocoleService protocoleService;
110
	private ModeTri triCourantVote = ModeTri.TRI_ASCENDANT;
110
	private ModeTri triCourantVote = ModeTri.TRI_ASCENDANT;
111
	private ModeTri triCourantDate = ModeTri.TRI_DESCENDANT;
111
	private ModeTri triCourantDate = ModeTri.TRI_DESCENDANT;
112
	private ModeTri triCourantTag = ModeTri.TRI_DESCENDANT;
112
	private ModeTri triCourantTag = ModeTri.TRI_DESCENDANT;
113
 
113
 
114
	public ResultatPictofloraPresenteur(ImageService imageService, ProtocoleService protocoleService, Vue vue) {
114
	public ResultatPictofloraPresenteur(ImageService imageService, ProtocoleService protocoleService, Vue vue) {
115
		this.vue = vue;
115
		this.vue = vue;
116
		this.imageService = imageService;
116
		this.imageService = imageService;
117
		this.protocoleService=protocoleService;
117
		this.protocoleService=protocoleService;
118
	}
118
	}
119
 
119
 
120
	public void go(HasWidgets composite) {
120
	public void go(HasWidgets composite) {
121
		composite.add(vue.asWidget());
121
		composite.add(vue.asWidget());
122
		vue.startChargement();
122
		vue.startChargement();
123
		rechercherImagesEtCreerWidgetPagination();
123
		rechercherImagesEtCreerWidgetPagination();
124
		gererEvenements();
124
		gererEvenements();
125
		vue.masquerVoteDescendant();
125
		vue.masquerVoteDescendant();
126
		vue.masquerVoteAscendant();
126
		vue.masquerVoteAscendant();
127
		vue.masquerDateDescendant();
127
		vue.masquerDateDescendant();
128
		vue.masquerDateAscendant();
128
		vue.masquerDateAscendant();
129
		vue.masquerTagAscendant();
129
		vue.masquerTagAscendant();
130
		vue.masquerTagDescendant();
130
		vue.masquerTagDescendant();
131
		
131
		
132
		initialiserAPartirInfosCache();
132
		initialiserAPartirInfosCache();
133
	}
133
	}
134
	
134
	
135
	private void initialiserAPartirInfosCache() {
135
	private void initialiserAPartirInfosCache() {
136
		InformationsRecherche infos = CacheClient.getInstance().getInformationsRechercheImage();
136
		InformationsRecherche infos = CacheClient.getInstance().getInformationsRechercheImage();
137
		if(infos.getTriParDate() != ModeTri.PAS_DE_TRI) {
137
		if(infos.getTriParDate() != ModeTri.PAS_DE_TRI) {
138
			mettreAJourAffichageTriDate();
138
			mettreAJourAffichageTriDate();
139
		}
139
		}
140
		
140
		
141
		if(infos.getTriParNbVotes() != ModeTri.PAS_DE_TRI) {
141
		if(infos.getTriParNbVotes() != ModeTri.PAS_DE_TRI) {
142
			mettreAJourAffichageTriVote();
142
			mettreAJourAffichageTriVote();
143
		}
143
		}
144
		
144
		
145
		if(infos.getTriParNbTags() != ModeTri.PAS_DE_TRI) {
145
		if(infos.getTriParNbTags() != ModeTri.PAS_DE_TRI) {
146
			mettreAjourAffichageTriTag();
146
			mettreAjourAffichageTriTag();
147
		}
147
		}
148
		
148
		
149
	}
149
	}
150
 
150
 
151
	public void gererEvenements() {
151
	public void gererEvenements() {
152
		ClickHandler surClicTriVote = new ClickHandler() {
152
		ClickHandler surClicTriVote = new ClickHandler() {
153
			@Override
153
			@Override
154
			public void onClick(ClickEvent event) {
154
			public void onClick(ClickEvent event) {
155
				surClicTriVote();
155
				surClicTriVote();
156
			}
156
			}
157
		};
157
		};
158
 
158
 
159
		vue.getLabelVote().addClickHandler(surClicTriVote);
159
		vue.getLabelVote().addClickHandler(surClicTriVote);
160
		vue.getTriParNbVotesAscendant().addClickHandler(surClicTriVote);
160
		vue.getTriParNbVotesAscendant().addClickHandler(surClicTriVote);
161
		vue.getTriParNbVotesDescendant().addClickHandler(surClicTriVote);
161
		vue.getTriParNbVotesDescendant().addClickHandler(surClicTriVote);
162
 
162
 
163
		ClickHandler surClicTriDate = new ClickHandler() {
163
		ClickHandler surClicTriDate = new ClickHandler() {
164
			@Override
164
			@Override
165
			public void onClick(ClickEvent event) {
165
			public void onClick(ClickEvent event) {
166
				surClicTriDate();
166
				surClicTriDate();
167
			}
167
			}
168
		};
168
		};
169
 
169
 
170
		vue.getLabelDate().addClickHandler(surClicTriDate);
170
		vue.getLabelDate().addClickHandler(surClicTriDate);
171
		vue.getTriParDateAscendant().addClickHandler(surClicTriDate);
171
		vue.getTriParDateAscendant().addClickHandler(surClicTriDate);
172
		vue.getTriParDateDescendant().addClickHandler(surClicTriDate);
172
		vue.getTriParDateDescendant().addClickHandler(surClicTriDate);
173
		
173
		
174
		ClickHandler surClicTriTag = new ClickHandler() {
174
		ClickHandler surClicTriTag = new ClickHandler() {
175
			@Override
175
			@Override
176
			public void onClick(ClickEvent event) {
176
			public void onClick(ClickEvent event) {
177
				surClicTriTag();
177
				surClicTriTag();
178
			}
178
			}
179
		};
179
		};
180
		
180
		
181
		vue.getLabelTag().addClickHandler(surClicTriTag);
181
		vue.getLabelTag().addClickHandler(surClicTriTag);
182
		vue.getTriParNbTagsAscendant().addClickHandler(surClicTriTag);
182
		vue.getTriParNbTagsAscendant().addClickHandler(surClicTriTag);
183
		vue.getTriParNbTagsDescendant().addClickHandler(surClicTriTag);
183
		vue.getTriParNbTagsDescendant().addClickHandler(surClicTriTag);
184
 
184
 
185
		BusEvenementiel.getInstance().addHandler(EvenementChangementProtocole.TYPE, new GestionnaireEvenementChangementProtocole() {
185
		BusEvenementiel.getInstance().addHandler(EvenementChangementProtocole.TYPE, new GestionnaireEvenementChangementProtocole() {
186
			@Override
186
			@Override
187
			public void onChangementProtocole(EvenementChangementProtocole event) {
187
			public void onChangementProtocole(EvenementChangementProtocole event) {
188
				InformationsRecherche informationsRechercheImages = CacheClient.getInstance().getInformationsRechercheImage();
188
				InformationsRecherche informationsRechercheImages = CacheClient.getInstance().getInformationsRechercheImage();
189
				if (informationsRechercheImages.getTriParNbVotes() != ModeTri.PAS_DE_TRI) {
189
				if (informationsRechercheImages.getTriParNbVotes() != ModeTri.PAS_DE_TRI) {
190
					informationsRechercheImages.setIdProtocoleSelectionne(event.getProtocole().getId() + "");
190
					informationsRechercheImages.setIdProtocoleSelectionne(event.getProtocole().getId() + "");
191
					chargerEtAfficherImagesPageEnCours();
191
					chargerEtAfficherImagesPageEnCours();
192
				}
192
				}
193
			}
193
			}
194
		});
194
		});
195
	}
195
	}
196
 
196
 
197
	protected void surClicTriTag() {
197
	protected void surClicTriTag() {
198
		mettreAjourAffichageTriTag();
198
		mettreAjourAffichageTriTag();
199
		InformationsRecherche informationsRechercheImages = CacheClient.getInstance().getInformationsRechercheImage();
199
		InformationsRecherche informationsRechercheImages = CacheClient.getInstance().getInformationsRechercheImage();
200
		informationsRechercheImages.setTriParNbTags(triCourantTag);
200
		informationsRechercheImages.setTriParNbTags(triCourantTag);
201
		informationsRechercheImages.setTriParDate(ModeTri.PAS_DE_TRI);
201
		informationsRechercheImages.setTriParDate(ModeTri.PAS_DE_TRI);
202
		informationsRechercheImages.setTriParNbVotes(ModeTri.PAS_DE_TRI);
202
		informationsRechercheImages.setTriParNbVotes(ModeTri.PAS_DE_TRI);
203
		chargerEtAfficherImagesPageEnCours();
203
		chargerEtAfficherImagesPageEnCours();
204
	}
204
	}
205
	
205
	
206
	private void mettreAjourAffichageTriTag() {
206
	private void mettreAjourAffichageTriTag() {
207
		vue.masquerDateDescendant();
207
		vue.masquerDateDescendant();
208
		vue.masquerDateAscendant();
208
		vue.masquerDateAscendant();
209
		vue.masquerVoteDescendant();
209
		vue.masquerVoteDescendant();
210
		vue.masquerVoteAscendant();
210
		vue.masquerVoteAscendant();
211
		if (triCourantTag == ModeTri.TRI_ASCENDANT) {
211
		if (triCourantTag == ModeTri.TRI_ASCENDANT) {
212
			triCourantTag = ModeTri.TRI_DESCENDANT;
212
			triCourantTag = ModeTri.TRI_DESCENDANT;
213
			vue.masquerTagAscendant();
213
			vue.masquerTagAscendant();
214
			vue.afficherTagDescendant();
214
			vue.afficherTagDescendant();
215
		} else {
215
		} else {
216
			triCourantTag = ModeTri.TRI_ASCENDANT;
216
			triCourantTag = ModeTri.TRI_ASCENDANT;
217
			vue.masquerTagDescendant();
217
			vue.masquerTagDescendant();
218
			vue.afficherTagAscendant();
218
			vue.afficherTagAscendant();
219
		}
219
		}
220
	}
220
	}
221
 
221
 
222
	public void surClicTriVote() {
222
	public void surClicTriVote() {
223
		mettreAJourAffichageTriVote();
223
		mettreAJourAffichageTriVote();
224
		InformationsRecherche informationsRechercheImages = CacheClient.getInstance().getInformationsRechercheImage();
224
		InformationsRecherche informationsRechercheImages = CacheClient.getInstance().getInformationsRechercheImage();
225
		int IdProtocole = CacheClient.getInstance().getProtocoleCourant().getId();
225
		int IdProtocole = CacheClient.getInstance().getProtocoleCourant().getId();
226
		informationsRechercheImages.setTriParNbVotes(triCourantVote);
226
		informationsRechercheImages.setTriParNbVotes(triCourantVote);
227
		informationsRechercheImages.setIdProtocoleSelectionne(IdProtocole + "");
227
		informationsRechercheImages.setIdProtocoleSelectionne(IdProtocole + "");
228
		informationsRechercheImages.setTriParDate(ModeTri.PAS_DE_TRI);
228
		informationsRechercheImages.setTriParDate(ModeTri.PAS_DE_TRI);
229
		informationsRechercheImages.setTriParNbTags(ModeTri.PAS_DE_TRI);
229
		informationsRechercheImages.setTriParNbTags(ModeTri.PAS_DE_TRI);
230
		chargerEtAfficherImagesPageEnCours();
230
		chargerEtAfficherImagesPageEnCours();
231
	}
231
	}
232
	
232
	
233
	private void mettreAJourAffichageTriVote() {
233
	private void mettreAJourAffichageTriVote() {
234
		vue.masquerDateDescendant();
234
		vue.masquerDateDescendant();
235
		vue.masquerDateAscendant();
235
		vue.masquerDateAscendant();
236
		vue.masquerTagAscendant();
236
		vue.masquerTagAscendant();
237
		vue.masquerTagDescendant();
237
		vue.masquerTagDescendant();
238
		if (triCourantVote == ModeTri.TRI_ASCENDANT) {
238
		if (triCourantVote == ModeTri.TRI_ASCENDANT) {
239
			triCourantVote = ModeTri.TRI_DESCENDANT;
239
			triCourantVote = ModeTri.TRI_DESCENDANT;
240
			vue.masquerVoteAscendant();
240
			vue.masquerVoteAscendant();
241
			vue.afficherVoteDescendant();
241
			vue.afficherVoteDescendant();
242
		} else {
242
		} else {
243
			triCourantVote = ModeTri.TRI_ASCENDANT;
243
			triCourantVote = ModeTri.TRI_ASCENDANT;
244
			vue.masquerVoteDescendant();
244
			vue.masquerVoteDescendant();
245
			vue.afficherVoteAscendant();
245
			vue.afficherVoteAscendant();
246
		}
246
		}
247
	}
247
	}
248
 
248
 
249
	public void surClicTriDate() {
249
	public void surClicTriDate() {
250
		mettreAJourAffichageTriDate();
250
		mettreAJourAffichageTriDate();
251
		InformationsRecherche informationsRechercheImages = CacheClient.getInstance().getInformationsRechercheImage();
251
		InformationsRecherche informationsRechercheImages = CacheClient.getInstance().getInformationsRechercheImage();
252
		informationsRechercheImages.setTriParDate(triCourantDate);
252
		informationsRechercheImages.setTriParDate(triCourantDate);
253
		informationsRechercheImages.setTriParNbVotes(ModeTri.PAS_DE_TRI);
253
		informationsRechercheImages.setTriParNbVotes(ModeTri.PAS_DE_TRI);
254
		informationsRechercheImages.setTriParNbTags(ModeTri.PAS_DE_TRI);
254
		informationsRechercheImages.setTriParNbTags(ModeTri.PAS_DE_TRI);
255
		chargerEtAfficherImagesPageEnCours();
255
		chargerEtAfficherImagesPageEnCours();
256
	}
256
	}
257
	
257
	
258
	private void mettreAJourAffichageTriDate() {
258
	private void mettreAJourAffichageTriDate() {
259
		vue.masquerTagAscendant();
259
		vue.masquerTagAscendant();
260
		vue.masquerTagDescendant();
260
		vue.masquerTagDescendant();
261
		vue.masquerVoteDescendant();
261
		vue.masquerVoteDescendant();
262
		vue.masquerVoteAscendant();
262
		vue.masquerVoteAscendant();
263
		if (triCourantDate == ModeTri.TRI_ASCENDANT) {
263
		if (triCourantDate == ModeTri.TRI_ASCENDANT) {
264
			triCourantDate = ModeTri.TRI_DESCENDANT;
264
			triCourantDate = ModeTri.TRI_DESCENDANT;
265
			vue.masquerDateAscendant();
265
			vue.masquerDateAscendant();
266
			vue.afficherDateDescendant();
266
			vue.afficherDateDescendant();
267
		} else {
267
		} else {
268
			triCourantDate = ModeTri.TRI_ASCENDANT;
268
			triCourantDate = ModeTri.TRI_ASCENDANT;
269
			vue.masquerDateDescendant();
269
			vue.masquerDateDescendant();
270
			vue.afficherDateAscendant();
270
			vue.afficherDateAscendant();
271
		}
271
		}
272
	}
272
	}
273
 
273
 
274
	public void rechercherImagesEtCreerWidgetPagination() {
274
	public void rechercherImagesEtCreerWidgetPagination() {
275
		// appel du service d'image pour avoir le nb total d'elements pour la
275
		// appel du service d'image pour avoir le nb total d'elements pour la
276
		// pagination
276
		// pagination
277
		ImagesParTaxonCallback callback = new ImagesParTaxonCallback() {
277
		ImagesParTaxonCallback callback = new ImagesParTaxonCallback() {
278
 
278
 
279
			@Override
279
			@Override
280
			public void surRetour(ImageServiceResultat imagesRecues) {
280
			public void surRetour(ImageServiceResultat imagesRecues) {
281
				creerWidgetPagination(imagesRecues.getNbTotalImagesPourLaRecherche());
281
				creerWidgetPagination(imagesRecues.getNbTotalImagesPourLaRecherche());
282
				afficherImages(imagesRecues);
282
				afficherImages(imagesRecues);
283
 
283
 
284
			}
284
			}
285
 
285
 
286
			@Override
286
			@Override
287
			public void surErreur(String messageErreur) {
287
			public void surErreur(String messageErreur) {
288
				Window.alert(messageErreur);
288
				Window.alert(messageErreur);
289
 
289
 
290
			}
290
			}
291
		};
291
		};
292
		final int debut = (CacheClient.getInstance().getPageCouranteRechercheImage() - 1) * CacheClient.getInstance().getPasPagination();
292
		final int debut = (CacheClient.getInstance().getPageCouranteRechercheImage() - 1) * CacheClient.getInstance().getPasPagination();
293
		final int fin = (CacheClient.getInstance().getPageCouranteRechercheImage()) * CacheClient.getInstance().getPasPagination();
293
		final int fin = (CacheClient.getInstance().getPageCouranteRechercheImage()) * CacheClient.getInstance().getPasPagination();
294
		imageService.getImagesParTaxon(CacheClient.getInstance().getInformationsRechercheImage(), debut, fin, callback);
294
		imageService.getImagesParTaxon(CacheClient.getInstance().getInformationsRechercheImage(), debut, fin, callback);
295
	}
295
	}
296
 
296
 
297
	private void chargerEtAfficherImages(final int premier, final int dernier) {
297
	private void chargerEtAfficherImages(final int premier, final int dernier) {
298
		vue.startChargement();
298
		vue.startChargement();
299
		vue.nettoyer();
299
		vue.nettoyer();
300
		ImagesParTaxonCallback callback = new ImagesParTaxonCallback() {
300
		ImagesParTaxonCallback callback = new ImagesParTaxonCallback() {
301
 
301
 
302
			@Override
302
			@Override
303
			public void surRetour(ImageServiceResultat imagesRecues) {
303
			public void surRetour(ImageServiceResultat imagesRecues) {
304
				afficherImages(imagesRecues);
304
				afficherImages(imagesRecues);
305
			}
305
			}
306
 
306
 
307
			@Override
307
			@Override
308
			public void surErreur(String messageErreur) {
308
			public void surErreur(String messageErreur) {
309
				Window.alert(messageErreur);
309
				Window.alert(messageErreur);
310
			}
310
			}
311
 
311
 
312
		};
312
		};
313
		imageService.getImagesParTaxon(CacheClient.getInstance().getInformationsRechercheImage(), premier, dernier, callback);
313
		imageService.getImagesParTaxon(CacheClient.getInstance().getInformationsRechercheImage(), premier, dernier, callback);
314
	}
314
	}
315
 
315
 
316
	public void afficherImages(ImageServiceResultat imageServiceResult) {
316
	public void afficherImages(ImageServiceResultat imageServiceResult) {
317
		List<Image> images = imageServiceResult.getImages();
317
		List<Image> images = imageServiceResult.getImages();
318
		if (images == null || images.size() == 0) {
318
		if (images == null || images.size() == 0) {
319
			vue.afficherElementsAucunResultatTrouve();
319
			vue.afficherElementsAucunResultatTrouve();
320
		} else {
320
		} else {
321
			vue.afficherElementsResultatsTrouve();
321
			vue.afficherElementsResultatsTrouve();
322
			for (Image image : images) {
322
			for (Image image : images) {
323
				ImagePresenteur imagePresenteur = new ImagePresenteur(image, CacheClient.getInstance().getProtocoleCourant(), new ImageVue());
323
				ImagePresenteur imagePresenteur = new ImagePresenteur(image, CacheClient.getInstance().getProtocoleCourant(), new ImageVue());
324
				imagePresenteur.go(vue.getImageTable());
324
				imagePresenteur.go(vue.getImageTable());
325
			}
325
			}
326
		}
326
		}
-
 
327
		CacheClient.getInstance().mettreAjourUrlCourante();
327
		vue.stopChargement();
328
		vue.stopChargement();
328
	}
329
	}
329
 
330
 
330
	private void creerWidgetPagination(int nbImages) {
331
	private void creerWidgetPagination(int nbImages) {
331
		PaginationPresenteur imagesPaginationPresenteurHaut = creerPresenteurPagination(nbImages);
332
		PaginationPresenteur imagesPaginationPresenteurHaut = creerPresenteurPagination(nbImages);
332
		PaginationPresenteur imagesPaginationPresenteurBas = creerPresenteurPagination(nbImages);
333
		PaginationPresenteur imagesPaginationPresenteurBas = creerPresenteurPagination(nbImages);
333
		imagesPaginationPresenteurHaut.setGroupePagination("pagination_images");
334
		imagesPaginationPresenteurHaut.setGroupePagination("pagination_images");
334
		imagesPaginationPresenteurBas.setGroupePagination("pagination_images");
335
		imagesPaginationPresenteurBas.setGroupePagination("pagination_images");
335
		imagesPaginationPresenteurHaut.go(vue.getPanneauPaginationHaut());
336
		imagesPaginationPresenteurHaut.go(vue.getPanneauPaginationHaut());
336
		imagesPaginationPresenteurBas.go(vue.getPanneauPagination());
337
		imagesPaginationPresenteurBas.go(vue.getPanneauPagination());
337
	}
338
	}
338
 
339
 
339
	public PaginationPresenteur creerPresenteurPagination(int nbImages) {
340
	public PaginationPresenteur creerPresenteurPagination(int nbImages) {
340
		PaginationPresenteur imagesPaginationPresenteur = new PaginationPresenteur(new PaginationVue(), nbImages, CacheClient.getInstance().getPasPagination(), CacheClient.getInstance().getPageCouranteRechercheImage()) {
341
		PaginationPresenteur imagesPaginationPresenteur = new PaginationPresenteur(new PaginationVue(), nbImages, CacheClient.getInstance().getPasPagination(), CacheClient.getInstance().getPageCouranteRechercheImage()) {
341
			@Override
342
			@Override
342
			public void chargerElements(int debut, int fin) {
343
			public void chargerElements(int debut, int fin) {
343
				chargerEtAfficherImages(debut, fin);
344
				chargerEtAfficherImages(debut, fin);
344
				CacheClient.getInstance().setPageCouranteRechercheImages(getPageCourante());
345
				CacheClient.getInstance().setPageCouranteRechercheImages(getPageCourante());
345
			}
346
			}
346
 
347
 
347
			@Override
348
			@Override
348
			public void actualiserPasCache(int pas) {
349
			public void actualiserPasCache(int pas) {
349
				CacheClient.getInstance().setPasPagination(pas);
350
				CacheClient.getInstance().setPasPagination(pas);
350
			}
351
			}
351
		};
352
		};
352
		return imagesPaginationPresenteur;
353
		return imagesPaginationPresenteur;
353
	}
354
	}
354
 
355
 
355
	public void chargerEtAfficherImagesPageEnCours() {
356
	public void chargerEtAfficherImagesPageEnCours() {
356
		final int debut = (CacheClient.getInstance().getPageCouranteRechercheImage() - 1) * CacheClient.getInstance().getPasPagination();
357
		final int debut = (CacheClient.getInstance().getPageCouranteRechercheImage() - 1) * CacheClient.getInstance().getPasPagination();
357
		final int fin = (CacheClient.getInstance().getPageCouranteRechercheImage()) * CacheClient.getInstance().getPasPagination();
358
		final int fin = (CacheClient.getInstance().getPageCouranteRechercheImage()) * CacheClient.getInstance().getPasPagination();
358
		chargerEtAfficherImages(debut, fin);
359
		chargerEtAfficherImages(debut, fin);
359
		CacheClient.getInstance().mettreAjourUrlCourante();
-
 
360
	}
360
	}
361
 
361
 
362
	public Vue getVue() {
362
	public Vue getVue() {
363
		return vue;
363
		return vue;
364
	}
364
	}
365
}
365
}