Subversion Repositories eFlore/Applications.del

Rev

Rev 1524 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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