Subversion Repositories eFlore/Applications.del

Rev

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

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

import org.tela_botanica.del.client.vues.rechercheobservations.ObservationRecherchePresenteur;

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 NumeroPagePresenteur {

        private final NumeroPageVue view;

        private int nbPage = 1;

        public NumeroPagePresenteur(int nbPage) {
                this.nbPage = nbPage;
                view = new NumeroPageVue(nbPage);
        }

        public void go(HasWidgets container) {
                container.add(view);
                handleEvents();
        }

        public void handleEvents() {
                view.getNbPageHtml().addClickHandler(new ClickHandler() {

                        @Override
                        public void onClick(ClickEvent event) {

                                int firstImage;
                                int lastImage;

                                int nbImagePerPage = ObservationRecherchePresenteur.getInstance()
                                                .getView().getNbImagesPerPage();

                                if (nbPage == 1) {
                                        firstImage = 0;
                                } else {
                                        firstImage = ((nbPage - 1) * nbImagePerPage);
                                }

                                lastImage = (nbPage - 1) * nbImagePerPage + nbImagePerPage;

                                ObservationRecherchePresenteur.getInstance().showImagePanels(firstImage,
                                                lastImage);

                        }
                });
        }
}