178 |
benjamin |
1 |
package org.tela_botanica.del.client.vues.rechercheimages.resultats.images;
|
|
|
2 |
|
|
|
3 |
import java.util.List;
|
|
|
4 |
|
250 |
gduche |
5 |
import org.tela_botanica.del.client.composants.presenteur.Presenteur;
|
178 |
benjamin |
6 |
import org.tela_botanica.del.client.modeles.Image;
|
|
|
7 |
import org.tela_botanica.del.client.modeles.Protocole;
|
|
|
8 |
import org.tela_botanica.del.client.modeles.VoteProtocole;
|
|
|
9 |
import org.tela_botanica.del.client.navigation.evenement.BusEvenementiel;
|
|
|
10 |
import org.tela_botanica.del.client.navigation.evenement.validationobservation.EvenementValidation;
|
|
|
11 |
import org.tela_botanica.del.client.utils.MockDatasource;
|
|
|
12 |
import org.tela_botanica.del.client.vues.rechercheimages.resultats.ResultatRechercheImagePresenteur;
|
|
|
13 |
import org.tela_botanica.del.client.vues.rechercheimages.vote.MoyenneVotePresenteur;
|
250 |
gduche |
14 |
import org.tela_botanica.del.client.vues.rechercheobservations.DetailImagePresenteur;
|
311 |
gduche |
15 |
import org.tela_botanica.del.client.vues.rechercheobservations.DetailImageVue;
|
178 |
benjamin |
16 |
|
|
|
17 |
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
18 |
import com.google.gwt.event.dom.client.ClickHandler;
|
311 |
gduche |
19 |
import com.google.gwt.event.dom.client.HasClickHandlers;
|
178 |
benjamin |
20 |
import com.google.gwt.user.client.ui.HasWidgets;
|
311 |
gduche |
21 |
import com.google.gwt.user.client.ui.IsWidget;
|
178 |
benjamin |
22 |
|
250 |
gduche |
23 |
public class ImagePresenteur extends Presenteur {
|
178 |
benjamin |
24 |
|
311 |
gduche |
25 |
public interface Vue extends IsWidget {
|
|
|
26 |
|
|
|
27 |
public abstract void loadImage(Image image);
|
|
|
28 |
public abstract HasClickHandlers getImagePrincipale();
|
316 |
aurelien |
29 |
public void setUrlImagePrincipale(String url);
|
|
|
30 |
public void setTitreImagePrincipale(String titre);
|
|
|
31 |
public void setAltTextImagePrincipale(String altText);
|
|
|
32 |
public String getUrlImagePrincipale();
|
|
|
33 |
public String getTitreImagePrincipale();
|
|
|
34 |
public String getAltTextImagePrincipale();
|
311 |
gduche |
35 |
public abstract HasClickHandlers getEnSavoirPlus();
|
|
|
36 |
public abstract HasClickHandlers getAjoutValidation();
|
|
|
37 |
public abstract void cacherZoneCache();
|
|
|
38 |
public abstract void afficherZoneCache();
|
|
|
39 |
public abstract HasWidgets getZoneVoter();
|
|
|
40 |
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
private Vue vue;
|
|
|
44 |
|
178 |
benjamin |
45 |
private final MockDatasource validationService = MockDatasource.getInstance();
|
|
|
46 |
private final Image image;
|
|
|
47 |
private boolean detailsOpen = false;
|
|
|
48 |
|
|
|
49 |
private Protocole protocole;
|
|
|
50 |
|
311 |
gduche |
51 |
public ImagePresenteur(Image image, Protocole protocole, Vue vue) {
|
178 |
benjamin |
52 |
this.image = image;
|
|
|
53 |
this.protocole = protocole;
|
311 |
gduche |
54 |
this.vue = vue;
|
178 |
benjamin |
55 |
}
|
|
|
56 |
|
|
|
57 |
public void go(HasWidgets composite) {
|
311 |
gduche |
58 |
composite.add(vue.asWidget());
|
178 |
benjamin |
59 |
vue.loadImage(image);
|
|
|
60 |
loadValidationData();
|
250 |
gduche |
61 |
gererEvenements();
|
178 |
benjamin |
62 |
}
|
|
|
63 |
|
|
|
64 |
private void loadValidationData() {
|
|
|
65 |
List<VoteProtocole> observationValidationDatas = validationService.getVoteByImageAndProtocol(image.getIdImage(), protocole.getNom());
|
311 |
gduche |
66 |
new MoyenneVotePresenteur(observationValidationDatas).go(vue.getZoneVoter());
|
178 |
benjamin |
67 |
}
|
|
|
68 |
|
250 |
gduche |
69 |
protected void gererEvenements() {
|
311 |
gduche |
70 |
vue.getImagePrincipale().addClickHandler(new ClickHandler() {
|
250 |
gduche |
71 |
|
|
|
72 |
@Override
|
|
|
73 |
public void onClick(ClickEvent event) {
|
316 |
aurelien |
74 |
IsWidget photo = (IsWidget)event.getSource();
|
|
|
75 |
ouvrirFenetreModale(new DetailImagePresenteur(photo , new DetailImageVue()));
|
250 |
gduche |
76 |
}
|
|
|
77 |
});
|
311 |
gduche |
78 |
vue.getEnSavoirPlus().addClickHandler(new ClickHandler() {
|
178 |
benjamin |
79 |
|
|
|
80 |
@Override
|
|
|
81 |
public void onClick(ClickEvent event) {
|
|
|
82 |
|
|
|
83 |
if (!detailsOpen) {
|
|
|
84 |
afficherDetails();
|
|
|
85 |
} else {
|
|
|
86 |
cacherDetails();
|
|
|
87 |
}
|
|
|
88 |
}
|
|
|
89 |
});
|
|
|
90 |
|
311 |
gduche |
91 |
vue.getAjoutValidation().addClickHandler(new ClickHandler() {
|
178 |
benjamin |
92 |
|
|
|
93 |
@Override
|
|
|
94 |
public void onClick(ClickEvent event) {
|
|
|
95 |
BusEvenementiel.getInstance().fireEvent(new EvenementValidation(image));
|
|
|
96 |
}
|
|
|
97 |
});
|
|
|
98 |
}
|
|
|
99 |
|
|
|
100 |
public void cacherDetails() {
|
311 |
gduche |
101 |
vue.cacherZoneCache();
|
178 |
benjamin |
102 |
detailsOpen = false;
|
|
|
103 |
}
|
|
|
104 |
|
|
|
105 |
public void afficherDetails() {
|
|
|
106 |
ResultatRechercheImagePresenteur.getInstance().fermerTousPanneauxDetailsObservations();
|
311 |
gduche |
107 |
vue.afficherZoneCache();
|
178 |
benjamin |
108 |
|
|
|
109 |
detailsOpen = true;
|
|
|
110 |
}
|
|
|
111 |
|
|
|
112 |
public boolean isDetailsOpen() {
|
|
|
113 |
return detailsOpen;
|
|
|
114 |
}
|
|
|
115 |
|
|
|
116 |
}
|