Subversion Repositories eFlore/Applications.del

Rev

Rev 9 | Blame | Last modification | View Log | RSS feed

package org.tela_botanica.del.client.vues.rechercheobservations.vote;

import java.util.List;

import org.cobogw.gwt.user.client.ui.Rating;
import org.tela_botanica.del.client.modeles.ObservationValidation;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.VerticalPanel;

public class MoyenneVoteVue extends Composite {

        private Panel mainPanel = new VerticalPanel();

        protected MoyenneVoteVue(List<ObservationValidation> validationDatas) {

                int meanVote = 0;
                int nbVote = 0;
                for (ObservationValidation imageCelValidationData : validationDatas) {

                        meanVote += imageCelValidationData.getVote();
                        nbVote++;
                }
                if (nbVote > 0)
                        meanVote /= nbVote;

                Panel ratePanel = new HorizontalPanel();
                Rating rating = new Rating(meanVote, 5);
                rating.setReadOnly(true);

                ratePanel.add(new HTML("Moyenne: "));
                ratePanel.add(rating);
                ratePanel.add(new HTML("&nbsp;&nbsp;Nb votes: "
                                + validationDatas.size()));

                mainPanel.add(ratePanel);

                initWidget(mainPanel);

        }
}