Class SimplePager

All Implemented Interfaces:
HasAttachHandlers, HasHandlers, EventListener, HasVisibility, IsRenderable, IsWidget

public class SimplePager extends AbstractPager
A pager for controlling a HasRows that only supports simple page navigation.

Example

public class SimplePagerExample implements EntryPoint {

  public void onModuleLoad() {
    // Create a CellList.
    CellList<String> cellList = new CellList<String>(new TextCell());

    // Add a cellList to a data provider.
    ListDataProvider<String> dataProvider = new ListDataProvider<String>();
    List<String> data = dataProvider.getList();
    for (int i = 0; i < 200; i++) {
      data.add("Item " + i);
    }
    dataProvider.addDataDisplay(cellList);

    // Create a SimplePager.
    SimplePager pager = new SimplePager();

    // Set the cellList as the display.
    pager.setDisplay(cellList);

    // Add the pager and list to the page.
    VerticalPanel vPanel = new VerticalPanel();
    vPanel.add(pager);
    vPanel.add(cellList);
    RootPanel.get().add(vPanel);
  }
}

  • Constructor Details

    • SimplePager

      public SimplePager()
      Construct a SimplePager with the default text location.
    • SimplePager

      @UiConstructor public SimplePager(SimplePager.TextLocation location)
      Construct a SimplePager with the specified text location.
      Parameters:
      location - the location of the text relative to the buttons
    • SimplePager

      public SimplePager(SimplePager.TextLocation location, boolean showFastForwardButton, boolean showLastPageButton)
      Construct a SimplePager with the default resources, fast forward rows and default image button names.
      Parameters:
      location - the location of the text relative to the buttons
      showFastForwardButton - if true, show a fast-forward button that advances by a larger increment than a single page
      showLastPageButton - if true, show a button to go to the last page
    • SimplePager

      public SimplePager(SimplePager.TextLocation location, boolean showFastForwardButton, int fastForwardRows, boolean showLastPageButton)
      Construct a SimplePager with the default resources and default image button names.
      Parameters:
      location - the location of the text relative to the buttons
      showFastForwardButton - if true, show a fast-forward button that advances by a larger increment than a single page
      fastForwardRows - the number of rows to jump when fast forwarding
      showLastPageButton - if true, show a button to go to the last page
    • SimplePager

      public SimplePager(SimplePager.TextLocation location, SimplePager.Resources resources, boolean showFastForwardButton, int fastForwardRows, boolean showLastPageButton, SimplePager.ImageButtonsConstants imageButtonConstants)
      Construct a SimplePager with the specified resources.
      Parameters:
      location - the location of the text relative to the buttons
      resources - the SimplePager.Resources to use
      showFastForwardButton - if true, show a fast-forward button that advances by a larger increment than a single page
      fastForwardRows - the number of rows to jump when fast forwarding
      showLastPageButton - if true, show a button to go to the last page
      imageButtonConstants - Constants that contain the image button names
    • SimplePager

      public SimplePager(SimplePager.TextLocation location, SimplePager.Resources resources, boolean showFastForwardButton, int fastForwardRows, boolean showLastPageButton, boolean showFirstPageButton, SimplePager.ImageButtonsConstants imageButtonConstants)
      Construct a SimplePager with the specified resources.
      Parameters:
      location - the location of the text relative to the buttons
      resources - the SimplePager.Resources to use
      showFastForwardButton - if true, show a fast-forward button that advances by a larger increment than a single page
      fastForwardRows - the number of rows to jump when fast forwarding
      showLastPageButton - if true, show a button to go to the last page
      showFirstPageButton - if true, show a button to go to the first page
      imageButtonConstants - Constants that contain the image button names
    • SimplePager

      public SimplePager(SimplePager.TextLocation location, SimplePager.Resources resources, boolean showFastForwardButton, int fastForwardRows, boolean showLastPageButton)
      Construct a SimplePager with the specified resources and default image button names.
      Parameters:
      location - the location of the text relative to the buttons
      resources - the SimplePager.Resources to use
      showFastForwardButton - if true, show a fast-forward button that advances by a larger increment than a single page
      fastForwardRows - the number of rows to jump when fast forwarding
      showLastPageButton - if true, show a button to go to the last page
  • Method Details

    • firstPage

      public void firstPage()
      Description copied from class: AbstractPager
      Go to the first page.
      Overrides:
      firstPage in class AbstractPager
    • getPage

      public int getPage()
      Description copied from class: AbstractPager

      Get the current page index.

      Since the page start index can be set to any value, its possible to be between pages. In this case, the return value is the number of times AbstractPager.previousPage() can be called.

      Overrides:
      getPage in class AbstractPager
      Returns:
      the page index, or -1 if the display is not set
      See Also:
    • getPageCount

      public int getPageCount()
      Description copied from class: AbstractPager
      Get the number of pages based on the data size.
      Overrides:
      getPageCount in class AbstractPager
      Returns:
      the page count, or -1 if the display is not set
    • hasNextPage

      public boolean hasNextPage()
      Description copied from class: AbstractPager
      Returns true if there is enough data such that a call to AbstractPager.nextPage() will succeed in moving the starting point of the table forward.
      Overrides:
      hasNextPage in class AbstractPager
      Returns:
      true if there is a next page
    • hasNextPages

      public boolean hasNextPages(int pages)
      Description copied from class: AbstractPager
      Returns true if there is enough data to display a given number of additional pages.
      Overrides:
      hasNextPages in class AbstractPager
      Parameters:
      pages - the number of pages to query
      Returns:
      true if there are pages next pages
    • hasPage

      public boolean hasPage(int index)
      Description copied from class: AbstractPager
      Returns true if there is enough data such that the specified page is within range.
      Overrides:
      hasPage in class AbstractPager
      Parameters:
      index - the page index
      Returns:
      true if the specified page is in range
    • hasPreviousPage

      public boolean hasPreviousPage()
      Description copied from class: AbstractPager
      Returns true if there is enough data such that a call to AbstractPager.previousPage() will succeed in moving the starting point of the table backward.
      Overrides:
      hasPreviousPage in class AbstractPager
      Returns:
      true if there is a previous page
    • hasPreviousPages

      public boolean hasPreviousPages(int pages)
      Description copied from class: AbstractPager
      Returns true if there is enough data to display a given number of previous pages.
      Overrides:
      hasPreviousPages in class AbstractPager
      Parameters:
      pages - the number of previous pages to query
      Returns:
      true if there are pages previous pages
    • lastPage

      public void lastPage()
      Description copied from class: AbstractPager
      Go to the last page.
      Overrides:
      lastPage in class AbstractPager
    • lastPageStart

      public void lastPageStart()
      Description copied from class: AbstractPager
      Set the page start to the last index that will still show a full page.
      Overrides:
      lastPageStart in class AbstractPager
    • nextPage

      public void nextPage()
      Description copied from class: AbstractPager
      Advance the starting row by 'pageSize' rows.
      Overrides:
      nextPage in class AbstractPager
    • previousPage

      public void previousPage()
      Description copied from class: AbstractPager
      Move the starting row back by 'pageSize' rows.
      Overrides:
      previousPage in class AbstractPager
    • setDisplay

      public void setDisplay(HasRows display)
      Description copied from class: AbstractPager
      Set the HasRows to be paged.
      Overrides:
      setDisplay in class AbstractPager
      Parameters:
      display - the HasRows
      See Also:
    • setPage

      public void setPage(int index)
      Description copied from class: AbstractPager
      Go to a specific page.
      Overrides:
      setPage in class AbstractPager
      Parameters:
      index - the page index
      See Also:
    • setPageSize

      public void setPageSize(int pageSize)
      Description copied from class: AbstractPager
      Set the page size of the display.
      Overrides:
      setPageSize in class AbstractPager
      Parameters:
      pageSize - the new page size
      See Also:
    • setPageStart

      public void setPageStart(int index)
      Description copied from class: AbstractPager
      Set the page start index.
      Overrides:
      setPageStart in class AbstractPager
      Parameters:
      index - the index
      See Also:
    • startLoading

      public void startLoading()
      Let the page know that the table is loading. Call this method to clear all data from the table and hide the current range when new data is being loaded into the table.
    • createText

      protected String createText()
      Get the text to display in the pager that reflects the state of the pager.
      Returns:
      the text
    • onRangeOrRowCountChanged

      protected void onRangeOrRowCountChanged()
      Description copied from class: AbstractPager
      Called when the range or row count changes. Implement this method to update the pager.
      Specified by:
      onRangeOrRowCountChanged in class AbstractPager
    • isNextButtonDisabled

      boolean isNextButtonDisabled()
      Check if the next button is disabled. Visible for testing.
    • isPreviousButtonDisabled

      boolean isPreviousButtonDisabled()
      Check if the previous button is disabled. Visible for testing.