Subversion Repositories eFlore/Applications.del

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
148 benjamin 1
package org.tela_botanica.del.client.vues.rechercheimages.pagination;
9 benjamin 2
 
148 benjamin 3
import org.tela_botanica.del.client.vues.rechercheimages.ImageRecherchePresenteur;
9 benjamin 4
 
5
import com.google.gwt.event.dom.client.ClickEvent;
6
import com.google.gwt.event.dom.client.ClickHandler;
7
import com.google.gwt.user.client.ui.HasWidgets;
8
 
14 benjamin 9
public class NumeroPagePresenteur {
9 benjamin 10
 
14 benjamin 11
	private final NumeroPageVue view;
9 benjamin 12
 
13
	private int nbPage = 1;
14
 
14 benjamin 15
	public NumeroPagePresenteur(int nbPage) {
9 benjamin 16
		this.nbPage = nbPage;
14 benjamin 17
		view = new NumeroPageVue(nbPage);
9 benjamin 18
	}
19
 
20
	public void go(HasWidgets container) {
21
		container.add(view);
22
		handleEvents();
23
	}
24
 
25
	public void handleEvents() {
26
		view.getNbPageHtml().addClickHandler(new ClickHandler() {
27
 
28
			@Override
29
			public void onClick(ClickEvent event) {
30
 
31
				int firstImage;
32
				int lastImage;
33
 
148 benjamin 34
				int nbImagePerPage = ImageRecherchePresenteur.getInstance()
9 benjamin 35
						.getView().getNbImagesPerPage();
36
 
37
				if (nbPage == 1) {
38
					firstImage = 0;
39
				} else {
40
					firstImage = ((nbPage - 1) * nbImagePerPage);
41
				}
42
 
43
				lastImage = (nbPage - 1) * nbImagePerPage + nbImagePerPage;
44
 
148 benjamin 45
				ImageRecherchePresenteur.getInstance().showImagePanels(firstImage,
9 benjamin 46
						lastImage);
47
 
48
			}
49
		});
50
	}
51
}