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());
|
1071 |
aurelien |
43 |
chargerPropositionDetermination();
|
922 |
benjamin |
44 |
gererEvenements();
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
public void chargerPropositionDetermination() {
|
1071 |
aurelien |
48 |
nbCommentaires = propositionDetermination.getTotalCommentaires();
|
|
|
49 |
nbVotes = propositionDetermination.getVotesDeterminations().size();
|
922 |
benjamin |
50 |
vue.setNbCommentaires(nbCommentaires);
|
|
|
51 |
vue.setNbVotes(nbVotes);
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
public void gererEvenements() {
|
|
|
55 |
vue.getZoneNbVotes().addClickHandler(new ClickHandler() {
|
|
|
56 |
@Override
|
|
|
57 |
public void onClick(ClickEvent event) {
|
1068 |
gduche |
58 |
if (nbVotes > 0) {
|
|
|
59 |
FenetreOverlaySimplePresenteur fenetreOverlaySimplePresenteur = new FenetreOverlaySimplePresenteur(new FenetreOverlayDefilanteVue());
|
|
|
60 |
DetailListeVotesDeterminationPresenteur detailListeVotesDeterminationPresenteur = new DetailListeVotesDeterminationPresenteur(new DetailListeVotesDeterminationVue());
|
|
|
61 |
fenetreOverlaySimplePresenteur.ouvrirFenetreModale(detailListeVotesDeterminationPresenteur);
|
|
|
62 |
detailListeVotesDeterminationPresenteur.afficherVotes(propositionDetermination);
|
|
|
63 |
}
|
922 |
benjamin |
64 |
}
|
|
|
65 |
});
|
|
|
66 |
|
|
|
67 |
vue.getZoneNbCommentaires().addClickHandler(new ClickHandler() {
|
|
|
68 |
@Override
|
|
|
69 |
public void onClick(ClickEvent event) {
|
1068 |
gduche |
70 |
if (nbCommentaires > 0) {
|
|
|
71 |
FenetreOverlaySimplePresenteur fenetreOverlaySimplePresenteur = new FenetreOverlaySimplePresenteur(new FenetreOverlayDefilanteVue());
|
|
|
72 |
DetailCommentairePresenteur detailCommentairePresenteur = new DetailCommentairePresenteur(new DetailCommentaireVue(), new CommentaireServiceConcret(), propositionDetermination);
|
|
|
73 |
fenetreOverlaySimplePresenteur.ouvrirFenetreModale(detailCommentairePresenteur);
|
|
|
74 |
detailCommentairePresenteur.afficherCommentaires();
|
|
|
75 |
}
|
922 |
benjamin |
76 |
}
|
|
|
77 |
});
|
|
|
78 |
}
|
|
|
79 |
|
|
|
80 |
}
|