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;
|
|
|
10 |
|
|
|
11 |
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
12 |
import com.google.gwt.event.dom.client.ClickHandler;
|
|
|
13 |
import com.google.gwt.event.dom.client.HasClickHandlers;
|
|
|
14 |
import com.google.gwt.user.client.ui.HasWidgets;
|
|
|
15 |
import com.google.gwt.user.client.ui.IsWidget;
|
|
|
16 |
|
|
|
17 |
public class LignePropositionPresenteur {
|
|
|
18 |
|
|
|
19 |
public abstract interface Vue extends IsWidget {
|
|
|
20 |
public HasClickHandlers getZoneNbVotes();
|
|
|
21 |
|
|
|
22 |
public HasClickHandlers getZoneNbCommentaires();
|
|
|
23 |
|
|
|
24 |
public void setNbVotes(int nbVotes);
|
|
|
25 |
|
|
|
26 |
public void setNbCommentaires(int nbCommentaires);
|
|
|
27 |
}
|
|
|
28 |
|
|
|
29 |
private Vue vue;
|
|
|
30 |
|
|
|
31 |
private PropositionDetermination propositionDetermination;
|
|
|
32 |
|
|
|
33 |
public LignePropositionPresenteur(Vue vue, PropositionDetermination propositionDetermination) {
|
|
|
34 |
this.vue = vue;
|
|
|
35 |
this.propositionDetermination = propositionDetermination;
|
|
|
36 |
}
|
|
|
37 |
|
|
|
38 |
public void go(HasWidgets composite) {
|
|
|
39 |
composite.add(vue.asWidget());
|
|
|
40 |
gererEvenements();
|
|
|
41 |
chargerPropositionDetermination();
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
public void chargerPropositionDetermination() {
|
|
|
45 |
int nbCommentaires = propositionDetermination.getTotalCommentaires();
|
926 |
benjamin |
46 |
if (propositionDetermination.getCommentaire() != null && propositionDetermination.getCommentaire() != "") {
|
|
|
47 |
nbCommentaires += 1;
|
|
|
48 |
}
|
922 |
benjamin |
49 |
int nbVotes = propositionDetermination.getVotesDeterminations().size();
|
|
|
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) {
|
926 |
benjamin |
58 |
FenetreOverlaySimplePresenteur fenetreOverlaySimplePresenteur = new FenetreOverlaySimplePresenteur(new FenetreOverlayDefilanteVue());
|
|
|
59 |
DetailListeVotesDeterminationPresenteur detailListeVotesDeterminationPresenteur = new DetailListeVotesDeterminationPresenteur(new DetailListeVotesDeterminationVue());
|
|
|
60 |
fenetreOverlaySimplePresenteur.ouvrirFenetreModale(detailListeVotesDeterminationPresenteur);
|
|
|
61 |
detailListeVotesDeterminationPresenteur.afficherVotes(propositionDetermination);
|
922 |
benjamin |
62 |
}
|
|
|
63 |
});
|
|
|
64 |
|
|
|
65 |
vue.getZoneNbCommentaires().addClickHandler(new ClickHandler() {
|
|
|
66 |
@Override
|
|
|
67 |
public void onClick(ClickEvent event) {
|
926 |
benjamin |
68 |
FenetreOverlaySimplePresenteur fenetreOverlaySimplePresenteur = new FenetreOverlaySimplePresenteur(new FenetreOverlayDefilanteVue());
|
|
|
69 |
DetailCommentairePresenteur detailCommentairePresenteur = new DetailCommentairePresenteur(new DetailCommentaireVue(), propositionDetermination);
|
|
|
70 |
fenetreOverlaySimplePresenteur.ouvrirFenetreModale(detailCommentairePresenteur);
|
|
|
71 |
detailCommentairePresenteur.afficherCommentaires();
|
922 |
benjamin |
72 |
}
|
|
|
73 |
});
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
}
|