1196 |
gduche |
1 |
package org.tela_botanica.del.client.vues.identiplante.resultats.observationdeterminations;
|
|
|
2 |
|
|
|
3 |
import org.tela_botanica.del.client.composants.commentaires.DetailCommentairePresenteur;
|
|
|
4 |
import org.tela_botanica.del.client.composants.commentaires.DetailCommentaireVue;
|
|
|
5 |
import org.tela_botanica.del.client.composants.fenetreoverlay.FenetreOverlayDefilanteVue;
|
|
|
6 |
import org.tela_botanica.del.client.composants.fenetreoverlay.FenetreOverlaySimplePresenteur;
|
|
|
7 |
import org.tela_botanica.del.client.composants.votes.details.DetailListeVotesDeterminationPresenteur;
|
|
|
8 |
import org.tela_botanica.del.client.composants.votes.details.DetailListeVotesDeterminationVue;
|
|
|
9 |
import org.tela_botanica.del.client.modeles.PropositionDetermination;
|
1524 |
mathias |
10 |
import org.tela_botanica.del.client.modeles.VoteDetermination;
|
|
|
11 |
import org.tela_botanica.del.client.navigation.evenement.BusEvenementiel;
|
|
|
12 |
import org.tela_botanica.del.client.navigation.evenement.voteDetermination.EvenementVoteDetermination;
|
|
|
13 |
import org.tela_botanica.del.client.navigation.evenement.voteDetermination.GestionnaireEvenementVoteDetermination;
|
1196 |
gduche |
14 |
import org.tela_botanica.del.client.services.rest.CommentaireServiceConcret;
|
|
|
15 |
|
|
|
16 |
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
17 |
import com.google.gwt.event.dom.client.ClickHandler;
|
|
|
18 |
import com.google.gwt.event.dom.client.HasClickHandlers;
|
|
|
19 |
import com.google.gwt.user.client.ui.HasWidgets;
|
|
|
20 |
import com.google.gwt.user.client.ui.IsWidget;
|
|
|
21 |
|
|
|
22 |
public class LignePropositionPresenteur {
|
|
|
23 |
|
|
|
24 |
private int nbCommentaires, nbVotes;
|
|
|
25 |
|
|
|
26 |
public abstract interface Vue extends IsWidget {
|
|
|
27 |
public HasClickHandlers getZoneNbVotes();
|
|
|
28 |
|
|
|
29 |
public HasClickHandlers getZoneNbCommentaires();
|
|
|
30 |
|
|
|
31 |
public void setNbVotes(int nbVotes);
|
|
|
32 |
|
|
|
33 |
public void setNbCommentaires(int nbCommentaires);
|
|
|
34 |
|
|
|
35 |
public void enleverLienCommentaires();
|
|
|
36 |
|
|
|
37 |
public void enleverLienVotes();
|
|
|
38 |
|
|
|
39 |
public void ajouterLienVotes();
|
1833 |
aurelien |
40 |
|
|
|
41 |
public void setPropositionRetenue(boolean propositionRetenue);
|
1196 |
gduche |
42 |
}
|
|
|
43 |
|
|
|
44 |
private Vue vue;
|
|
|
45 |
|
|
|
46 |
private PropositionDetermination propositionDetermination;
|
|
|
47 |
|
|
|
48 |
public LignePropositionPresenteur(Vue vue,
|
|
|
49 |
PropositionDetermination propositionDetermination) {
|
|
|
50 |
this.vue = vue;
|
|
|
51 |
this.propositionDetermination = propositionDetermination;
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
public void go(HasWidgets composite) {
|
|
|
55 |
composite.add(vue.asWidget());
|
|
|
56 |
chargerPropositionDetermination();
|
|
|
57 |
gererEvenements();
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
public void chargerPropositionDetermination() {
|
|
|
61 |
this.nbCommentaires = propositionDetermination.getTotalCommentaires();
|
|
|
62 |
this.nbVotes = propositionDetermination.getVotesDeterminations().size();
|
|
|
63 |
vue.setNbCommentaires(nbCommentaires);
|
|
|
64 |
vue.setNbVotes(nbVotes);
|
1833 |
aurelien |
65 |
vue.setPropositionRetenue(propositionDetermination.estPropositionRetenue());
|
1196 |
gduche |
66 |
}
|
|
|
67 |
|
|
|
68 |
public void gererEvenements() {
|
1524 |
mathias |
69 |
gererEvenementsVotes();
|
|
|
70 |
if (nbCommentaires > 0) {
|
|
|
71 |
vue.getZoneNbCommentaires().addClickHandler(new ClickHandler() {
|
1196 |
gduche |
72 |
@Override
|
|
|
73 |
public void onClick(ClickEvent event) {
|
1524 |
mathias |
74 |
if (nbCommentaires > 0) {
|
1196 |
gduche |
75 |
FenetreOverlaySimplePresenteur fenetreOverlaySimplePresenteur = new FenetreOverlaySimplePresenteur(
|
|
|
76 |
new FenetreOverlayDefilanteVue());
|
1524 |
mathias |
77 |
DetailCommentairePresenteur detailCommentairePresenteur = new DetailCommentairePresenteur(
|
|
|
78 |
new DetailCommentaireVue(),
|
|
|
79 |
new CommentaireServiceConcret(),
|
|
|
80 |
propositionDetermination);
|
1196 |
gduche |
81 |
fenetreOverlaySimplePresenteur
|
1524 |
mathias |
82 |
.ouvrirFenetreModale(detailCommentairePresenteur);
|
|
|
83 |
detailCommentairePresenteur.afficherCommentaires();
|
1196 |
gduche |
84 |
}
|
|
|
85 |
}
|
|
|
86 |
});
|
|
|
87 |
} else {
|
1524 |
mathias |
88 |
vue.enleverLienCommentaires();
|
1196 |
gduche |
89 |
}
|
1524 |
mathias |
90 |
|
|
|
91 |
BusEvenementiel.getInstance().addHandler(EvenementVoteDetermination.TYPE, new GestionnaireEvenementVoteDetermination() {
|
|
|
92 |
@Override
|
|
|
93 |
public void onVoteDetermination(VoteDetermination event) {
|
|
|
94 |
if(event.getPropositionDetermination() == propositionDetermination) {
|
|
|
95 |
if(nbVotes == 0) {
|
|
|
96 |
nbVotes++;
|
|
|
97 |
gererEvenementsVotes();
|
|
|
98 |
}
|
|
|
99 |
vue.setNbVotes(nbVotes);
|
|
|
100 |
}
|
|
|
101 |
|
|
|
102 |
}
|
|
|
103 |
});
|
|
|
104 |
}
|
1196 |
gduche |
105 |
|
1524 |
mathias |
106 |
private void gererEvenementsVotes() {
|
|
|
107 |
if (nbVotes > 0) {
|
|
|
108 |
vue.getZoneNbVotes().addClickHandler(new ClickHandler() {
|
1196 |
gduche |
109 |
@Override
|
|
|
110 |
public void onClick(ClickEvent event) {
|
1524 |
mathias |
111 |
if (nbVotes > 0) {
|
1196 |
gduche |
112 |
FenetreOverlaySimplePresenteur fenetreOverlaySimplePresenteur = new FenetreOverlaySimplePresenteur(
|
|
|
113 |
new FenetreOverlayDefilanteVue());
|
1524 |
mathias |
114 |
DetailListeVotesDeterminationPresenteur detailListeVotesDeterminationPresenteur = new DetailListeVotesDeterminationPresenteur(
|
|
|
115 |
new DetailListeVotesDeterminationVue());
|
1196 |
gduche |
116 |
fenetreOverlaySimplePresenteur
|
1524 |
mathias |
117 |
.ouvrirFenetreModale(detailListeVotesDeterminationPresenteur);
|
|
|
118 |
detailListeVotesDeterminationPresenteur
|
|
|
119 |
.afficherVotes(propositionDetermination);
|
1196 |
gduche |
120 |
}
|
|
|
121 |
}
|
|
|
122 |
});
|
1524 |
mathias |
123 |
vue.ajouterLienVotes();
|
1196 |
gduche |
124 |
} else {
|
1524 |
mathias |
125 |
vue.enleverLienVotes();
|
1196 |
gduche |
126 |
}
|
|
|
127 |
}
|
|
|
128 |
}
|