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