Subversion Repositories eFlore/Applications.del

Rev

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

Rev 1969 Rev 2050
1
package org.tela_botanica.del.client.vues.identiplante.resultats;
1
package org.tela_botanica.del.client.vues.identiplante.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.composants.presenteur.Presenteur;
8
import org.tela_botanica.del.client.composants.presenteur.Presenteur;
-
 
9
import org.tela_botanica.del.client.gestionhistorique.ConstantesNavigation;
9
import org.tela_botanica.del.client.modeles.Image;
10
import org.tela_botanica.del.client.modeles.Image;
10
import org.tela_botanica.del.client.modeles.InformationsRecherche;
11
import org.tela_botanica.del.client.modeles.InformationsRecherche;
11
import org.tela_botanica.del.client.modeles.ModeTri;
12
import org.tela_botanica.del.client.modeles.ModeTri;
12
import org.tela_botanica.del.client.modeles.Observation;
13
import org.tela_botanica.del.client.modeles.Observation;
13
import org.tela_botanica.del.client.modeles.ObservationServiceResultat;
14
import org.tela_botanica.del.client.modeles.ObservationServiceResultat;
-
 
15
import org.tela_botanica.del.client.modeles.Utilisateur;
14
import org.tela_botanica.del.client.services.rest.ObservationService;
16
import org.tela_botanica.del.client.services.rest.ObservationService;
15
import org.tela_botanica.del.client.services.rest.async.ObservationsCallback;
17
import org.tela_botanica.del.client.services.rest.async.ObservationsCallback;
-
 
18
import org.tela_botanica.del.client.utils.StringUtils;
16
import org.tela_botanica.del.client.vues.identiplante.resultats.observations.ObservationPresenteur;
19
import org.tela_botanica.del.client.vues.identiplante.resultats.observations.ObservationPresenteur;
17
import org.tela_botanica.del.client.vues.identiplante.resultats.observations.ObservationVue;
20
import org.tela_botanica.del.client.vues.identiplante.resultats.observations.ObservationVue;
18
 
21
 
19
import com.google.gwt.event.dom.client.ClickEvent;
22
import com.google.gwt.event.dom.client.ClickEvent;
20
import com.google.gwt.event.dom.client.ClickHandler;
23
import com.google.gwt.event.dom.client.ClickHandler;
21
import com.google.gwt.event.dom.client.HasClickHandlers;
24
import com.google.gwt.event.dom.client.HasClickHandlers;
22
import com.google.gwt.user.client.Window;
25
import com.google.gwt.user.client.Window;
23
import com.google.gwt.user.client.ui.HasWidgets;
26
import com.google.gwt.user.client.ui.HasWidgets;
24
import com.google.gwt.user.client.ui.IsWidget;
27
import com.google.gwt.user.client.ui.IsWidget;
25
import com.google.gwt.user.client.ui.Label;
28
import com.google.gwt.user.client.ui.Label;
26
 
29
 
