922 |
benjamin |
1 |
package org.tela_botanica.del.client.vues.rechercheobservations.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;
|
959 |
benjamin |
10 |
import org.tela_botanica.del.client.services.rest.CommentaireServiceConcret;
|
922 |
benjamin |
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 |
|
1068 |
gduche |
20 |
private int nbCommentaires, nbVotes;
|
|
|
21 |
|
922 |
benjamin |
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 |
|
|
|
32 |
private Vue vue;
|
|
|
33 |
|
|
|
34 |
private PropositionDetermination propositionDetermination;
|
|
|
35 |
|
|
|
36 |
public LignePropositionPresenteur(Vue vue, PropositionDetermination propositionDetermination) {
|
|
|
37 |
this.vue = vue;
|
|
|
38 |
this.propositionDetermination = propositionDetermination;
|
|
|
39 |
}
|
|
|
40 |
|
|
|
41 |
public void go(HasWidgets composite) {
|
|
|
42 |
composite.add(vue.asWidget());
|
|
|
43 |
gererEvenements();
|
|
|
44 |
chargerPropositionDetermination();
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
public void chargerPropositionDetermination() {
|
1068 |
gduche |
48 |
this.nbCommentaires = propositionDetermination.getTotalCommentaires();
|
|
|
49 |
this.nbVotes = propositionDetermination.getVotesDeterminations().size();
|
922 |
benjamin |
50 |
vue.setNbCommentaires(nbCommentaires);
|
|
|
51 |
vue.setNbVotes(nbVotes);
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
public void gererEvenements() {
|
1068 |
gduche |
55 |
|
|
|
56 |
final int nbVotes = this.nbVotes;
|
|
|
57 |
final int nbCommentaires = this.nbCommentaires;
|
|
|
58 |
|
922 |
benjamin |
59 |
vue.getZoneNbVotes().addClickHandler(new ClickHandler() {
|
|
|
60 |
@Override
|
|
|
61 |
public void onClick(ClickEvent event) {
|
1068 |
gduche |
62 |
if (nbVotes > 0) {
|
|
|
63 |
FenetreOverlaySimplePresenteur fenetreOverlaySimplePresenteur = new FenetreOverlaySimplePresenteur(new FenetreOverlayDefilanteVue());
|
|
|
64 |
DetailListeVotesDeterminationPresenteur detailListeVotesDeterminationPresenteur = new DetailListeVotesDeterminationPresenteur(new DetailListeVotesDeterminationVue());
|
|
|
65 |
fenetreOverlaySimplePresenteur.ouvrirFenetreModale(detailListeVotesDeterminationPresenteur);
|
|
|
66 |
detailListeVotesDeterminationPresenteur.afficherVotes(propositionDetermination);
|
|
|
67 |
}
|
922 |
benjamin |
68 |
}
|
|
|
69 |
});
|
|
|
70 |
|
|
|
71 |
vue.getZoneNbCommentaires().addClickHandler(new ClickHandler() {
|
|
|
72 |
@Override
|
|
|
73 |
public void onClick(ClickEvent event) {
|
1068 |
gduche |
74 |
if (nbCommentaires > 0) {
|
|
|
75 |
FenetreOverlaySimplePresenteur fenetreOverlaySimplePresenteur = new FenetreOverlaySimplePresenteur(new FenetreOverlayDefilanteVue());
|
|
|
76 |
DetailCommentairePresenteur detailCommentairePresenteur = new DetailCommentairePresenteur(new DetailCommentaireVue(), new CommentaireServiceConcret(), propositionDetermination);
|
|
|
77 |
fenetreOverlaySimplePresenteur.ouvrirFenetreModale(detailCommentairePresenteur);
|
|
|
78 |
detailCommentairePresenteur.afficherCommentaires();
|
|
|
79 |
}
|
922 |
benjamin |
80 |
}
|
|
|
81 |
});
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
}
|