663 |
benjamin |
1 |
package org.tela_botanica.del.client.vues.plateformedetermination.forum.interventions;
|
|
|
2 |
|
978 |
gduche |
3 |
import org.tela_botanica.del.client.composants.fenetreoverlay.FenetreOverlayDefilanteVue;
|
|
|
4 |
import org.tela_botanica.del.client.composants.fenetreoverlay.FenetreOverlaySimplePresenteur;
|
|
|
5 |
import org.tela_botanica.del.client.composants.formulaires.formulairecommentaire.FormulaireCommentairePresenteur;
|
|
|
6 |
import org.tela_botanica.del.client.composants.formulaires.formulairecommentaire.FormulaireCommentaireVue;
|
663 |
benjamin |
7 |
import org.tela_botanica.del.client.composants.votes.barrerepartition.BarreRepartitionVotePresenteur;
|
|
|
8 |
import org.tela_botanica.del.client.composants.votes.barrerepartition.BarreRepartitionVoteVue;
|
|
|
9 |
import org.tela_botanica.del.client.modeles.Commentaire;
|
|
|
10 |
import org.tela_botanica.del.client.modeles.InterventionForum;
|
|
|
11 |
import org.tela_botanica.del.client.modeles.MoyenneVote;
|
|
|
12 |
import org.tela_botanica.del.client.modeles.PropositionDetermination;
|
|
|
13 |
import org.tela_botanica.del.client.services.CalculVoteDeterminationService;
|
978 |
gduche |
14 |
import org.tela_botanica.del.client.services.rest.CommentaireServiceConcret;
|
959 |
benjamin |
15 |
import org.tela_botanica.del.client.services.rest.VoteDeterminationServiceConcret;
|
663 |
benjamin |
16 |
import org.tela_botanica.del.client.vues.plateformedetermination.forum.ArbreCommentairePresenteur;
|
|
|
17 |
import org.tela_botanica.del.client.vues.plateformedetermination.forum.ArbreCommentaireVue;
|
|
|
18 |
|
978 |
gduche |
19 |
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
20 |
import com.google.gwt.event.dom.client.ClickHandler;
|
|
|
21 |
import com.google.gwt.event.dom.client.HasClickHandlers;
|
|
|
22 |
import com.google.gwt.user.client.Window;
|
663 |
benjamin |
23 |
import com.google.gwt.user.client.ui.HasWidgets;
|
|
|
24 |
import com.google.gwt.user.client.ui.IsWidget;
|
|
|
25 |
|
|
|
26 |
public class ForumInterventionPresenteur {
|
|
|
27 |
|
|
|
28 |
public interface Vue extends IsWidget {
|
|
|
29 |
void ajouterInterventionDetermination(PropositionDetermination determination, IsWidget barreRepartition, IsWidget arbreCommentaires);
|
|
|
30 |
void ajouterInterventionCommentaire(Commentaire commentaire, IsWidget arbreCommentaires);
|
978 |
gduche |
31 |
HasClickHandlers getRepondre();
|
|
|
32 |
HasWidgets getEnfants();
|
663 |
benjamin |
33 |
}
|
|
|
34 |
|
|
|
35 |
private Vue vue;
|
|
|
36 |
|
|
|
37 |
private InterventionForum interventionForum;
|
|
|
38 |
|
|
|
39 |
public ForumInterventionPresenteur(Vue vue, InterventionForum interventionForum) {
|
|
|
40 |
this.vue = vue;
|
|
|
41 |
this.interventionForum = interventionForum;
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
public void go(HasWidgets composite) {
|
|
|
45 |
chargerIntervention();
|
|
|
46 |
composite.add(vue.asWidget());
|
978 |
gduche |
47 |
gererEvenements();
|
663 |
benjamin |
48 |
}
|
978 |
gduche |
49 |
|
|
|
50 |
public void addEnfant(ForumInterventionPresenteur presenteur) {
|
|
|
51 |
presenteur.go(vue.getEnfants());
|
|
|
52 |
}
|
663 |
benjamin |
53 |
|
|
|
54 |
private void chargerIntervention() {
|
|
|
55 |
if (interventionForum instanceof PropositionDetermination) {
|
|
|
56 |
ajouterPropositionDetermination((PropositionDetermination) interventionForum);
|
|
|
57 |
} else if (interventionForum instanceof Commentaire) {
|
|
|
58 |
ajouterCommentaire((Commentaire) interventionForum);
|
|
|
59 |
}
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
private void ajouterPropositionDetermination(PropositionDetermination propositionDetermination) {
|
959 |
benjamin |
63 |
BarreRepartitionVotePresenteur barreRepartitionVotePresenteur = new BarreRepartitionVotePresenteur(new BarreRepartitionVoteVue(), new VoteDeterminationServiceConcret());
|
966 |
gduche |
64 |
barreRepartitionVotePresenteur.toggleNomEspece();
|
663 |
benjamin |
65 |
calculerEtAfficherVoteDetermination(barreRepartitionVotePresenteur, propositionDetermination);
|
|
|
66 |
ArbreCommentairePresenteur arbreCommentairePresenteur = new ArbreCommentairePresenteur(new ArbreCommentaireVue(), propositionDetermination);
|
|
|
67 |
vue.ajouterInterventionDetermination(propositionDetermination, barreRepartitionVotePresenteur.getBarreRepartitionVoteVue(), arbreCommentairePresenteur.getArbreCommentaireVue());
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
private void ajouterCommentaire(Commentaire proposition) {
|
|
|
71 |
ArbreCommentairePresenteur arbreCommentairePresenteur = new ArbreCommentairePresenteur(new ArbreCommentaireVue(), proposition);
|
|
|
72 |
vue.ajouterInterventionCommentaire(proposition, arbreCommentairePresenteur.getArbreCommentaireVue());
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
private void calculerEtAfficherVoteDetermination(BarreRepartitionVotePresenteur barreRepartitionVotePresenteur, PropositionDetermination propositionDetermination) {
|
|
|
76 |
MoyenneVote votes = CalculVoteDeterminationService.calculerVoteDetermination(propositionDetermination);
|
|
|
77 |
barreRepartitionVotePresenteur.afficherVotes(votes);
|
|
|
78 |
}
|
978 |
gduche |
79 |
|
|
|
80 |
private void gererEvenements() {
|
|
|
81 |
vue.getRepondre().addClickHandler(new ClickHandler() {
|
|
|
82 |
@Override
|
|
|
83 |
public void onClick(ClickEvent event) {
|
|
|
84 |
FormulaireCommentairePresenteur commentairePresenteur = new FormulaireCommentairePresenteur(interventionForum, new CommentaireServiceConcret(), new FormulaireCommentaireVue());
|
|
|
85 |
FenetreOverlaySimplePresenteur fenetreOverlaySimplePresenteur = new FenetreOverlaySimplePresenteur(new FenetreOverlayDefilanteVue());
|
|
|
86 |
fenetreOverlaySimplePresenteur.ouvrirFenetreModale(commentairePresenteur);
|
|
|
87 |
}
|
|
|
88 |
});
|
|
|
89 |
}
|
663 |
benjamin |
90 |
}
|