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

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

Introduction

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

Prototype

@Override
    public void setPage(int index) 

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  . jav  a  2s .com*/
 * 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  w w w .ja v  a 2 s  .  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/>//www.ja v a 2  s . 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());
}