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 Detail

      • SimplePager

        public SimplePager()
        Construct a SimplePager with the default text location.
      • 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 Detail

      • 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
      • 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
      • 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
      • 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 java.lang.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.