Subversion Repositories eFlore/Applications.del

Rev

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

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

import java.util.Iterator;
import java.util.List;

import org.tela_botanica.del.client.composants.presenteur.Presenteur;
import org.tela_botanica.del.client.modeles.Observation;
import org.tela_botanica.del.client.modeles.PropositionDetermination;

import com.google.gwt.user.client.ui.HasWidgets;

public class ObservationPresenteur extends Presenteur {

        private Observation observation;

        public ObservationPresenteur(Observation observation) {
                super(new ObservationVue());
                this.observation = observation;
                chargerObservation();
        }

        public void chargerObservation() {
                ObservationVue vue = (ObservationVue) this.getVue();
                vue.auteur.setText(observation.getAuteur());
                vue.date.setText(observation.getDate());
                vue.famille.setText(observation.getFamille());
                vue.localite.setText(observation.getLocalite());

                List<String> motsCles = observation.getMotsClefs();
                Iterator<String> itMotsCles = motsCles.iterator();
                String motsClesChaine = "";
                while (itMotsCles.hasNext()) {
                        String motCle = itMotsCles.next();
                        motsClesChaine += motCle;
                        if (itMotsCles.hasNext()) {
                                motsClesChaine += ", ";
                        }
                }
                vue.motsClefs.setText(motsClesChaine);
                vue.nomRetenu.setText(observation.getNomRetenu());
                vue.numNomenclatural.setText(observation.getNumNomenclatural());

                vue.photoPrincipale.setUrl((observation.getImages()).get(0).getUrl());

                List<PropositionDetermination> propositions = observation.getPropositionsDetermination();

                vue.tableauPropositions.setText(0, 0, "Certitude");
                vue.tableauPropositions.setText(0, 1, "Commentaires");
                vue.tableauPropositions.setText(0, 2, "Nom");
                vue.tableauPropositions.setText(0, 3, "Votez");

                int i = 0;
                for (PropositionDetermination proposition : propositions) {
                        i++;
                        vue.tableauPropositions.setText(i, 0, String.valueOf(proposition.getVotesDeterminations().size()));
                        vue.tableauPropositions.setText(i, 1, String.valueOf(proposition.getCommentaires().size()));
                        vue.tableauPropositions.setText(i, 2, proposition.getEspece());

                }

                // vue.propositions.setText(ch);
        }

        public void go(HasWidgets composite) {
                composite.add(this.getVue());
        }

        protected void handleEvents() {
                // TODO Auto-generated method stub

        }

}