Subversion Repositories eFlore/Applications.del

Rev

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

Rev Author Line No. Line
14 benjamin 1
package org.tela_botanica.del.client.vues.rechercheobservations.vote;
9 benjamin 2
 
3
import java.util.List;
4
 
5
import org.cobogw.gwt.user.client.ui.Rating;
14 benjamin 6
import org.tela_botanica.del.client.modeles.ObservationValidation;
9 benjamin 7
 
66 gduche 8
import com.google.gwt.core.client.GWT;
9
import com.google.gwt.uibinder.client.UiBinder;
10
import com.google.gwt.uibinder.client.UiField;
9 benjamin 11
import com.google.gwt.user.client.ui.Composite;
66 gduche 12
import com.google.gwt.user.client.ui.FocusPanel;
13
import com.google.gwt.user.client.ui.Label;
9 benjamin 14
import com.google.gwt.user.client.ui.Panel;
15
import com.google.gwt.user.client.ui.VerticalPanel;
66 gduche 16
import com.google.gwt.user.client.ui.Widget;
9 benjamin 17
 
14 benjamin 18
public class MoyenneVoteVue extends Composite {
9 benjamin 19
 
66 gduche 20
	// Annotation can be used to change the name of the associated xml file
21
	// @UiTemplate("MoyenneVoteVue.ui.xml")
22
	interface MyUiBinder extends UiBinder<Widget, MoyenneVoteVue> {
23
	}
24
 
25
	private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);
26
 
9 benjamin 27
	private Panel mainPanel = new VerticalPanel();
28
 
66 gduche 29
	@UiField
30
	FocusPanel voter;
31
 
32
	@UiField
33
	Label nbVotes;
34
 
14 benjamin 35
	protected MoyenneVoteVue(List<ObservationValidation> validationDatas) {
66 gduche 36
		initWidget(uiBinder.createAndBindUi(this));
9 benjamin 37
 
38
		int meanVote = 0;
39
		int nbVote = 0;
14 benjamin 40
		for (ObservationValidation imageCelValidationData : validationDatas) {
9 benjamin 41
 
42
			meanVote += imageCelValidationData.getVote();
43
			nbVote++;
44
		}
45
		if (nbVote > 0)
46
			meanVote /= nbVote;
47
		Rating rating = new Rating(meanVote, 5);
48
		rating.setReadOnly(true);
66 gduche 49
		voter.add(rating);
9 benjamin 50
 
66 gduche 51
		nbVotes.setText(String.valueOf(validationDatas.size()));
9 benjamin 52
 
53
	}
54
}