478 |
benjamin |
1 |
package org.tela_botanica.del.client.vues.rechercheimages.resultats.votes;
|
9 |
benjamin |
2 |
|
|
|
3 |
import java.util.List;
|
|
|
4 |
|
423 |
gduche |
5 |
import org.tela_botanica.del.client.modeles.Protocole;
|
148 |
benjamin |
6 |
import org.tela_botanica.del.client.modeles.VoteProtocole;
|
423 |
gduche |
7 |
import org.tela_botanica.del.client.services.rest.VoteProtocoleService;
|
|
|
8 |
import org.tela_botanica.del.client.utils.MockDatasource;
|
9 |
benjamin |
9 |
|
423 |
gduche |
10 |
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
11 |
import com.google.gwt.event.dom.client.ClickHandler;
|
|
|
12 |
import com.google.gwt.user.client.Window;
|
9 |
benjamin |
13 |
import com.google.gwt.user.client.ui.HasWidgets;
|
|
|
14 |
|
14 |
benjamin |
15 |
public class MoyenneVotePresenteur {
|
9 |
benjamin |
16 |
|
423 |
gduche |
17 |
private MoyenneVoteVue vue;
|
|
|
18 |
private Protocole protocole;
|
|
|
19 |
private final VoteProtocoleService voteProtocoleService = MockDatasource.getInstance();
|
|
|
20 |
private String idImage;
|
|
|
21 |
private final MockDatasource validationService = MockDatasource.getInstance();
|
|
|
22 |
|
|
|
23 |
public MoyenneVotePresenteur(List<VoteProtocole> validationDatas, String idImage, Protocole protocole) {
|
|
|
24 |
vue = new MoyenneVoteVue(validationDatas);
|
|
|
25 |
this.protocole = protocole;
|
|
|
26 |
this.idImage = idImage;
|
9 |
benjamin |
27 |
}
|
|
|
28 |
|
|
|
29 |
public void go(HasWidgets container) {
|
423 |
gduche |
30 |
container.add(vue);
|
|
|
31 |
gererEvenements();
|
9 |
benjamin |
32 |
}
|
423 |
gduche |
33 |
|
|
|
34 |
public void gererEvenements() {
|
|
|
35 |
vue.getVotes().addClickHandler(new ClickHandler() {
|
|
|
36 |
@Override
|
|
|
37 |
public void onClick(ClickEvent event) {
|
|
|
38 |
vue.afficherBoutonVoter();
|
|
|
39 |
vue.afficherBoutonAnnuler();
|
|
|
40 |
vue.masquerNbVotes();
|
|
|
41 |
}
|
|
|
42 |
});
|
|
|
43 |
|
|
|
44 |
vue.getBoutonAnnuler().addClickHandler(new ClickHandler() {
|
|
|
45 |
@Override
|
|
|
46 |
public void onClick(ClickEvent event) {
|
|
|
47 |
vue.masquerBoutonVoter();
|
|
|
48 |
vue.masquerBoutonAnnuler();
|
|
|
49 |
vue.afficherNbVotes();
|
|
|
50 |
vue.reinitialiserVotes();
|
|
|
51 |
}
|
|
|
52 |
});
|
|
|
53 |
|
|
|
54 |
vue.getBoutonVoter().addClickHandler(new ClickHandler() {
|
|
|
55 |
@Override
|
|
|
56 |
public void onClick(ClickEvent event) {
|
|
|
57 |
|
|
|
58 |
enregistrerVote();
|
|
|
59 |
vue.masquerBoutonVoter();
|
|
|
60 |
vue.masquerBoutonAnnuler();
|
|
|
61 |
vue.afficherNbVotes();
|
|
|
62 |
vue.reinitialiserVotes();
|
|
|
63 |
}
|
|
|
64 |
});
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
public void enregistrerVote() {
|
|
|
68 |
VoteProtocole voteProtocole = new VoteProtocole();
|
|
|
69 |
voteProtocole.setProtocole(this.protocole);
|
|
|
70 |
voteProtocoleService.saveVote(idImage, voteProtocole);
|
|
|
71 |
|
500 |
aurelien |
72 |
List<VoteProtocole> observationValidationDatas = validationService.getVotePourImageEtProtocole(idImage, protocole.getNom());
|
423 |
gduche |
73 |
vue.rafraichir(observationValidationDatas);
|
|
|
74 |
}
|
9 |
benjamin |
75 |
}
|