178 |
benjamin |
1 |
package org.tela_botanica.del.client.vues.rechercheimages.resultats.images;
|
|
|
2 |
|
|
|
3 |
import java.util.List;
|
|
|
4 |
|
|
|
5 |
import org.tela_botanica.del.client.modeles.Image;
|
|
|
6 |
import org.tela_botanica.del.client.modeles.Protocole;
|
|
|
7 |
import org.tela_botanica.del.client.modeles.VoteProtocole;
|
|
|
8 |
import org.tela_botanica.del.client.navigation.evenement.BusEvenementiel;
|
|
|
9 |
import org.tela_botanica.del.client.navigation.evenement.validationobservation.EvenementValidation;
|
|
|
10 |
import org.tela_botanica.del.client.utils.MockDatasource;
|
|
|
11 |
import org.tela_botanica.del.client.vues.rechercheimages.resultats.ResultatRechercheImagePresenteur;
|
|
|
12 |
import org.tela_botanica.del.client.vues.rechercheimages.vote.MoyenneVotePresenteur;
|
|
|
13 |
|
|
|
14 |
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
15 |
import com.google.gwt.event.dom.client.ClickHandler;
|
|
|
16 |
import com.google.gwt.user.client.ui.HasWidgets;
|
|
|
17 |
import com.google.gwt.user.client.ui.Label;
|
|
|
18 |
import com.google.gwt.user.client.ui.VerticalPanel;
|
|
|
19 |
|
|
|
20 |
public class ImagePresenteur {
|
|
|
21 |
|
|
|
22 |
private final MockDatasource validationService = MockDatasource.getInstance();
|
|
|
23 |
private ImageVue vue = new ImageVue();
|
|
|
24 |
private final Image image;
|
|
|
25 |
private boolean detailsOpen = false;
|
|
|
26 |
|
|
|
27 |
private Protocole protocole;
|
|
|
28 |
|
|
|
29 |
public ImagePresenteur(Image image, Protocole protocole) {
|
|
|
30 |
this.image = image;
|
|
|
31 |
this.protocole = protocole;
|
|
|
32 |
}
|
|
|
33 |
|
|
|
34 |
public void go(HasWidgets composite) {
|
|
|
35 |
composite.add(vue);
|
|
|
36 |
vue.loadImage(image);
|
|
|
37 |
loadValidationData();
|
|
|
38 |
handleEvents();
|
|
|
39 |
|
|
|
40 |
}
|
|
|
41 |
|
|
|
42 |
private void loadValidationData() {
|
|
|
43 |
|
|
|
44 |
List<VoteProtocole> observationValidationDatas = validationService.getVoteByImageAndProtocol(image.getIdImage(), protocole.getNom());
|
|
|
45 |
new MoyenneVotePresenteur(observationValidationDatas).go(vue.getVoter());
|
|
|
46 |
|
|
|
47 |
}
|
|
|
48 |
|
|
|
49 |
private void handleEvents() {
|
|
|
50 |
|
|
|
51 |
vue.getEnSavoirPlus().addClickHandler(new ClickHandler() {
|
|
|
52 |
|
|
|
53 |
@Override
|
|
|
54 |
public void onClick(ClickEvent event) {
|
|
|
55 |
|
|
|
56 |
if (!detailsOpen) {
|
|
|
57 |
afficherDetails();
|
|
|
58 |
} else {
|
|
|
59 |
cacherDetails();
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
}
|
|
|
63 |
});
|
|
|
64 |
|
|
|
65 |
vue.getAjoutValidation().addClickHandler(new ClickHandler() {
|
|
|
66 |
|
|
|
67 |
@Override
|
|
|
68 |
public void onClick(ClickEvent event) {
|
|
|
69 |
BusEvenementiel.getInstance().fireEvent(new EvenementValidation(image));
|
|
|
70 |
}
|
|
|
71 |
});
|
|
|
72 |
}
|
|
|
73 |
|
|
|
74 |
public void cacherDetails() {
|
|
|
75 |
VerticalPanel zoneCache = vue.getZoneCache();
|
|
|
76 |
Label enSavoirPlus = vue.getEnSavoirPlus();
|
|
|
77 |
|
|
|
78 |
zoneCache.setVisible(false);
|
|
|
79 |
enSavoirPlus.setStyleName("boutonPlus");
|
|
|
80 |
|
|
|
81 |
detailsOpen = false;
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
public void afficherDetails() {
|
|
|
85 |
ResultatRechercheImagePresenteur.getInstance().fermerTousPanneauxDetailsObservations();
|
|
|
86 |
|
|
|
87 |
VerticalPanel zoneCache = vue.getZoneCache();
|
|
|
88 |
Label enSavoirPlus = vue.getEnSavoirPlus();
|
|
|
89 |
|
|
|
90 |
zoneCache.setVisible(true);
|
|
|
91 |
enSavoirPlus.setStyleName("boutonMoins");
|
|
|
92 |
|
|
|
93 |
detailsOpen = true;
|
|
|
94 |
}
|
|
|
95 |
|
|
|
96 |
public boolean isDetailsOpen() {
|
|
|
97 |
return detailsOpen;
|
|
|
98 |
}
|
|
|
99 |
|
|
|
100 |
public ImageVue getVue() {
|
|
|
101 |
return vue;
|
|
|
102 |
}
|
|
|
103 |
}
|