New file |
0,0 → 1,51 |
package org.tela_botanica.del.client.vues.searchobservations.pagination; |
|
import org.tela_botanica.del.client.vues.searchobservations.ObservationSearchPresenter; |
|
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 NumberPagePresenter { |
|
private final NumberPageView view; |
|
private int nbPage = 1; |
|
public NumberPagePresenter(int nbPage) { |
this.nbPage = nbPage; |
view = new NumberPageView(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 = ObservationSearchPresenter.getInstance() |
.getView().getNbImagesPerPage(); |
|
if (nbPage == 1) { |
firstImage = 0; |
} else { |
firstImage = ((nbPage - 1) * nbImagePerPage); |
} |
|
lastImage = (nbPage - 1) * nbImagePerPage + nbImagePerPage; |
|
ObservationSearchPresenter.getInstance().showImagePanels(firstImage, |
lastImage); |
|
} |
}); |
} |
} |