Subversion Repositories eFlore/Applications.del

Rev

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

Rev Author Line No. Line
116 benjamin 1
package org.tela_botanica.del.client.vues.plateformedetermination.vote.protocole.moyenne;
2
 
3
import java.util.List;
4
 
5
import org.cobogw.gwt.user.client.ui.Rating;
140 aurelien 6
import org.tela_botanica.del.client.modeles.PropositionDetermination;
116 benjamin 7
import org.tela_botanica.del.client.modeles.Protocole;
8
 
9
import com.google.gwt.core.client.GWT;
10
import com.google.gwt.uibinder.client.UiBinder;
11
import com.google.gwt.uibinder.client.UiField;
12
import com.google.gwt.user.client.ui.Composite;
13
import com.google.gwt.user.client.ui.FocusPanel;
14
import com.google.gwt.user.client.ui.Label;
15
import com.google.gwt.user.client.ui.Widget;
16
 
17
public class MoyenneVoteProtocoleVue extends Composite {
18
 
19
	interface MyUiBinder extends UiBinder<Widget, MoyenneVoteProtocoleVue> {
20
	}
21
 
22
	private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);
23
 
24
	@UiField
25
	FocusPanel moyenneVotes, monVote;
26
 
27
	@UiField
28
	Label nbVotes, nomProtocole;
29
 
140 aurelien 30
	protected MoyenneVoteProtocoleVue(Protocole protocole, List<PropositionDetermination> validationDatas) {
116 benjamin 31
		initWidget(uiBinder.createAndBindUi(this));
32
 
33
		nomProtocole.setText(protocole.getNom());
34
 
35
		int meanVote = 0;
36
		int nbVote = 0;
140 aurelien 37
		for (PropositionDetermination validationData : validationDatas) {
116 benjamin 38
 
140 aurelien 39
			//meanVote += validationData.getVote();
116 benjamin 40
			nbVote++;
41
		}
42
		if (nbVote > 0)
43
			meanVote /= nbVote;
44
		Rating rating = new Rating(meanVote, 5);
45
		rating.setReadOnly(true);
46
		moyenneVotes.add(rating);
47
 
48
		nbVotes.setText(String.valueOf(validationDatas.size()));
49
 
50
	}
51
 
52
	public FocusPanel getMonVote() {
53
		return monVote;
54
	}
55
 
56
	public void setMonVote(FocusPanel monVote) {
57
		this.monVote = monVote;
58
	}
59
}