Subversion Repositories eFlore/Applications.del

Rev

Rev 210 | Rev 284 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

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

import java.util.List;

import org.tela_botanica.del.client.cache.CacheClient;
import org.tela_botanica.del.client.modeles.Image;
import org.tela_botanica.del.client.modeles.VoteProtocole;
import org.tela_botanica.del.client.utils.MockDatasource;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.HasWidgets;

public class ComparaisonEflorePresenteur {

        private ComparaisonEfloreVue vue = new ComparaisonEfloreVue();
        private final MockDatasource observationService = MockDatasource.getInstance();
        private final MockDatasource validationService = MockDatasource.getInstance();
        private Image imagePrincipale;
        private String nomTaxonComparaison;
        private List<org.tela_botanica.del.client.modeles.Image> imagesEflore;

        public ComparaisonEflorePresenteur() {
                this.imagePrincipale = CacheClient.getInstance().getImageCourante();
                this.nomTaxonComparaison = CacheClient.getInstance().getTaxonPourRechercheEflore();
        }

        public void go(HasWidgets composite) {
                composite.add(vue);
                chargerValidationObservationPrincipale();
                vue.chargerImagePrincipale(imagePrincipale);
                chargerObservationsEflore();
                gererEvenements();
        }

        private void chargerValidationObservationPrincipale() {
                List<VoteProtocole> observationValidations = validationService.getVote(imagePrincipale.getIdImage());
                imagePrincipale.setVoteProtocoles(observationValidations);
        }

        private void chargerObservationsEflore() {
                imagesEflore = observationService.getImagesEfloreParTaxon(nomTaxonComparaison);
                vue.chargerImagesEflore(imagesEflore, 0);
        }

        private void gererEvenements() {
                vue.scrollLeftImage.addClickHandler(new ClickHandler() {

                        @Override
                        public void onClick(ClickEvent event) {
                                vue.chargerImagesEflore(imagesEflore, vue.getCurrentIndexImages() - 1);
                        }
                });

                vue.scrollRightImage.addClickHandler(new ClickHandler() {

                        @Override
                        public void onClick(ClickEvent event) {
                                vue.chargerImagesEflore(imagesEflore, vue.getCurrentIndexImages() + 1);
                        }
                });
        }

}