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();
|
|
|
40 |
}
|
|
|
41 |
|
|
|
42 |
private Vue vue;
|
|
|
43 |
|
|
|
44 |
private PropositionDetermination propositionDetermination;
|
|
|
45 |
|
|
|
46 |
public LignePropositionPresenteur(Vue vue,
|
|
|
47 |
PropositionDetermination propositionDetermination) {
|
|
|
48 |
this.vue = vue;
|
|
|
49 |
this.propositionDetermination = propositionDetermination;
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
public void go(HasWidgets composite) {
|
|
|
53 |
composite.add(vue.asWidget());
|
|
|
54 |
chargerPropositionDetermination();
|
|
|
55 |
gererEvenements();
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
public void chargerPropositionDetermination() {
|
|
|
59 |
this.nbCommentaires = propositionDetermination.getTotalCommentaires();
|
|
|
60 |
this.nbVotes = propositionDetermination.getVotesDeterminations().size();
|
|
|
61 |
vue.setNbCommentaires(nbCommentaires);
|
|
|
62 |
vue.setNbVotes(nbVotes);
|
|
|
63 |
}
|
|
|
64 |
|
|
|
65 |
public void gererEvenements() {
|
1524 |
mathias |
66 |
gererEvenementsVotes();
|
|
|
67 |
if (nbCommentaires > 0) {
|
|
|
68 |
vue.getZoneNbCommentaires().addClickHandler(new ClickHandler() {
|
1196 |
gduche |
69 |
@Override
|
|
|
70 |
public void onClick(ClickEvent event) {
|
1524 |
mathias |
71 |
if (nbCommentaires > 0) {
|
1196 |
gduche |
72 |
FenetreOverlaySimplePresenteur fenetreOverlaySimplePresenteur = new FenetreOverlaySimplePresenteur(
|
|
|
73 |
new FenetreOverlayDefilanteVue());
|
1524 |
mathias |
74 |
DetailCommentairePresenteur detailCommentairePresenteur = new DetailCommentairePresenteur(
|
|
|
75 |
new DetailCommentaireVue(),
|
|
|
76 |
new CommentaireServiceConcret(),
|
|
|
77 |
propositionDetermination);
|
1196 |
gduche |
78 |
fenetreOverlaySimplePresenteur
|
1524 |
mathias |
79 |
.ouvrirFenetreModale(detailCommentairePresenteur);
|
|
|
80 |
detailCommentairePresenteur.afficherCommentaires();
|
1196 |
gduche |
81 |
}
|
|
|
82 |
}
|
|
|
83 |
});
|
|
|
84 |
} else {
|
1524 |
mathias |
85 |
vue.enleverLienCommentaires();
|
1196 |
gduche |
86 |
}
|
1524 |
mathias |
87 |
|
|
|
88 |
BusEvenementiel.getInstance().addHandler(EvenementVoteDetermination.TYPE, new GestionnaireEvenementVoteDetermination() {
|
|
|
89 |
@Override
|
|
|
90 |
public void onVoteDetermination(VoteDetermination event) {
|
|
|
91 |
if(event.getPropositionDetermination() == propositionDetermination) {
|
|
|
92 |
if(nbVotes == 0) {
|
|
|
93 |
nbVotes++;
|
|
|
94 |
gererEvenementsVotes();
|
|
|
95 |
}
|
|
|
96 |
vue.setNbVotes(nbVotes);
|
|
|
97 |
}
|
|
|
98 |
|
|
|
99 |
}
|
|
|
100 |
});
|
|
|
101 |
}
|
1196 |
gduche |
102 |
|
1524 |
mathias |
103 |
private void gererEvenementsVotes() {
|
|
|
104 |
if (nbVotes > 0) {
|
|
|
105 |
vue.getZoneNbVotes().addClickHandler(new ClickHandler() {
|
1196 |
gduche |
106 |
@Override
|
|
|
107 |
public void onClick(ClickEvent event) {
|
1524 |
mathias |
108 |
if (nbVotes > 0) {
|
1196 |
gduche |
109 |
FenetreOverlaySimplePresenteur fenetreOverlaySimplePresenteur = new FenetreOverlaySimplePresenteur(
|
|
|
110 |
new FenetreOverlayDefilanteVue());
|
1524 |
mathias |
111 |
DetailListeVotesDeterminationPresenteur detailListeVotesDeterminationPresenteur = new DetailListeVotesDeterminationPresenteur(
|
|
|
112 |
new DetailListeVotesDeterminationVue());
|
1196 |
gduche |
113 |
fenetreOverlaySimplePresenteur
|
1524 |
mathias |
114 |
.ouvrirFenetreModale(detailListeVotesDeterminationPresenteur);
|
|
|
115 |
detailListeVotesDeterminationPresenteur
|
|
|
116 |
.afficherVotes(propositionDetermination);
|
1196 |
gduche |
117 |
}
|
|
|
118 |
}
|
|
|
119 |
});
|
1524 |
mathias |
120 |
vue.ajouterLienVotes();
|
1196 |
gduche |
121 |
} else {
|
1524 |
mathias |
122 |
vue.enleverLienVotes();
|
1196 |
gduche |
123 |
}
|
|
|
124 |
}
|
|
|
125 |
}
|