Subversion Repositories eFlore/Applications.del

Rev

Rev 1086 | Rev 1092 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
638 aurelien 1
package org.tela_botanica.del.client.composants.votes.moyennevotes;
9 benjamin 2
 
3
import java.util.List;
4
 
5
import org.cobogw.gwt.user.client.ui.Rating;
1084 gduche 6
import org.tela_botanica.del.client.composants.votes.barrerepartition.InfoBulleAnim;
423 gduche 7
import org.tela_botanica.del.client.i18n.I18n;
148 benjamin 8
import org.tela_botanica.del.client.modeles.VoteProtocole;
9 benjamin 9
 
66 gduche 10
import com.google.gwt.core.client.GWT;
423 gduche 11
import com.google.gwt.event.dom.client.ClickEvent;
12
import com.google.gwt.event.dom.client.ClickHandler;
629 aurelien 13
import com.google.gwt.event.dom.client.HasChangeHandlers;
423 gduche 14
import com.google.gwt.event.dom.client.HasClickHandlers;
66 gduche 15
import com.google.gwt.uibinder.client.UiBinder;
16
import com.google.gwt.uibinder.client.UiField;
423 gduche 17
import com.google.gwt.user.client.Window;
18
import com.google.gwt.user.client.ui.Button;
9 benjamin 19
import com.google.gwt.user.client.ui.Composite;
66 gduche 20
import com.google.gwt.user.client.ui.FocusPanel;
423 gduche 21
import com.google.gwt.user.client.ui.HasText;
629 aurelien 22
import com.google.gwt.user.client.ui.HasWidgets;
66 gduche 23
import com.google.gwt.user.client.ui.Label;
1084 gduche 24
import com.google.gwt.user.client.ui.Panel;
66 gduche 25
import com.google.gwt.user.client.ui.Widget;
9 benjamin 26
 
629 aurelien 27
public class MoyenneVoteVue extends Composite implements MoyenneVotePresenteur.Vue {
9 benjamin 28
 
66 gduche 29
	// Annotation can be used to change the name of the associated xml file
30
	// @UiTemplate("MoyenneVoteVue.ui.xml")
31
	interface MyUiBinder extends UiBinder<Widget, MoyenneVoteVue> {
32
	}
33
 
34
	private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);
423 gduche 35
	private Rating votes;
36
	private int valeurOrigine;
1084 gduche 37
	private InfoBulleAnim animerVotePrisEnCompte;
423 gduche 38
 
66 gduche 39
	@UiField
40
	FocusPanel voter;
41
 
42
	@UiField
1085 gduche 43
	Panel votePrisEnCompte, zoneFleur;
1084 gduche 44
 
45
	@UiField
1088 gduche 46
	Label nbVotes, protocole, noteGenerale;
66 gduche 47
 
423 gduche 48
	@UiField
49
	Button boutonVoter, boutonAnnuler;
50
 
629 aurelien 51
	public MoyenneVoteVue() {
66 gduche 52
		initWidget(uiBinder.createAndBindUi(this));
423 gduche 53
		votes = new Rating(0, 5);
54
		votes.setReadOnly(false);
55
		voter.add(votes);
56
		masquerBoutonAnnuler();
57
		masquerBoutonVoter();
1084 gduche 58
		votePrisEnCompte.setVisible(false);
59
		animerVotePrisEnCompte = new InfoBulleAnim(votePrisEnCompte);
423 gduche 60
	}
61
 
62
	public HasClickHandlers getBoutonVoter() {
63
		return boutonVoter;
64
	}
65
 
66
	public HasClickHandlers getBoutonAnnuler() {
67
		return boutonAnnuler;
68
	}
69
 
70
	public HasText getNbVotes() {
71
		return nbVotes;
72
	}
73
 
74
	public HasClickHandlers getVotes() {
75
		return votes;
76
	}
77
 
629 aurelien 78
	public int getValeurVote() {
79
		return votes.getValue();
80
	}
81
 
423 gduche 82
	public void afficherBoutonVoter() {
83
		boutonVoter.setVisible(true);
84
	}
85
 
86
	public void afficherBoutonAnnuler() {
87
		boutonAnnuler.setVisible(true);
88
	}
89
 
90
	public void masquerBoutonVoter() {
91
		boutonVoter.setVisible(false);
92
	}
93
 
94
	public void masquerBoutonAnnuler() {
95
		boutonAnnuler.setVisible(false);
96
	}
97
 
98
	public void afficherNbVotes () {
99
		nbVotes.setVisible(true);
100
	}
101
 
102
	public void masquerNbVotes () {
103
		nbVotes.setVisible(false);
104
	}
105
 
106
	public void reinitialiserVotes() {
107
		votes.setValue(valeurOrigine);
108
	}
109
 
1088 gduche 110
	public void rafraichir(int voteUtilisateur, int nombreVotes) {
111
		valeurOrigine = voteUtilisateur;
1086 gduche 112
		String valeurVote = nombreVotes+" "+I18n.getVocabulary().nbVotes();
113
		if (nombreVotes > 1) {
114
			valeurVote += "s";
115
		}
116
		nbVotes.setText(valeurVote);
1088 gduche 117
		votes.setValue(voteUtilisateur);
9 benjamin 118
	}
629 aurelien 119
 
120
	@Override
121
	public void ajouterAuParent(HasWidgets composite) {
122
		composite.add(this);
123
	}
1084 gduche 124
 
125
	@Override
126
	public void afficherVotePrisEnCompte() {
127
		votePrisEnCompte.removeStyleName("votePrisEnCompteNon");
128
		votePrisEnCompte.setStyleName("votePrisEnCompteOui");
129
		animerVotePrisEnCompte.run(2000);
130
	}
1085 gduche 131
 
132
	public HasWidgets getZoneFleur() {
133
		return zoneFleur;
134
	}
1086 gduche 135
 
136
	public HasText getZoneProtocole() {
137
		return protocole;
138
	}
1088 gduche 139
 
140
	public void setNoteGenerale(int note) {
141
		noteGenerale.setText(" : " + note);
142
	}
9 benjamin 143
}