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;
|
|
|
6 |
import org.tela_botanica.del.client.modeles.Protocole;
|
148 |
benjamin |
7 |
import org.tela_botanica.del.client.modeles.VoteProtocole;
|
116 |
benjamin |
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 |
|
148 |
benjamin |
30 |
protected MoyenneVoteProtocoleVue(Protocole protocole, List<VoteProtocole> validationDatas) {
|
116 |
benjamin |
31 |
initWidget(uiBinder.createAndBindUi(this));
|
|
|
32 |
|
|
|
33 |
nomProtocole.setText(protocole.getNom());
|
|
|
34 |
|
|
|
35 |
int meanVote = 0;
|
|
|
36 |
int nbVote = 0;
|
148 |
benjamin |
37 |
for (VoteProtocole validationData : validationDatas) {
|
|
|
38 |
meanVote += validationData.getVote();
|
116 |
benjamin |
39 |
nbVote++;
|
|
|
40 |
}
|
|
|
41 |
if (nbVote > 0)
|
|
|
42 |
meanVote /= nbVote;
|
|
|
43 |
Rating rating = new Rating(meanVote, 5);
|
|
|
44 |
rating.setReadOnly(true);
|
|
|
45 |
moyenneVotes.add(rating);
|
|
|
46 |
|
|
|
47 |
nbVotes.setText(String.valueOf(validationDatas.size()));
|
|
|
48 |
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
public FocusPanel getMonVote() {
|
|
|
52 |
return monVote;
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
public void setMonVote(FocusPanel monVote) {
|
|
|
56 |
this.monVote = monVote;
|
|
|
57 |
}
|
|
|
58 |
}
|