27
public class ResultatsIdentiplantePresenteur extends Presenteur {
30
public class ResultatsIdentiplantePresenteur extends Presenteur {
28
 
31
 
29
	/**
32
	/**
30
	 * Interface vue : création des composants graphiques
33
	 * Interface vue : création des composants graphiques
31
	 * */
34
	 * */
32
	public abstract interface Vue extends IsWidget {
35
	public abstract interface Vue extends IsWidget {
33
		public HasWidgets getZoneObservations();
36
		public HasWidgets getZoneObservations();
34
 
37
 
35
		public HasWidgets getZonePaginationHaut();
38
		public HasWidgets getZonePaginationHaut();
36
 
39
 
37
		public HasWidgets getZonePaginationBas();
40
		public HasWidgets getZonePaginationBas();
38
 
41
 
39
		public void startChargement();
42
		public void startChargement();
40
 
43
 
41
		public void stopChargement();
44
		public void stopChargement();
42
 
45
 
43
		public void nettoyer();
46
		public void nettoyer();
44
 
47
 
45
		public HasClickHandlers getTriParDateObservationAscendant();
48
		public HasClickHandlers getTriParDateObservationAscendant();
46
 
49
 
47
		public HasClickHandlers getTriParDateObservationDescendant();
50
		public HasClickHandlers getTriParDateObservationDescendant();
48
		
51
		
49
		public HasClickHandlers getTriParDatePublicationAscendant();
52
		public HasClickHandlers getTriParDatePublicationAscendant();
50
 
53
 
51
		public HasClickHandlers getTriParDatePublicationDescendant();
54
		public HasClickHandlers getTriParDatePublicationDescendant();
52
		
55
		
53
		public HasClickHandlers getTriParNbCommentairesAscendant();
56
		public HasClickHandlers getTriParNbCommentairesAscendant();
54
 
57
 
55
		public HasClickHandlers getTriParNbCommentairesDescendant();
58
		public HasClickHandlers getTriParNbCommentairesDescendant();
56
 
59
 
57
		public void afficherElementsAucunResultatTrouve();
60
		public void afficherElementsAucunResultatTrouve();
58
 
61
 
59
		public void afficherElementsResultatsTrouves();
62
		public void afficherElementsResultatsTrouves();
60
 
63
 
61
		public HasClickHandlers getLabelDateObservation();
64
		public HasClickHandlers getLabelDateObservation();
62
		
65
		
63
		public HasClickHandlers getLabelDatePublication();
66
		public HasClickHandlers getLabelDatePublication();
64
		
67
		
65
		public HasClickHandlers getLabelNbCommentaires();
68
		public HasClickHandlers getLabelNbCommentaires();
66
 
69
 
67
		void setModeTriPublication(ModeTri mode);
70
		void setModeTriPublication(ModeTri mode);
68
 
71
 
69
		void setModeTriObservation(ModeTri mode);
72
		void setModeTriObservation(ModeTri mode);
70
 
73
 
71
		void setModeTriNbCommentaires(ModeTri mode);
74
		void setModeTriNbCommentaires(ModeTri mode);
-
 
75
		
-
 
76
		void afficherCacherZoneTri(boolean afficher);
72
	}
77
	}
73
 
78
 
74
	private Vue vue;
79
	private Vue vue;
75
	private ObservationService serviceObs;
80
	private ObservationService serviceObs;
76
	private ModeTri triCourantDatePublication = ModeTri.TRI_DESCENDANT;
81
	private ModeTri triCourantDatePublication = ModeTri.TRI_DESCENDANT;
77
	private ModeTri triCourantDateObservation = ModeTri.PAS_DE_TRI;
82
	private ModeTri triCourantDateObservation = ModeTri.PAS_DE_TRI;
78
	private ModeTri triCourantNbCommentaires = ModeTri.PAS_DE_TRI;
83
	private ModeTri triCourantNbCommentaires = ModeTri.PAS_DE_TRI;
79
	private CacheClient cache = CacheClient.getInstance();
84
	private CacheClient cache = CacheClient.getInstance();
80
	private String statut;
85
	private String statut;
81
 
86
 
82
	/**
87
	/**
83
	 * Constructeur de la classe
88
	 * Constructeur de la classe
84
	 * 
89
	 * 
85
	 * @param ObservationService
90
	 * @param ObservationService
86
	 *            serviceObs le service pour récupérer les observations
91
	 *            serviceObs le service pour récupérer les observations
87
	 * @Vue Vue l'objet implémentant l'interface
92
	 * @Vue Vue l'objet implémentant l'interface
88
	 * */
93
	 * */
89
	public ResultatsIdentiplantePresenteur(ObservationService serviceObs, Vue vue) {
94
	public ResultatsIdentiplantePresenteur(ObservationService serviceObs, Vue vue) {
90
		String statut = CacheClient.getInstance().getFiltreStatut();
95
		String statut = CacheClient.getInstance().getFiltreStatut();
91
		this.vue = vue;
96
		this.vue = vue;
92
		InformationsRecherche infos = CacheClient.getInstance().getInformationsRechercheObservation();
97
		InformationsRecherche infos = CacheClient.getInstance().getInformationsRechercheObservation();
93
		
98
		
94
		if (infos.getTriParDatePublication() != ModeTri.PAS_DE_TRI) {
99
		if (infos.getTriParDatePublication() != ModeTri.PAS_DE_TRI) {
95
			triCourantDatePublication = infos.getTriParDatePublication();
100
			triCourantDatePublication = infos.getTriParDatePublication();
96
			vue.setModeTriPublication(triCourantDatePublication);
101
			vue.setModeTriPublication(triCourantDatePublication);
97
		}
102
		}
98
		
103
		
99
		if (infos.getTriParDateObservation() != ModeTri.PAS_DE_TRI) {
104
		if (infos.getTriParDateObservation() != ModeTri.PAS_DE_TRI) {
100
			triCourantDateObservation = infos.getTriParDateObservation();
105
			triCourantDateObservation = infos.getTriParDateObservation();
101
			vue.setModeTriObservation(triCourantDatePublication);
106
			vue.setModeTriObservation(triCourantDatePublication);
102
		}
107
		}
103
			
108
			
104
		if (infos.getTriParNbCommentaires() != ModeTri.PAS_DE_TRI) {
109
		if (infos.getTriParNbCommentaires() != ModeTri.PAS_DE_TRI) {
105
			triCourantNbCommentaires = infos.getTriParNbCommentaires();
110
			triCourantNbCommentaires = infos.getTriParNbCommentaires();
106
			vue.setModeTriNbCommentaires(triCourantNbCommentaires);
111
			vue.setModeTriNbCommentaires(triCourantNbCommentaires);
107
		}
112
		}
108
		
113
		
109
		this.serviceObs = serviceObs;
114
		this.serviceObs = serviceObs;
110
		this.statut = statut;
115
		this.statut = statut;
111
	}
116
	}
112
 
117
 
113
	/**
118
	/**
114
	 * Lancer l'affichage de la recherche dans le composant passé en paramètre
119
	 * Lancer l'affichage de la recherche dans le composant passé en paramètre
115
	 * 
120
	 * 
116
	 * @param HasWidgets composite le conteneur de widgets dans lequel ajouter la vue
121
	 * @param HasWidgets composite le conteneur de widgets dans lequel ajouter la vue
117
	 * */
122
	 * */
118
	public void go(HasWidgets composite) {
123
	public void go(HasWidgets composite) {
119
		composite.add(vue.asWidget());
124
		composite.add(vue.asWidget());
120
		lancerRechercheEtCreerWidgetPagination();
125
		lancerRechercheEtCreerWidgetPagination();
121
		gererEvenements();
126
		gererEvenements();
122
	}
127
	}
123
 
128
 
124
	/**
129
	/**
125
	 * Initier un callback pour créer le widget de pagination et afficher les
130
	 * Initier un callback pour créer le widget de pagination et afficher les
126
	 * observations recues et lancer la recherche avec le service
131
	 * observations recues et lancer la recherche avec le service
127
	 * */
132
	 * */
128
	public void lancerRechercheEtCreerWidgetPagination() {
133
	public void lancerRechercheEtCreerWidgetPagination() {
129
 
134
		
130
		int debut = (cache.getPageCouranteRechercheObservations() - 1) * cache.getPasPagination();
135
		int debut = (cache.getPageCouranteRechercheObservations() - 1) * cache.getPasPagination();
131
		int fin = cache.getPageCouranteRechercheObservations() * cache.getPasPagination();
136
		int fin = cache.getPageCouranteRechercheObservations() * cache.getPasPagination();
132
 
137
 
133
		ObservationsCallback callback = new ObservationsCallback() {
138
		ObservationsCallback callback = new ObservationsCallback() {
134
 
139
 
135
			@Override
140
			@Override
136
			public void surRetour(ObservationServiceResultat observationsRecues) {
141
			public void surRetour(ObservationServiceResultat observationsRecues) {
137
				creerWidgetPagination(observationsRecues.getNbTotalObservationsPourLaRecherche());
142
				creerWidgetPagination(observationsRecues.getNbTotalObservationsPourLaRecherche());
138
				afficherObservations(observationsRecues);
143
				afficherObservations(observationsRecues);
139
 
144
 
140
			}
145
			}
141
 
146
 
142
			@Override
147
			@Override
143
			public void surErreur(String messageErreur) {
148
			public void surErreur(String messageErreur) {
144
				Window.alert(messageErreur);
149
				Window.alert(messageErreur);
145
 
150
 
146
			}
151
			}
147
		};
152
		};
148
 
153
 
149
		serviceObs.getObservations(cache.getInformationsRechercheObservation(), debut, fin, statut, callback);
154
		serviceObs.getObservations(cache.getInformationsRechercheObservation(), debut, fin, statut, callback);
150
	}
155
	}
151
 
156
 
152
	/**
157
	/**
153
	 * Créer les widgets de pagination en fonction du nombre d'observation
158
	 * Créer les widgets de pagination en fonction du nombre d'observation
154
	 * 
159
	 * 
155
	 * @param int nbObservations le nombre d'observations à afficher
160
	 * @param int nbObservations le nombre d'observations à afficher
156
	 * */
161
	 * */
157
	private void creerWidgetPagination(int nbObservations) {
162
	private void creerWidgetPagination(int nbObservations) {
158
		vue.getZonePaginationHaut().clear();
163
		vue.getZonePaginationHaut().clear();
159
		PaginationPresenteur paginationPresenteurHaut = creerPresenteurPagination(nbObservations);
164
		PaginationPresenteur paginationPresenteurHaut = creerPresenteurPagination(nbObservations);
160
		paginationPresenteurHaut.setGroupePagination("pagination_observations");
165
		paginationPresenteurHaut.setGroupePagination("pagination_observations");
161
		paginationPresenteurHaut.go(vue.getZonePaginationHaut());
166
		paginationPresenteurHaut.go(vue.getZonePaginationHaut());
162
 
167
 
163
		vue.getZonePaginationBas().clear();
168
		vue.getZonePaginationBas().clear();
164
		PaginationPresenteur paginationPresenteurBas = creerPresenteurPagination(nbObservations);
169
		PaginationPresenteur paginationPresenteurBas = creerPresenteurPagination(nbObservations);
165
		paginationPresenteurBas.setGroupePagination("pagination_observations");
170
		paginationPresenteurBas.setGroupePagination("pagination_observations");
166
		paginationPresenteurBas.go(vue.getZonePaginationBas());
171
		paginationPresenteurBas.go(vue.getZonePaginationBas());
167
	}
172
	}
168
 
173
 
169
	/**
174
	/**
170
	 * Créer un présenteur du widget pagination
175
	 * Créer un présenteur du widget pagination
171
	 * 
176
	 * 
172
	 * @param int nbObservations le nombre total d'observation à afficher
177
	 * @param int nbObservations le nombre total d'observation à afficher
173
	 * */
178
	 * */
174
	private PaginationPresenteur creerPresenteurPagination(int nbObservations) {
179
	private PaginationPresenteur creerPresenteurPagination(int nbObservations) {
175
		PaginationPresenteur presenteur = new PaginationPresenteur(new PaginationVue(), nbObservations, cache.getPasPagination(), cache.getPageCouranteRechercheObservations()) {
180
		PaginationPresenteur presenteur = new PaginationPresenteur(new PaginationVue(), nbObservations, cache.getPasPagination(), cache.getPageCouranteRechercheObservations()) {
176
 
181
 
177
			@Override
182
			@Override
178
			public void chargerElements(int debut, int fin) {
183
			public void chargerElements(int debut, int fin) {
179
				chargerEtAfficherObservations(debut, fin);
184
				chargerEtAfficherObservations(debut, fin);
180
				cache.setPageCouranteRechercheObservations(getPageCourante());
185
				cache.setPageCouranteRechercheObservations(getPageCourante());
181
			}
186
			}
182
 
187
 
183
			@Override
188
			@Override
184
			public void actualiserPasCache(int pas) {
189
			public void actualiserPasCache(int pas) {
185
				cache.setPasPagination(pas);
190
				cache.setPasPagination(pas);
186
			}
191
			}
187
 
192
 
188
		};
193
		};
189
		return presenteur;
194
		return presenteur;
190
	}
195
	}
191
 
196
 
192
	/**
197
	/**
193
	 * Gestion des évènements de la vue recherche Observation
198
	 * Gestion des évènements de la vue recherche Observation
194
	 * */
199
	 * */
195
	protected void gererEvenements() {
200
	protected void gererEvenements() {
196
 
201
 
197
		ClickHandler surClicDateObservation = new ClickHandler() {
202
		ClickHandler surClicDateObservation = new ClickHandler() {
198
			/**
203
			/**
199
			 * Gestion du clic sur l'option de tri par date d'observation Masque
204
			 * Gestion du clic sur l'option de tri par date d'observation Masque
200
			 * les éléments de tri qui sont en cours et affiche les autres
205
			 * les éléments de tri qui sont en cours et affiche les autres
201
			 * */
206
			 * */
202
			public void onClick(ClickEvent event) {
207
			public void onClick(ClickEvent event) {
203
				toggleModeTriObservation();
208
				toggleModeTriObservation();
204
 
209
 
205
				InformationsRecherche informationsRechercheObservations = cache.getInformationsRechercheObservation();
210
				InformationsRecherche informationsRechercheObservations = cache.getInformationsRechercheObservation();
206
				informationsRechercheObservations.setTriParDatePublication(ModeTri.PAS_DE_TRI);
211
				informationsRechercheObservations.setTriParDatePublication(ModeTri.PAS_DE_TRI);
207
				informationsRechercheObservations.setTriParNbCommentaires(ModeTri.PAS_DE_TRI);
212
				informationsRechercheObservations.setTriParNbCommentaires(ModeTri.PAS_DE_TRI);
208
				informationsRechercheObservations.setTriParDateObservation(triCourantDateObservation);
213
				informationsRechercheObservations.setTriParDateObservation(triCourantDateObservation);
209
				chercherEtAfficherObservationsPageEnCours();
214
				chercherEtAfficherObservationsPageEnCours();
210
			}
215
			}
211
		};
216
		};
212
		
217
		
213
		ClickHandler surClicDatePublication = new ClickHandler() {
218
		ClickHandler surClicDatePublication = new ClickHandler() {
214
			/**
219
			/**
215
			 * Gestion du clic sur l'option de tri par date d'observation Masque
220
			 * Gestion du clic sur l'option de tri par date d'observation Masque
216
			 * les éléments de tri qui sont en cours et affiche les autres
221
			 * les éléments de tri qui sont en cours et affiche les autres
217
			 * */
222
			 * */
218
			public void onClick(ClickEvent event) {
223
			public void onClick(ClickEvent event) {
219
				toggleModeTriPublication();
224
				toggleModeTriPublication();
220
 
225
 
221
				InformationsRecherche informationsRechercheObservations = cache.getInformationsRechercheObservation();
226
				InformationsRecherche informationsRechercheObservations = cache.getInformationsRechercheObservation();
222
				informationsRechercheObservations.setTriParDateObservation(ModeTri.PAS_DE_TRI);
227
				informationsRechercheObservations.setTriParDateObservation(ModeTri.PAS_DE_TRI);
223
				informationsRechercheObservations.setTriParNbCommentaires(ModeTri.PAS_DE_TRI);
228
				informationsRechercheObservations.setTriParNbCommentaires(ModeTri.PAS_DE_TRI);
224
				informationsRechercheObservations.setTriParDatePublication(triCourantDatePublication);
229
				informationsRechercheObservations.setTriParDatePublication(triCourantDatePublication);
225
 
230
 
226
				chercherEtAfficherObservationsPageEnCours();
231
				chercherEtAfficherObservationsPageEnCours();
227
			}
232
			}
228
		};
233
		};
229
		
234
		
230
		ClickHandler surClicNbCommentaires = new ClickHandler() {
235
		ClickHandler surClicNbCommentaires = new ClickHandler() {
231
			/**
236
			/**
232
			 * Même comportement qu'au dessus mais pour le tri par nb de commentaires
237
			 * Même comportement qu'au dessus mais pour le tri par nb de commentaires
233
			 */
238
			 */
234
			public void onClick(ClickEvent event) {
239
			public void onClick(ClickEvent event) {
235
				toggleModeTriNbCommentaires();
240
				toggleModeTriNbCommentaires();
236
 
241
 
237
				InformationsRecherche informationsRechercheObservations = cache.getInformationsRechercheObservation();
242
				InformationsRecherche informationsRechercheObservations = cache.getInformationsRechercheObservation();
238
				informationsRechercheObservations.setTriParDateObservation(ModeTri.PAS_DE_TRI);
243
				informationsRechercheObservations.setTriParDateObservation(ModeTri.PAS_DE_TRI);
239
				informationsRechercheObservations.setTriParDatePublication(ModeTri.PAS_DE_TRI);
244
				informationsRechercheObservations.setTriParDatePublication(ModeTri.PAS_DE_TRI);
240
				informationsRechercheObservations.setTriParNbCommentaires(triCourantNbCommentaires);
245
				informationsRechercheObservations.setTriParNbCommentaires(triCourantNbCommentaires);
241
				chercherEtAfficherObservationsPageEnCours();
246
				chercherEtAfficherObservationsPageEnCours();
242
			}
247
			}
243
		};
248
		};
244
 
249
 
245
		vue.getLabelDateObservation().addClickHandler(surClicDateObservation);
250
		vue.getLabelDateObservation().addClickHandler(surClicDateObservation);
246
		vue.getTriParDateObservationAscendant().addClickHandler(surClicDateObservation);
251
		vue.getTriParDateObservationAscendant().addClickHandler(surClicDateObservation);
247
		vue.getTriParDateObservationDescendant().addClickHandler(surClicDateObservation);
252
		vue.getTriParDateObservationDescendant().addClickHandler(surClicDateObservation);
248
		
253
		
249
		vue.getLabelDatePublication().addClickHandler(surClicDatePublication);
254
		vue.getLabelDatePublication().addClickHandler(surClicDatePublication);
250
		vue.getTriParDatePublicationAscendant().addClickHandler(surClicDatePublication);
255
		vue.getTriParDatePublicationAscendant().addClickHandler(surClicDatePublication);
251
		vue.getTriParDatePublicationDescendant().addClickHandler(surClicDatePublication);
256
		vue.getTriParDatePublicationDescendant().addClickHandler(surClicDatePublication);
252
		
257
		
253
		vue.getLabelNbCommentaires().addClickHandler(surClicNbCommentaires);
258
		vue.getLabelNbCommentaires().addClickHandler(surClicNbCommentaires);
254
		vue.getTriParNbCommentairesAscendant().addClickHandler(surClicNbCommentaires);
259
		vue.getTriParNbCommentairesAscendant().addClickHandler(surClicNbCommentaires);
255
		vue.getTriParNbCommentairesDescendant().addClickHandler(surClicNbCommentaires);
260
		vue.getTriParNbCommentairesDescendant().addClickHandler(surClicNbCommentaires);
256
	}
261
	}
257
 
262
 
258
	/**
263
	/**
259
	 * Inverser le mode de tri en fonction du précédent
264
	 * Inverser le mode de tri en fonction du précédent
260
	 * */
265
	 * */
261
	public void toggleModeTriPublication() {
266
	public void toggleModeTriPublication() {
262
		if (triCourantDatePublication == ModeTri.TRI_ASCENDANT) {
267
		if (triCourantDatePublication == ModeTri.TRI_ASCENDANT) {
263
			triCourantDatePublication = ModeTri.TRI_DESCENDANT;
268
			triCourantDatePublication = ModeTri.TRI_DESCENDANT;
264
		} else if(triCourantDatePublication == ModeTri.TRI_DESCENDANT) {
269
		} else if(triCourantDatePublication == ModeTri.TRI_DESCENDANT) {
265
			triCourantDatePublication = ModeTri.TRI_ASCENDANT;
270
			triCourantDatePublication = ModeTri.TRI_ASCENDANT;
266
		} else {
271
		} else {
267
			triCourantDatePublication = ModeTri.TRI_DESCENDANT;
272
			triCourantDatePublication = ModeTri.TRI_DESCENDANT;
268
		}
273
		}
269
		
274
		
270
		triCourantDateObservation = ModeTri.PAS_DE_TRI;
275
		triCourantDateObservation = ModeTri.PAS_DE_TRI;
271
		triCourantNbCommentaires = ModeTri.PAS_DE_TRI;
276
		triCourantNbCommentaires = ModeTri.PAS_DE_TRI;
272
 
277
 
273
		vue.setModeTriPublication(triCourantDatePublication);
278
		vue.setModeTriPublication(triCourantDatePublication);
274
	}
279
	}
275
	
280
	
276
	/**
281
	/**
277
	 * Inverser le mode de tri en fonction du précédent
282
	 * Inverser le mode de tri en fonction du précédent
278
	 * */
283
	 * */
279
	public void toggleModeTriObservation() {
284
	public void toggleModeTriObservation() {
280
		if (triCourantDateObservation == ModeTri.TRI_ASCENDANT) {
285
		if (triCourantDateObservation == ModeTri.TRI_ASCENDANT) {
281
			triCourantDateObservation = ModeTri.TRI_DESCENDANT;
286
			triCourantDateObservation = ModeTri.TRI_DESCENDANT;
282
		} else if(triCourantDateObservation == ModeTri.TRI_DESCENDANT) {
287
		} else if(triCourantDateObservation == ModeTri.TRI_DESCENDANT) {
283
			triCourantDateObservation = ModeTri.TRI_ASCENDANT;
288
			triCourantDateObservation = ModeTri.TRI_ASCENDANT;
284
		} else {
289
		} else {
285
			triCourantDateObservation = ModeTri.TRI_DESCENDANT;
290
			triCourantDateObservation = ModeTri.TRI_DESCENDANT;
286
		}
291
		}
287
		
292
		
288
		triCourantDatePublication = ModeTri.PAS_DE_TRI;
293
		triCourantDatePublication = ModeTri.PAS_DE_TRI;
289
		triCourantNbCommentaires = ModeTri.PAS_DE_TRI;
294
		triCourantNbCommentaires = ModeTri.PAS_DE_TRI;
290
 
295
 
291
		vue.setModeTriObservation(triCourantDateObservation);
296
		vue.setModeTriObservation(triCourantDateObservation);
292
	}
297
	}
293
	
298
	
294
	/**
299
	/**
295
	 * Inverser le mode de tri en fonction du précédent
300
	 * Inverser le mode de tri en fonction du précédent
296
	 * */
301
	 * */
297
	public void toggleModeTriNbCommentaires() {
302
	public void toggleModeTriNbCommentaires() {
298
		if (triCourantNbCommentaires == ModeTri.TRI_ASCENDANT) {
303
		if (triCourantNbCommentaires == ModeTri.TRI_ASCENDANT) {
299
			triCourantNbCommentaires = ModeTri.TRI_DESCENDANT;
304
			triCourantNbCommentaires = ModeTri.TRI_DESCENDANT;
300
		} else if(triCourantNbCommentaires == ModeTri.TRI_DESCENDANT) {
305
		} else if(triCourantNbCommentaires == ModeTri.TRI_DESCENDANT) {
301
			triCourantNbCommentaires = ModeTri.TRI_ASCENDANT;
306
			triCourantNbCommentaires = ModeTri.TRI_ASCENDANT;
302
		} else {
307
		} else {
303
			triCourantNbCommentaires = ModeTri.TRI_DESCENDANT;
308
			triCourantNbCommentaires = ModeTri.TRI_DESCENDANT;
304
		}
309
		}
305
		
310
		
306
		triCourantDateObservation = ModeTri.PAS_DE_TRI;
311
		triCourantDateObservation = ModeTri.PAS_DE_TRI;
307
		triCourantDatePublication = ModeTri.PAS_DE_TRI;
312
		triCourantDatePublication = ModeTri.PAS_DE_TRI;
308
 
313
 
309
		vue.setModeTriNbCommentaires(triCourantNbCommentaires);
314
		vue.setModeTriNbCommentaires(triCourantNbCommentaires);
310
	}
315
	}
311
 
316
 
312
	/**
317
	/**
313
	 * Initialiser les variable de début et fin et lancer le chargement des
318
	 * Initialiser les variable de début et fin et lancer le chargement des
314
	 * observations
319
	 * observations
315
	 * */
320
	 * */
316
	public void chercherEtAfficherObservationsPageEnCours() {
321
	public void chercherEtAfficherObservationsPageEnCours() {
317
		int debut = (cache.getPageCouranteRechercheObservations() - 1) * cache.getPasPagination();
322
		int debut = (cache.getPageCouranteRechercheObservations() - 1) * cache.getPasPagination();
318
		int fin = (cache.getPageCouranteRechercheObservations()) * cache.getPasPagination();
323
		int fin = (cache.getPageCouranteRechercheObservations()) * cache.getPasPagination();
319
		chargerEtAfficherObservations(debut, fin);
324
		chargerEtAfficherObservations(debut, fin);
320
	}
325
	}
321
 
326
 
322
	/**
327
	/**
323
	 * Lancer le service pour charger les observations entre debut et fin et les
328
	 * Lancer le service pour charger les observations entre debut et fin et les
324
	 * afficher
329
	 * afficher
325
	 * 
330
	 * 
326
	 * @param int debut l'entier de départ de la requete
331
	 * @param int debut l'entier de départ de la requete
327
	 * @param int fin l'entier de limite de la requete
332
	 * @param int fin l'entier de limite de la requete
328
	 * */
333
	 * */
329
	public void chargerEtAfficherObservations(int debut, int fin) {
334
	public void chargerEtAfficherObservations(int debut, int fin) {
330
		vue.startChargement();
335
		vue.startChargement();
331
		vue.nettoyer();
336
		vue.nettoyer();
332
 
337
 
333
		ObservationsCallback surReceptionObservation = new ObservationsCallback() {
338
		ObservationsCallback surReceptionObservation = new ObservationsCallback() {
334
 
339
 
335
			@Override
340
			@Override
336
			public void surRetour(ObservationServiceResultat observationsRecues) {
341
			public void surRetour(ObservationServiceResultat observationsRecues) {
337
				afficherObservations(observationsRecues);
342
				afficherObservations(observationsRecues);
338
 
343
 
339
			}
344
			}
340
 
345
 
341
			@Override
346
			@Override
342
			public void surErreur(String messageErreur) {
347
			public void surErreur(String messageErreur) {
343
				Window.alert(messageErreur);
348
				Window.alert(messageErreur);
344
 
349
 
345
			}
350
			}
346
		};
351
		};
347
		serviceObs.getObservations(cache.getInformationsRechercheObservation(), debut, fin, statut, surReceptionObservation);
352
		serviceObs.getObservations(cache.getInformationsRechercheObservation(), debut, fin, statut, surReceptionObservation);
348
	}
353
	}
349
 
354
 
350
	/**
355
	/**
351
	 * Parcrourir les résultats de la recherche pour initier l'affichage de
356
	 * Parcrourir les résultats de la recherche pour initier l'affichage de
352
	 * chaque observation
357
	 * chaque observation
353
	 * 
358
	 * 
354
	 * @param ObservationServiceResultat
359
	 * @param ObservationServiceResultat
355
	 *            resultats les résultats issus de la requête
360
	 *            resultats les résultats issus de la requête
356
	 * */
361
	 * */
357
	private void afficherObservations(ObservationServiceResultat resultats) {
362
	private void afficherObservations(ObservationServiceResultat resultats) {
358
		vue.nettoyer();
363
		vue.nettoyer();
359
 
364
 
360
		if (resultats.getObservations() == null || resultats.getObservations().size() == 0) {
365
		if (resultats.getObservations() == null || resultats.getObservations().size() == 0) {
361
			vue.afficherElementsAucunResultatTrouve();
366
			vue.afficherElementsAucunResultatTrouve();
362
		} else {
367
		} else {
363
			vue.afficherElementsResultatsTrouves();
368
			vue.afficherElementsResultatsTrouves();
-
 
369
			
-
 
370
			// Si on consulte l'onglet mon activité, on cache le tri qui n'a pas de sens ici car c'est une timeline
-
 
371
			vue.afficherCacherZoneTri(!cache.getFiltreStatut().equals(ConstantesNavigation.PARAM_TYPE_MONACTIVITE));
-
 
372
			// S'il y a de nouveau évènements sur l'obs, elle doit être mise en valeur
-
 
373
			// les x premieres obs sont affichées un peu différemment (où x est le nombre de nouveaux évènements)
-
 
374
			int i = 0;
-
 
375
			int nbEvents = CacheClient.getInstance().getUtilisateur().getNbEvenementsInt();
-
 
376
			
364
			for (Observation observation : resultats.getObservations()) {
377
			for (Observation observation : resultats.getObservations()) {
365
				List<Image> listeImagesObs = observation.getImages();
378
				List<Image> listeImagesObs = observation.getImages();
366
				Image imagePrincipale = null;
379
				Image imagePrincipale = null;
367
				if(listeImagesObs != null && listeImagesObs.size() > 0) {
380
				if(listeImagesObs != null && listeImagesObs.size() > 0) {
368
					imagePrincipale = listeImagesObs.get(0);
381
					imagePrincipale = listeImagesObs.get(0);
369
				}
382
				}
370
				ObservationPresenteur presenteur = new ObservationPresenteur(new ObservationVue(), observation, imagePrincipale);
383
				ObservationPresenteur presenteur = new ObservationPresenteur(new ObservationVue(), observation, imagePrincipale);
371
				presenteur.go(vue.getZoneObservations());
384
				presenteur.go(vue.getZoneObservations());
-
 
385
				
-
 
386
				if(nbEvents != 0 && i <= nbEvents) {
-
 
387
					presenteur.mettreEnValeurEvenementsObs();
-
 
388
				}
-
 
389
				i++;
372
			}
390
			}
373
		}
391
		}
374
		CacheClient.getInstance().mettreAjourUrlCourante();
392
		CacheClient.getInstance().mettreAjourUrlCourante();
375
		vue.stopChargement();
393
		vue.stopChargement();
376
	}
394
	}
377
}
395
}