140 |
aurelien |
1 |
package org.tela_botanica.del.client.vues.plateformedetermination.vote.barrerepartition;
|
|
|
2 |
|
186 |
aurelien |
3 |
import java.util.Date;
|
|
|
4 |
|
|
|
5 |
import org.tela_botanica.del.client.modeles.MoyenneVote;
|
|
|
6 |
import org.tela_botanica.del.client.modeles.VoteDetermination;
|
|
|
7 |
import org.tela_botanica.del.client.services.CalculVoteDeterminationService;
|
140 |
aurelien |
8 |
import org.tela_botanica.del.client.utils.MockDatasource;
|
|
|
9 |
|
186 |
aurelien |
10 |
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
11 |
import com.google.gwt.event.dom.client.ClickHandler;
|
|
|
12 |
import com.google.gwt.event.shared.HandlerRegistration;
|
172 |
aurelien |
13 |
import com.google.gwt.user.client.ui.HTML;
|
140 |
aurelien |
14 |
import com.google.gwt.user.client.ui.HasWidgets;
|
|
|
15 |
|
|
|
16 |
public class BarreRepartitionVotePresenteur {
|
|
|
17 |
|
|
|
18 |
private BarreRepartitionVoteVue vue = new BarreRepartitionVoteVue();
|
|
|
19 |
|
|
|
20 |
private MockDatasource validationService = MockDatasource.getInstance();
|
186 |
aurelien |
21 |
|
|
|
22 |
private MoyenneVote moyenneVote;
|
|
|
23 |
|
140 |
aurelien |
24 |
public void go(HasWidgets container) {
|
|
|
25 |
container.add(vue);
|
|
|
26 |
}
|
|
|
27 |
|
186 |
aurelien |
28 |
public void afficherVotes(MoyenneVote moyenneVote) {
|
|
|
29 |
this.moyenneVote = moyenneVote;
|
|
|
30 |
vue.afficherVotes(moyenneVote.getScore(), moyenneVote.getIntituleAssocie());
|
|
|
31 |
gererEvenements();
|
140 |
aurelien |
32 |
}
|
|
|
33 |
|
|
|
34 |
public BarreRepartitionVoteVue getBarreRepartitionVoteVue() {
|
|
|
35 |
return vue;
|
|
|
36 |
}
|
172 |
aurelien |
37 |
|
|
|
38 |
public HTML getBarreRepartitionVoteVueHTML() {
|
|
|
39 |
return vue.getBarreRepartitionHtmlBrut();
|
|
|
40 |
}
|
186 |
aurelien |
41 |
|
|
|
42 |
public void gererEvenements() {
|
|
|
43 |
|
|
|
44 |
vue.getBoutonOui().addClickHandler(new ClickHandler() {
|
|
|
45 |
|
|
|
46 |
@Override
|
|
|
47 |
public void onClick(ClickEvent event) {
|
|
|
48 |
VoteDetermination vd = new VoteDetermination();
|
|
|
49 |
vd.setContributeur("test");
|
|
|
50 |
vd.setDate(new Date());
|
|
|
51 |
vd.setVote(1);
|
|
|
52 |
vd.setId("3");
|
|
|
53 |
|
|
|
54 |
moyenneVote.getPropositionAssociee().ajouterVoteDetermination(vd);
|
|
|
55 |
moyenneVote = CalculVoteDeterminationService.calculerVoteDetermination(moyenneVote.getPropositionAssociee());
|
|
|
56 |
afficherVotes(moyenneVote);
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
});
|
|
|
60 |
|
|
|
61 |
vue.getBoutonNon().addClickHandler(new ClickHandler() {
|
|
|
62 |
|
|
|
63 |
@Override
|
|
|
64 |
public void onClick(ClickEvent event) {
|
|
|
65 |
VoteDetermination vd = new VoteDetermination();
|
|
|
66 |
vd.setContributeur("test");
|
|
|
67 |
vd.setDate(new Date());
|
|
|
68 |
vd.setVote(0);
|
|
|
69 |
vd.setId("3");
|
|
|
70 |
|
|
|
71 |
moyenneVote.getPropositionAssociee().ajouterVoteDetermination(vd);
|
|
|
72 |
moyenneVote = CalculVoteDeterminationService.calculerVoteDetermination(moyenneVote.getPropositionAssociee());
|
|
|
73 |
afficherVotes(moyenneVote);
|
|
|
74 |
}
|
|
|
75 |
});
|
|
|
76 |
}
|
140 |
aurelien |
77 |
}
|