Example usage for com.google.gwt.gen2.table.client PagingScrollTable gotoPreviousPage

List of usage examples for com.google.gwt.gen2.table.client PagingScrollTable gotoPreviousPage

Introduction

In this page you can find the example usage for com.google.gwt.gen2.table.client PagingScrollTable gotoPreviousPage.

Prototype

public void gotoPreviousPage() 

Source Link

Document

Go to the previous page.

Usage

From source file:org.apache.hupa.widgets.ui.PagingOptions.java

License:Apache License

public PagingOptions(final PagingScrollTable<?> table, PagingOptionsConstants constants, Loading loading) {
    this.loading = loading;
    firstLink = new EnableHyperlink("<< " + constants.pageFirst(), "");
    prevLink = new EnableHyperlink("< " + constants.pagePrev(), "");
    lastLink = new EnableHyperlink(constants.pageLast() + " >>", "");
    nextLink = new EnableHyperlink(constants.pageNext() + " >", "");
    pagingPanel.setSpacing(3);//w w  w  .  java  2  s  . co  m

    pagingPanel.add(panel);
    pagingPanel.add(firstLink);
    pagingPanel.add(prevLink);
    pagingPanel.add(nextLink);
    pagingPanel.add(lastLink);
    panel.setWidget(text);
    panel.setWidth("100px");
    pagingPanel.setCellHorizontalAlignment(panel, HorizontalPanel.ALIGN_CENTER);
    firstLink.setEnabled(false);
    prevLink.setEnabled(false);
    lastLink.setEnabled(false);
    nextLink.setEnabled(false);

    table.addPageCountChangeHandler(new PageCountChangeHandler() {

        public void onPageCountChange(PageCountChangeEvent event) {
            int startCount = currentPage * table.getPageSize() + 1;

            int endCount = currentPage * table.getPageSize() + table.getPageSize();

            int rows = table.getTableModel().getRowCount();
            updateControl(startCount, endCount, rows);
        }

    });

    table.addPageChangeHandler(new PageChangeHandler() {

        public void onPageChange(PageChangeEvent event) {
            loading(true);

            currentPage = event.getNewPage();
            int startCount = currentPage * table.getPageSize() + 1;

            int endCount = currentPage * table.getPageSize() + table.getPageSize();
            int rows = table.getTableModel().getRowCount();

            updateControl(startCount, endCount, rows);
        }
    });

    table.addPageLoadHandler(new PageLoadHandler() {

        public void onPageLoad(PageLoadEvent event) {
            loading(false);
        }

    });

    table.addPagingFailureHandler(new PagingFailureHandler() {

        public void onPagingFailure(PagingFailureEvent event) {
            loading(false);
        }

    });

    firstLink.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            table.gotoFirstPage();
        }

    });

    prevLink.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            table.gotoPreviousPage();
        }

    });

    nextLink.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            table.gotoNextPage();
        }

    });

    lastLink.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            table.gotoLastPage();
        }

    });

    table.getTableModel().addRowCountChangeHandler(new RowCountChangeHandler() {

        public void onRowCountChange(RowCountChangeEvent event) {
            int startCount = currentPage * table.getPageSize() + 1;

            int endCount = currentPage * table.getPageSize() + table.getPageSize();

            int rows = event.getNewRowCount();
            updateControl(startCount, endCount, rows);

        }

    });
    initWidget(pagingPanel);
}