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 |
|
194 |
aurelien |
54 |
vue.getBoutonOui().setEnabled(false);
|
|
|
55 |
vue.getBoutonNon().setEnabled(true);
|
|
|
56 |
|
186 |
aurelien |
57 |
moyenneVote.getPropositionAssociee().ajouterVoteDetermination(vd);
|
|
|
58 |
moyenneVote = CalculVoteDeterminationService.calculerVoteDetermination(moyenneVote.getPropositionAssociee());
|
|
|
59 |
afficherVotes(moyenneVote);
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
});
|
|
|
63 |
|
|
|
64 |
vue.getBoutonNon().addClickHandler(new ClickHandler() {
|
|
|
65 |
|
|
|
66 |
@Override
|
|
|
67 |
public void onClick(ClickEvent event) {
|
|
|
68 |
VoteDetermination vd = new VoteDetermination();
|
|
|
69 |
vd.setContributeur("test");
|
|
|
70 |
vd.setDate(new Date());
|
|
|
71 |
vd.setVote(0);
|
|
|
72 |
vd.setId("3");
|
|
|
73 |
|
194 |
aurelien |
74 |
vue.getBoutonOui().setEnabled(true);
|
|
|
75 |
vue.getBoutonNon().setEnabled(false);
|
|
|
76 |
|
186 |
aurelien |
77 |
moyenneVote.getPropositionAssociee().ajouterVoteDetermination(vd);
|
|
|
78 |
moyenneVote = CalculVoteDeterminationService.calculerVoteDetermination(moyenneVote.getPropositionAssociee());
|
|
|
79 |
afficherVotes(moyenneVote);
|
|
|
80 |
}
|
|
|
81 |
});
|
|
|
82 |
}
|
140 |
aurelien |
83 |
}
|