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

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

Introduction

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

Prototype

public HandlerRegistration addPageCountChangeHandler(PageCountChangeHandler handler) 

Source Link

Usage

From source file:com.qualogy.qafe.gwt.client.component.QPagingOptions.java

License:Apache License

/**
 * Constructor.//  ww  w  .  j av  a  2 s  .  c o m
 * 
 * @param table
 *            the table being affected
 * @param images
 *            the images to use
 */
public QPagingOptions(PagingScrollTable<?> table, PagingOptionsImages images) {
    this.table = table;

    if (this.table instanceof QPagingScrollTable) {
        ((QPagingScrollTable) this.table).setPagingOptions(this);
    }

    // Create the main widget
    HorizontalPanel hPanel = new HorizontalPanel();
    initWidget(hPanel);
    hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    setStyleName(DEFAULT_STYLENAME);

    // Create the paging image buttons
    createPageButtons(images);

    // Create the current page box
    createCurPageBox();

    // Create the page count label
    numPagesLabel = new HTML();

    // Create the loading image
    loadingImage = new Image(GWT.getModuleBaseURL() + "scrollTableLoading.gif");
    loadingImage.setVisible(false);

    // Create the error label
    errorLabel = new HTML();
    errorLabel.setStylePrimaryName("errorMessage");

    // Add the widgets to the panel
    hPanel.add(createSpacer());
    hPanel.add(firstImage);
    hPanel.add(createSpacer());
    hPanel.add(prevImage);
    hPanel.add(createSpacer());
    hPanel.add(curPageBox);
    hPanel.add(createSpacer());
    hPanel.add(numPagesLabel);
    hPanel.add(createSpacer());
    hPanel.add(nextImage);
    hPanel.add(createSpacer());
    hPanel.add(lastImage);
    hPanel.add(createSpacer());
    hPanel.add(loadingImage);
    hPanel.add(errorLabel);

    // Add handlers to the table
    table.addPageLoadHandler(new PageLoadHandler() {
        public void onPageLoad(PageLoadEvent event) {
            loadingImage.setVisible(false);
            errorLabel.setHTML("");
        }
    });
    table.addPageChangeHandler(new PageChangeHandler() {
        public void onPageChange(PageChangeEvent event) {
            curPageBox.setText((event.getNewPage() + 1) + "");
            loadingImage.setVisible(true);
            errorLabel.setHTML("");
        }
    });
    table.addPagingFailureHandler(new PagingFailureHandler() {
        public void onPagingFailure(PagingFailureEvent event) {
            loadingImage.setVisible(false);
            errorLabel.setHTML(event.getException().getMessage());
        }
    });
    table.addPageCountChangeHandler(new PageCountChangeHandler() {
        public void onPageCountChange(PageCountChangeEvent event) {
            setPageCount(event.getNewPageCount());
        }
    });
    setPageCount(table.getPageCount());
}

From source file:edu.caltech.ipac.firefly.ui.table.PagingPanel.java

License:Apache License

/**
 * Constructor.//from  w  w  w. ja  v a 2 s  .c o  m
 *
 * @param table  the table being affected
 * @param images the images to use
 */
public PagingPanel(PagingScrollTable<?> table, PagingOptions.PagingOptionsImages images) {
    this.table = table;

    // Create the main widget
    HorizontalPanel hPanel = new HorizontalPanel();
    initWidget(hPanel);
    hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    setStyleName(DEFAULT_STYLENAME);

    // Create the paging image buttons
    createPageButtons(images);

    // Create the current page box
    createCurPageBox();

    // Create the page count label
    numPagesLabel = new HTML();

    // Create the loading image
    loadingImage = new Image(GWT.getModuleBaseURL() + "scrollTableLoading.gif");
    loadingImage.setVisible(false);

    // Create the error label
    errorLabel = new HTML();
    errorLabel.setStylePrimaryName("errorMessage");

    // display status
    status = new Label();
    status.addStyleName("status");
    status.setWordWrap(false);

    // Add the widgets to the panel
    hPanel.add(createSpacer());
    hPanel.add(firstImage);
    hPanel.add(createSpacer());
    hPanel.add(prevImage);
    hPanel.add(createSpacer());
    hPanel.add(curPageBox);
    hPanel.add(createSpacer());
    hPanel.add(numPagesLabel);
    hPanel.add(createSpacer());
    hPanel.add(nextImage);
    hPanel.add(createSpacer());
    hPanel.add(lastImage);
    hPanel.add(createSpacer());
    hPanel.add(status);
    hPanel.add(createSpacer());
    hPanel.add(loadingImage);
    hPanel.add(errorLabel);

    // Add handlers to the table
    table.addPageLoadHandler(new PageLoadHandler() {
        public void onPageLoad(PageLoadEvent event) {
            setIsLoading(false);
        }
    });
    table.addPageChangeHandler(new PageChangeHandler() {
        public void onPageChange(PageChangeEvent event) {
            curPageBox.setText((event.getNewPage() + 1) + "");
            setIsLoading(true);
        }
    });
    table.addPagingFailureHandler(new PagingFailureHandler() {
        public void onPagingFailure(PagingFailureEvent event) {
            loadingImage.setVisible(false);
            errorLabel.setHTML(event.getException().getMessage());
        }
    });
    table.addPageCountChangeHandler(new PageCountChangeHandler() {
        public void onPageCountChange(PageCountChangeEvent event) {
            setPageCount(event.getNewPageCount());
        }
    });
    setPageCount(table.getPageCount());
}

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);/*  www  . j  av a  2s  . c  o 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);
}