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