50 |
benjamin |
1 |
package org.tela_botanica.del.client.vues.comparaisoneflore;
|
|
|
2 |
|
1062 |
benjamin |
3 |
import java.util.ArrayList;
|
50 |
benjamin |
4 |
import java.util.List;
|
|
|
5 |
|
73 |
benjamin |
6 |
import org.tela_botanica.del.client.cache.CacheClient;
|
1069 |
benjamin |
7 |
import org.tela_botanica.del.client.composants.fenetreoverlay.FenetreOverlayDefilanteVue;
|
|
|
8 |
import org.tela_botanica.del.client.composants.fenetreoverlay.FenetreOverlaySimplePresenteur;
|
|
|
9 |
import org.tela_botanica.del.client.composants.images.DetailImagePresenteur;
|
|
|
10 |
import org.tela_botanica.del.client.composants.images.DetailImageVue;
|
148 |
benjamin |
11 |
import org.tela_botanica.del.client.modeles.Image;
|
352 |
aurelien |
12 |
import org.tela_botanica.del.client.modeles.ImageServiceResultat;
|
1037 |
benjamin |
13 |
import org.tela_botanica.del.client.modeles.InformationsRecherche;
|
1062 |
benjamin |
14 |
import org.tela_botanica.del.client.navigation.evenement.BusEvenementiel;
|
|
|
15 |
import org.tela_botanica.del.client.navigation.evenement.comparaisoneflore.EvenementComparaisonEflore;
|
|
|
16 |
import org.tela_botanica.del.client.navigation.evenement.comparaisoneflore.GestionnaireEvenementComparaisonEflore;
|
284 |
benjamin |
17 |
import org.tela_botanica.del.client.services.rest.ImageService;
|
352 |
aurelien |
18 |
import org.tela_botanica.del.client.services.rest.async.ImagesParTaxonCallback;
|
1062 |
benjamin |
19 |
import org.tela_botanica.del.client.vues.plateformedetermination.formulairerechercheeflore.FormulaireRechercheEflorePresenteur;
|
50 |
benjamin |
20 |
|
|
|
21 |
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
22 |
import com.google.gwt.event.dom.client.ClickHandler;
|
284 |
benjamin |
23 |
import com.google.gwt.event.dom.client.HasClickHandlers;
|
939 |
benjamin |
24 |
import com.google.gwt.user.client.Window;
|
1062 |
benjamin |
25 |
import com.google.gwt.user.client.ui.HTMLPanel;
|
50 |
benjamin |
26 |
import com.google.gwt.user.client.ui.HasWidgets;
|
284 |
benjamin |
27 |
import com.google.gwt.user.client.ui.IsWidget;
|
50 |
benjamin |
28 |
|
|
|
29 |
public class ComparaisonEflorePresenteur {
|
|
|
30 |
|
284 |
benjamin |
31 |
public interface Vue extends IsWidget {
|
|
|
32 |
public void chargerImagePrincipale(org.tela_botanica.del.client.modeles.Image image);
|
|
|
33 |
|
|
|
34 |
public void chargerImagesEflore(List<org.tela_botanica.del.client.modeles.Image> observationsEflore, int indexImage);
|
|
|
35 |
|
|
|
36 |
public HasClickHandlers getScrollLeftImage();
|
|
|
37 |
|
|
|
38 |
public HasClickHandlers getScrollRightImage();
|
|
|
39 |
|
|
|
40 |
public int getCurrentIndexImages();
|
361 |
benjamin |
41 |
|
939 |
benjamin |
42 |
public void startChargement();
|
|
|
43 |
|
361 |
benjamin |
44 |
public void stopChargement();
|
1062 |
benjamin |
45 |
|
|
|
46 |
public void afficherAucuneImageTrouvee();
|
|
|
47 |
|
|
|
48 |
public HTMLPanel getFormulaireRecherche();
|
|
|
49 |
|
|
|
50 |
public void setCurrentIndexImages(int index);
|
1069 |
benjamin |
51 |
|
|
|
52 |
public com.google.gwt.user.client.ui.Image getImagePrincipale();
|
|
|
53 |
|
|
|
54 |
public com.google.gwt.user.client.ui.Image getImageEflore();
|
284 |
benjamin |
55 |
}
|
|
|
56 |
|
|
|
57 |
private Vue vue;
|
359 |
benjamin |
58 |
private final ImageService imageService;
|
284 |
benjamin |
59 |
|
148 |
benjamin |
60 |
private Image imagePrincipale;
|
50 |
benjamin |
61 |
private String nomTaxonComparaison;
|
1062 |
benjamin |
62 |
private List<org.tela_botanica.del.client.modeles.Image> imagesEflore = new ArrayList<Image>();
|
|
|
63 |
private int page = 0;
|
|
|
64 |
private int nbImagesPreFetch = 10;
|
62 |
benjamin |
65 |
|
882 |
aurelien |
66 |
public ComparaisonEflorePresenteur(Vue vue, ImageService imageService) {
|
284 |
benjamin |
67 |
this.vue = vue;
|
148 |
benjamin |
68 |
this.imagePrincipale = CacheClient.getInstance().getImageCourante();
|
73 |
benjamin |
69 |
this.nomTaxonComparaison = CacheClient.getInstance().getTaxonPourRechercheEflore();
|
360 |
benjamin |
70 |
this.imageService = imageService;
|
50 |
benjamin |
71 |
}
|
|
|
72 |
|
|
|
73 |
public void go(HasWidgets composite) {
|
284 |
benjamin |
74 |
composite.add(vue.asWidget());
|
148 |
benjamin |
75 |
vue.chargerImagePrincipale(imagePrincipale);
|
50 |
benjamin |
76 |
chargerObservationsEflore();
|
|
|
77 |
gererEvenements();
|
1062 |
benjamin |
78 |
new FormulaireRechercheEflorePresenteur().go(vue.getFormulaireRecherche());
|
50 |
benjamin |
79 |
}
|
|
|
80 |
|
284 |
benjamin |
81 |
public void chargerObservationsEflore() {
|
939 |
benjamin |
82 |
|
1062 |
benjamin |
83 |
int debut = (page * nbImagesPreFetch) + 1;
|
|
|
84 |
int fin = (page + 1) * nbImagesPreFetch;
|
|
|
85 |
|
361 |
benjamin |
86 |
vue.startChargement();
|
360 |
benjamin |
87 |
|
1037 |
benjamin |
88 |
InformationsRecherche informationsRecherche = new InformationsRecherche();
|
|
|
89 |
informationsRecherche.setTaxon(nomTaxonComparaison);
|
|
|
90 |
|
352 |
aurelien |
91 |
ImagesParTaxonCallback callback = new ImagesParTaxonCallback() {
|
360 |
benjamin |
92 |
|
352 |
aurelien |
93 |
@Override
|
939 |
benjamin |
94 |
public void surRetour(ImageServiceResultat imagesRecues) {
|
1062 |
benjamin |
95 |
if (imagesRecues == null || imagesRecues.getImages() == null || imagesRecues.getImages().size() == 0) {
|
|
|
96 |
vue.afficherAucuneImageTrouvee();
|
1037 |
benjamin |
97 |
} else {
|
1062 |
benjamin |
98 |
addImagesEflore(imagesRecues.getImages());
|
1037 |
benjamin |
99 |
vue.stopChargement();
|
1062 |
benjamin |
100 |
vue.chargerImagesEflore(imagesEflore, vue.getCurrentIndexImages());
|
1037 |
benjamin |
101 |
}
|
352 |
aurelien |
102 |
}
|
939 |
benjamin |
103 |
|
|
|
104 |
@Override
|
|
|
105 |
public void surErreur(String messageErreur) {
|
1062 |
benjamin |
106 |
vue.afficherAucuneImageTrouvee();
|
939 |
benjamin |
107 |
Window.alert(messageErreur);
|
|
|
108 |
}
|
|
|
109 |
|
352 |
aurelien |
110 |
};
|
360 |
benjamin |
111 |
|
1062 |
benjamin |
112 |
imageService.getImagesParTaxon(informationsRecherche, debut, fin, callback);
|
360 |
benjamin |
113 |
|
50 |
benjamin |
114 |
}
|
|
|
115 |
|
|
|
116 |
private void gererEvenements() {
|
284 |
benjamin |
117 |
vue.getScrollLeftImage().addClickHandler(new ClickHandler() {
|
50 |
benjamin |
118 |
|
|
|
119 |
@Override
|
|
|
120 |
public void onClick(ClickEvent event) {
|
148 |
benjamin |
121 |
vue.chargerImagesEflore(imagesEflore, vue.getCurrentIndexImages() - 1);
|
50 |
benjamin |
122 |
}
|
|
|
123 |
});
|
62 |
benjamin |
124 |
|
284 |
benjamin |
125 |
vue.getScrollRightImage().addClickHandler(new ClickHandler() {
|
50 |
benjamin |
126 |
|
|
|
127 |
@Override
|
|
|
128 |
public void onClick(ClickEvent event) {
|
1062 |
benjamin |
129 |
|
|
|
130 |
if (vue.getCurrentIndexImages() == imagesEflore.size() - 1) {
|
|
|
131 |
page += 1;
|
|
|
132 |
vue.setCurrentIndexImages(vue.getCurrentIndexImages()+1);
|
|
|
133 |
chargerObservationsEflore();
|
|
|
134 |
} else {
|
|
|
135 |
vue.chargerImagesEflore(imagesEflore, vue.getCurrentIndexImages() + 1);
|
|
|
136 |
}
|
50 |
benjamin |
137 |
}
|
|
|
138 |
});
|
1062 |
benjamin |
139 |
|
|
|
140 |
BusEvenementiel.getInstance().addHandler(EvenementComparaisonEflore.TYPE, new GestionnaireEvenementComparaisonEflore() {
|
|
|
141 |
|
|
|
142 |
@Override
|
|
|
143 |
public void onComparaisonEflore(EvenementComparaisonEflore event) {
|
|
|
144 |
nomTaxonComparaison = event.getTaxonDemande();
|
1064 |
benjamin |
145 |
page=0;
|
|
|
146 |
vue.setCurrentIndexImages(0);
|
|
|
147 |
getImagesEflore().clear();
|
1062 |
benjamin |
148 |
chargerObservationsEflore();
|
|
|
149 |
}
|
|
|
150 |
});
|
1069 |
benjamin |
151 |
|
|
|
152 |
vue.getImagePrincipale().addClickHandler(new ClickHandler() {
|
|
|
153 |
|
|
|
154 |
@Override
|
|
|
155 |
public void onClick(ClickEvent arg0) {
|
|
|
156 |
FenetreOverlaySimplePresenteur presenteurGalerie = new FenetreOverlaySimplePresenteur(new FenetreOverlayDefilanteVue());
|
|
|
157 |
presenteurGalerie.ouvrirFenetreModaleDefilante(0, new DetailImagePresenteur(imagePrincipale, new DetailImageVue()));
|
|
|
158 |
presenteurGalerie.afficherBoutonsSuivantsPrecedents(false);
|
|
|
159 |
}
|
|
|
160 |
});
|
|
|
161 |
|
|
|
162 |
vue.getImageEflore().addClickHandler(new ClickHandler() {
|
|
|
163 |
|
|
|
164 |
@Override
|
|
|
165 |
public void onClick(ClickEvent arg0) {
|
|
|
166 |
FenetreOverlaySimplePresenteur presenteurGalerie = new FenetreOverlaySimplePresenteur(new FenetreOverlayDefilanteVue());
|
|
|
167 |
presenteurGalerie.ouvrirFenetreModaleDefilante(0, new DetailImagePresenteur(imagesEflore.get(vue.getCurrentIndexImages()), new DetailImageVue()));
|
|
|
168 |
presenteurGalerie.afficherBoutonsSuivantsPrecedents(false);
|
|
|
169 |
}
|
|
|
170 |
});
|
50 |
benjamin |
171 |
}
|
|
|
172 |
|
284 |
benjamin |
173 |
public List<org.tela_botanica.del.client.modeles.Image> getImagesEflore() {
|
|
|
174 |
return imagesEflore;
|
|
|
175 |
}
|
|
|
176 |
|
1062 |
benjamin |
177 |
public void addImagesEflore(List<org.tela_botanica.del.client.modeles.Image> imagesEflore) {
|
|
|
178 |
this.imagesEflore.addAll(imagesEflore);
|
360 |
benjamin |
179 |
}
|
1069 |
benjamin |
180 |
|
|
|
181 |
|
360 |
benjamin |
182 |
|
50 |
benjamin |
183 |
}
|