178 |
benjamin |
1 |
package org.tela_botanica.del.client.vues.rechercheimages.resultats.images;
|
|
|
2 |
|
|
|
3 |
import java.util.List;
|
|
|
4 |
|
332 |
gduche |
5 |
import org.tela_botanica.del.client.cache.CacheClient;
|
438 |
aurelien |
6 |
import org.tela_botanica.del.client.composants.fenetreOverlayDefilante.FenetreOverlayDefilantePresenteur;
|
|
|
7 |
import org.tela_botanica.del.client.composants.fenetreOverlayDefilante.FenetreOverlayDefilanteVue;
|
250 |
gduche |
8 |
import org.tela_botanica.del.client.composants.presenteur.Presenteur;
|
178 |
benjamin |
9 |
import org.tela_botanica.del.client.modeles.Image;
|
332 |
gduche |
10 |
import org.tela_botanica.del.client.modeles.Observation;
|
178 |
benjamin |
11 |
import org.tela_botanica.del.client.modeles.Protocole;
|
|
|
12 |
import org.tela_botanica.del.client.modeles.VoteProtocole;
|
|
|
13 |
import org.tela_botanica.del.client.navigation.evenement.BusEvenementiel;
|
360 |
benjamin |
14 |
import org.tela_botanica.del.client.navigation.evenement.changementprotocole.EvenementChangementProtocole;
|
|
|
15 |
import org.tela_botanica.del.client.navigation.evenement.changementprotocole.GestionnaireEvenementChangementProtocole;
|
359 |
benjamin |
16 |
import org.tela_botanica.del.client.navigation.evenement.rechercheimage.EvenementVoirDetailsImage;
|
|
|
17 |
import org.tela_botanica.del.client.navigation.evenement.rechercheimage.GestionnaireEvenementVoirDetailsImage;
|
178 |
benjamin |
18 |
import org.tela_botanica.del.client.navigation.evenement.validationobservation.EvenementValidation;
|
|
|
19 |
import org.tela_botanica.del.client.utils.MockDatasource;
|
|
|
20 |
import org.tela_botanica.del.client.vues.rechercheimages.vote.MoyenneVotePresenteur;
|
250 |
gduche |
21 |
import org.tela_botanica.del.client.vues.rechercheobservations.DetailImagePresenteur;
|
311 |
gduche |
22 |
import org.tela_botanica.del.client.vues.rechercheobservations.DetailImageVue;
|
178 |
benjamin |
23 |
|
|
|
24 |
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
25 |
import com.google.gwt.event.dom.client.ClickHandler;
|
311 |
gduche |
26 |
import com.google.gwt.event.dom.client.HasClickHandlers;
|
178 |
benjamin |
27 |
import com.google.gwt.user.client.ui.HasWidgets;
|
311 |
gduche |
28 |
import com.google.gwt.user.client.ui.IsWidget;
|
178 |
benjamin |
29 |
|
250 |
gduche |
30 |
public class ImagePresenteur extends Presenteur {
|
178 |
benjamin |
31 |
|
311 |
gduche |
32 |
public interface Vue extends IsWidget {
|
359 |
benjamin |
33 |
|
311 |
gduche |
34 |
public abstract void loadImage(Image image);
|
359 |
benjamin |
35 |
|
311 |
gduche |
36 |
public abstract HasClickHandlers getImagePrincipale();
|
363 |
gduche |
37 |
|
|
|
38 |
public IsWidget getImagePrincipaleWidget();
|
|
|
39 |
|
316 |
aurelien |
40 |
public void setUrlImagePrincipale(String url);
|
359 |
benjamin |
41 |
|
316 |
aurelien |
42 |
public void setTitreImagePrincipale(String titre);
|
359 |
benjamin |
43 |
|
316 |
aurelien |
44 |
public void setAltTextImagePrincipale(String altText);
|
359 |
benjamin |
45 |
|
316 |
aurelien |
46 |
public String getUrlImagePrincipale();
|
359 |
benjamin |
47 |
|
316 |
aurelien |
48 |
public String getTitreImagePrincipale();
|
359 |
benjamin |
49 |
|
316 |
aurelien |
50 |
public String getAltTextImagePrincipale();
|
359 |
benjamin |
51 |
|
311 |
gduche |
52 |
public abstract HasClickHandlers getEnSavoirPlus();
|
359 |
benjamin |
53 |
|
363 |
gduche |
54 |
public abstract HasClickHandlers getZoom();
|
359 |
benjamin |
55 |
|
311 |
gduche |
56 |
public abstract void cacherZoneCache();
|
359 |
benjamin |
57 |
|
311 |
gduche |
58 |
public abstract void afficherZoneCache();
|
359 |
benjamin |
59 |
|
311 |
gduche |
60 |
public abstract HasWidgets getZoneVoter();
|
359 |
benjamin |
61 |
|
363 |
gduche |
62 |
public HasClickHandlers getNomAuteur();
|
423 |
gduche |
63 |
|
363 |
gduche |
64 |
public HasClickHandlers getNomEspece();
|
311 |
gduche |
65 |
}
|
359 |
benjamin |
66 |
|
|
|
67 |
private Vue vue;
|
|
|
68 |
|
178 |
benjamin |
69 |
private final MockDatasource validationService = MockDatasource.getInstance();
|
|
|
70 |
private final Image image;
|
|
|
71 |
private boolean detailsOpen = false;
|
|
|
72 |
|
|
|
73 |
private Protocole protocole;
|
|
|
74 |
|
311 |
gduche |
75 |
public ImagePresenteur(Image image, Protocole protocole, Vue vue) {
|
178 |
benjamin |
76 |
this.image = image;
|
|
|
77 |
this.protocole = protocole;
|
311 |
gduche |
78 |
this.vue = vue;
|
178 |
benjamin |
79 |
}
|
|
|
80 |
|
|
|
81 |
public void go(HasWidgets composite) {
|
311 |
gduche |
82 |
composite.add(vue.asWidget());
|
178 |
benjamin |
83 |
vue.loadImage(image);
|
|
|
84 |
loadValidationData();
|
250 |
gduche |
85 |
gererEvenements();
|
178 |
benjamin |
86 |
}
|
|
|
87 |
|
|
|
88 |
private void loadValidationData() {
|
360 |
benjamin |
89 |
vue.getZoneVoter().clear();
|
178 |
benjamin |
90 |
List<VoteProtocole> observationValidationDatas = validationService.getVoteByImageAndProtocol(image.getIdImage(), protocole.getNom());
|
423 |
gduche |
91 |
new MoyenneVotePresenteur(observationValidationDatas, image.getIdImage(), protocole).go(vue.getZoneVoter());
|
|
|
92 |
|
178 |
benjamin |
93 |
}
|
|
|
94 |
|
363 |
gduche |
95 |
private void lancerEvenementValidation() {
|
|
|
96 |
|
|
|
97 |
CacheClient.getInstance().setImageCourante(image);
|
|
|
98 |
Observation obs = image.getObservation();
|
|
|
99 |
BusEvenementiel.getInstance().fireEvent(new EvenementValidation(obs));
|
|
|
100 |
}
|
|
|
101 |
|
250 |
gduche |
102 |
protected void gererEvenements() {
|
311 |
gduche |
103 |
vue.getImagePrincipale().addClickHandler(new ClickHandler() {
|
363 |
gduche |
104 |
public void onClick(ClickEvent event) {
|
|
|
105 |
lancerEvenementValidation();
|
|
|
106 |
}
|
|
|
107 |
});
|
359 |
benjamin |
108 |
|
363 |
gduche |
109 |
vue.getNomAuteur().addClickHandler(new ClickHandler() {
|
250 |
gduche |
110 |
public void onClick(ClickEvent event) {
|
363 |
gduche |
111 |
lancerEvenementValidation();
|
250 |
gduche |
112 |
}
|
|
|
113 |
});
|
363 |
gduche |
114 |
|
|
|
115 |
vue.getNomEspece().addClickHandler(new ClickHandler() {
|
|
|
116 |
public void onClick(ClickEvent event) {
|
|
|
117 |
lancerEvenementValidation();
|
|
|
118 |
}
|
|
|
119 |
});
|
|
|
120 |
|
311 |
gduche |
121 |
vue.getEnSavoirPlus().addClickHandler(new ClickHandler() {
|
178 |
benjamin |
122 |
|
|
|
123 |
@Override
|
|
|
124 |
public void onClick(ClickEvent event) {
|
359 |
benjamin |
125 |
BusEvenementiel.getInstance().fireEvent(new EvenementVoirDetailsImage(image));
|
178 |
benjamin |
126 |
}
|
|
|
127 |
});
|
|
|
128 |
|
363 |
gduche |
129 |
vue.getZoom().addClickHandler(new ClickHandler() {
|
178 |
benjamin |
130 |
public void onClick(ClickEvent event) {
|
438 |
aurelien |
131 |
FenetreOverlayDefilantePresenteur presenteurGalerie = new FenetreOverlayDefilantePresenteur(0, new FenetreOverlayDefilanteVue()) {
|
|
|
132 |
|
|
|
133 |
@Override
|
|
|
134 |
public void surClicBoutonSuivant() {
|
|
|
135 |
}
|
|
|
136 |
|
|
|
137 |
@Override
|
|
|
138 |
public void surClicBoutonPrecedent() {
|
|
|
139 |
}
|
|
|
140 |
};
|
|
|
141 |
presenteurGalerie.ouvrirFenetreModaleDefilante(0, new DetailImagePresenteur(image, new DetailImageVue()));
|
|
|
142 |
presenteurGalerie.afficherBoutonsSuivantsPrecedents(false);
|
178 |
benjamin |
143 |
}
|
|
|
144 |
});
|
359 |
benjamin |
145 |
|
|
|
146 |
BusEvenementiel.getInstance().addHandler(EvenementVoirDetailsImage.TYPE, new GestionnaireEvenementVoirDetailsImage() {
|
|
|
147 |
|
|
|
148 |
@Override
|
|
|
149 |
public void onVoirDetailsImage(EvenementVoirDetailsImage event) {
|
|
|
150 |
if (image.getIdImage().equals(event.getImage().getIdImage())) {
|
|
|
151 |
|
|
|
152 |
if (!detailsOpen) {
|
|
|
153 |
afficherDetails();
|
|
|
154 |
} else {
|
|
|
155 |
cacherDetails();
|
|
|
156 |
}
|
|
|
157 |
} else {
|
|
|
158 |
cacherDetails();
|
|
|
159 |
}
|
|
|
160 |
}
|
|
|
161 |
});
|
360 |
benjamin |
162 |
|
|
|
163 |
BusEvenementiel.getInstance().addHandler(EvenementChangementProtocole.TYPE, new GestionnaireEvenementChangementProtocole() {
|
|
|
164 |
|
|
|
165 |
@Override
|
|
|
166 |
public void onChangementProtocole(EvenementChangementProtocole event) {
|
|
|
167 |
setProtocole(event.getProtocole());
|
|
|
168 |
loadValidationData();
|
|
|
169 |
}
|
|
|
170 |
});
|
178 |
benjamin |
171 |
}
|
|
|
172 |
|
|
|
173 |
public void cacherDetails() {
|
311 |
gduche |
174 |
vue.cacherZoneCache();
|
178 |
benjamin |
175 |
detailsOpen = false;
|
|
|
176 |
}
|
|
|
177 |
|
|
|
178 |
public void afficherDetails() {
|
311 |
gduche |
179 |
vue.afficherZoneCache();
|
178 |
benjamin |
180 |
detailsOpen = true;
|
|
|
181 |
}
|
|
|
182 |
|
|
|
183 |
public boolean isDetailsOpen() {
|
|
|
184 |
return detailsOpen;
|
|
|
185 |
}
|
|
|
186 |
|
360 |
benjamin |
187 |
public Protocole getProtocole() {
|
|
|
188 |
return protocole;
|
|
|
189 |
}
|
|
|
190 |
|
|
|
191 |
public void setProtocole(Protocole protocole) {
|
|
|
192 |
this.protocole = protocole;
|
|
|
193 |
}
|
|
|
194 |
|
178 |
benjamin |
195 |
}
|