Rev 14 | Blame | Last modification | View Log | RSS feed
package org.tela_botanica.del.client.vues.rechercheimages.pagination;
import org.tela_botanica.del.client.vues.rechercheimages.ImageRecherchePresenteur;
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 = ImageRecherchePresenteur.getInstance()
.getView().getNbImagesPerPage();
if (nbPage == 1) {
firstImage = 0;
} else {
firstImage = ((nbPage - 1) * nbImagePerPage);
}
lastImage = (nbPage - 1) * nbImagePerPage + nbImagePerPage;
ImageRecherchePresenteur.getInstance().showImagePanels(firstImage,
lastImage);
}
});
}
}