Example usage for com.google.gwt.user.cellview.client SimplePager hasNextPage

List of usage examples for com.google.gwt.user.cellview.client SimplePager hasNextPage

Introduction

In this page you can find the example usage for com.google.gwt.user.cellview.client SimplePager hasNextPage.

Prototype

@Override
    public boolean hasNextPage() 

Source Link

Usage

From source file:com.dianaui.universal.core.client.ui.Pagination.java

License:Apache License

/**
 * This will help to rebuild the Pagination based on the data inside the SimplePager passed in.
 * Make sure to all this after adding/remove data from any of the grid to ensure that this stays
 * current with the SimplePager.//www . j  a v a2  s.c om
 * ex.
 * dataProvider.getList().addAll(newData);
 * pagination.rebuild(mySimplePager);
 *
 * @param pager the SimplePager of the CellTable/DataGrid
 */
public void rebuild(final SimplePager pager) {
    clear();
    previousLink = null;
    nextLink = null;

    if (pager.getPageCount() == 0) {
        return;
    }

    final AnchorListItem prev = addPreviousLink();
    prev.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            pager.previousPage();
        }
    });
    prev.setEnabled(pager.hasPreviousPage());

    for (int i = 0; i < pager.getPageCount(); i++) {
        final int display = i + 1;
        final AnchorListItem page = new AnchorListItem(String.valueOf(display));
        page.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(final ClickEvent event) {
                pager.setPage(display - 1);
            }
        });

        if (i == pager.getPage()) {
            page.setActive(true);
        }

        add(page);
    }

    final AnchorListItem next = addNextLink();
    next.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            pager.nextPage();
        }
    });
    next.setEnabled(pager.hasNextPage());
}

From source file:com.github.gwtbootstrap.showcase.client.CellTables.java

License:Apache License

private void rebuildPager(final Pagination pagination, final SimplePager pager) {
    pagination.clear();//from   www  .j  a v a  2s  .  c  o m

    if (pager.getPageCount() == 0) {
        return;
    }

    NavLink prev = new NavLink("<");

    prev.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            GWT.log(String.valueOf("prev"));
            pager.previousPage();
        }
    });

    prev.setDisabled(!pager.hasPreviousPage());

    pagination.add(prev);

    int before = 2;
    int after = 2;

    while (!pager.hasPreviousPages(before) && before > 0) {
        before--;
        if (pager.hasNextPages(after + 1)) {
            after++;
        }
    }

    while (!pager.hasNextPages(after) && after > 0) {
        after--;
        if (pager.hasPreviousPages(before + 1)) {
            before++;
        }
    }

    for (int i = pager.getPage() - before; i <= pager.getPage() + after; i++) {

        final int index = i + 1;

        NavLink page = new NavLink(String.valueOf(index));

        page.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                pager.setPage(index - 1);
            }
        });

        if (i == pager.getPage()) {
            page.setActive(true);
        }

        pagination.add(page);
    }

    NavLink next = new NavLink(">");

    next.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            GWT.log(String.valueOf("next"));
            pager.nextPage();
        }
    });

    next.setDisabled(!pager.hasNextPage());

    pagination.add(next);
}

From source file:org.gwtbootstrap3.client.ui.Pagination.java

License:Apache License

/**
 * This will help to rebuild the Pagination based on the data inside the SimplePager passed in.
 * <p/>/*from  w w w  . j a  va2s .c  o m*/
 * Make sure to all this after adding/remove data from any of the grid to ensure that this stays
 * current with the SimplePager.
 * <p/>
 * ex.
 * dataProvider.getList().addAll(newData);
 * pagination.rebuild(mySimplePager);
 *
 * @param pager the SimplePager of the CellTable/DataGrid
 */
public void rebuild(final SimplePager pager) {
    clear();

    if (pager.getPageCount() == 0) {
        return;
    }

    final AnchorListItem prev = addPreviousLink();
    prev.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(final ClickEvent event) {
            pager.previousPage();
            updatePaginationState(pager);
        }
    });
    prev.setEnabled(pager.hasPreviousPage());

    for (int i = 0; i < pager.getPageCount(); i++) {
        final int display = i + 1;
        final AnchorListItem page = new AnchorListItem(String.valueOf(display));
        page.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(final ClickEvent event) {
                pager.setPage(display - 1);
                updatePaginationState(pager);
            }
        });

        if (i == pager.getPage()) {
            page.setActive(true);
        }

        add(page);
    }

    final AnchorListItem next = addNextLink();
    next.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(final ClickEvent event) {
            pager.nextPage();
            updatePaginationState(pager);
        }
    });
    next.setEnabled(pager.hasNextPage());
}

From source file:org.gwtbootstrap3.client.ui.Pagination.java

License:Apache License

/**
 * This updates the current active page, and the enabled state
 * of the previous and next buttons in the Pagination based
 * on the state of the given SimplePager.
 * @param pager the SimplePager of the CellTable/DataGrid
 *///from   w  w w .j a va  2s. c o  m
private void updatePaginationState(final SimplePager pager) {

    for (int i = 0; i < getWidgetCount(); i++) {
        if (i == 0) { //previous button
            ((AnchorListItem) getWidget(i)).setEnabled(pager.hasPreviousPage());
        } else if (i == getWidgetCount() - 1) { //next button
            ((AnchorListItem) getWidget(i)).setEnabled(pager.hasNextPage());
        } else {
            int index = i - 1;
            if (index == pager.getPage()) {
                ((AnchorListItem) getWidget(i)).setActive(true);
            } else {
                ((AnchorListItem) getWidget(i)).setActive(false);
            }
        }
    }
}