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