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;
|
|
|
10 |
import org.tela_botanica.del.client.services.rest.CommentaireServiceConcret;
|
|
|
11 |
|
|
|
12 |
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
13 |
import com.google.gwt.event.dom.client.ClickHandler;
|
|
|
14 |
import com.google.gwt.event.dom.client.HasClickHandlers;
|
|
|
15 |
import com.google.gwt.user.client.ui.HasWidgets;
|
|
|
16 |
import com.google.gwt.user.client.ui.IsWidget;
|
|
|
17 |
|
|
|
18 |
public class LignePropositionPresenteur {
|
|
|
19 |
|
|
|
20 |
private int nbCommentaires, nbVotes;
|
|
|
21 |
|
|
|
22 |
public abstract interface Vue extends IsWidget {
|
|
|
23 |
public HasClickHandlers getZoneNbVotes();
|
|
|
24 |
|
|
|
25 |
public HasClickHandlers getZoneNbCommentaires();
|
|
|
26 |
|
|
|
27 |
public void setNbVotes(int nbVotes);
|
|
|
28 |
|
|
|
29 |
public void setNbCommentaires(int nbCommentaires);
|
|
|
30 |
|
|
|
31 |
public void enleverLienCommentaires();
|
|
|
32 |
|
|
|
33 |
public void enleverLienVotes();
|
|
|
34 |
|
|
|
35 |
public void ajouterLienVotes();
|
|
|
36 |
}
|
|
|
37 |
|
|
|
38 |
private Vue vue;
|
|
|
39 |
|
|
|
40 |
private PropositionDetermination propositionDetermination;
|
|
|
41 |
|
|
|
42 |
public LignePropositionPresenteur(Vue vue,
|
|
|
43 |
PropositionDetermination propositionDetermination) {
|
|
|
44 |
this.vue = vue;
|
|
|
45 |
this.propositionDetermination = propositionDetermination;
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
public void go(HasWidgets composite) {
|
|
|
49 |
composite.add(vue.asWidget());
|
|
|
50 |
chargerPropositionDetermination();
|
|
|
51 |
gererEvenements();
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
public void chargerPropositionDetermination() {
|
|
|
55 |
this.nbCommentaires = propositionDetermination.getTotalCommentaires();
|
|
|
56 |
this.nbVotes = propositionDetermination.getVotesDeterminations().size();
|
|
|
57 |
vue.setNbCommentaires(nbCommentaires);
|
|
|
58 |
vue.setNbVotes(nbVotes);
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
public void gererEvenements() {
|
|
|
62 |
if (nbVotes > 0) {
|
|
|
63 |
vue.getZoneNbVotes().addClickHandler(new ClickHandler() {
|
|
|
64 |
@Override
|
|
|
65 |
public void onClick(ClickEvent event) {
|
|
|
66 |
if (nbVotes > 0) {
|
|
|
67 |
FenetreOverlaySimplePresenteur fenetreOverlaySimplePresenteur = new FenetreOverlaySimplePresenteur(
|
|
|
68 |
new FenetreOverlayDefilanteVue());
|
|
|
69 |
DetailListeVotesDeterminationPresenteur detailListeVotesDeterminationPresenteur = new DetailListeVotesDeterminationPresenteur(
|
|
|
70 |
new DetailListeVotesDeterminationVue());
|
|
|
71 |
fenetreOverlaySimplePresenteur
|
|
|
72 |
.ouvrirFenetreModale(detailListeVotesDeterminationPresenteur);
|
|
|
73 |
detailListeVotesDeterminationPresenteur
|
|
|
74 |
.afficherVotes(propositionDetermination);
|
|
|
75 |
}
|
|
|
76 |
}
|
|
|
77 |
});
|
|
|
78 |
vue.ajouterLienVotes();
|
|
|
79 |
} else {
|
|
|
80 |
vue.enleverLienVotes();
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
if (nbCommentaires > 0) {
|
|
|
84 |
vue.getZoneNbCommentaires().addClickHandler(new ClickHandler() {
|
|
|
85 |
@Override
|
|
|
86 |
public void onClick(ClickEvent event) {
|
|
|
87 |
if (nbCommentaires > 0) {
|
|
|
88 |
FenetreOverlaySimplePresenteur fenetreOverlaySimplePresenteur = new FenetreOverlaySimplePresenteur(
|
|
|
89 |
new FenetreOverlayDefilanteVue());
|
|
|
90 |
DetailCommentairePresenteur detailCommentairePresenteur = new DetailCommentairePresenteur(
|
|
|
91 |
new DetailCommentaireVue(),
|
|
|
92 |
new CommentaireServiceConcret(),
|
|
|
93 |
propositionDetermination);
|
|
|
94 |
fenetreOverlaySimplePresenteur
|
|
|
95 |
.ouvrirFenetreModale(detailCommentairePresenteur);
|
|
|
96 |
detailCommentairePresenteur.afficherCommentaires();
|
|
|
97 |
}
|
|
|
98 |
}
|
|
|
99 |
});
|
|
|
100 |
} else {
|
|
|
101 |
vue.enleverLienCommentaires();
|
|
|
102 |
}
|
|
|
103 |
}
|
|
|
104 |
|
|
|
105 |
}
|