Class PageableController

java.lang.Object
org.eclipse.nebula.widgets.pagination.PageableController
All Implemented Interfaces:
java.io.Serializable

public class PageableController
extends java.lang.Object
implements java.io.Serializable
The pagination controller is used to store information about pagination :
  • the current page index: index of the selected page.
  • the page size: number items to display per page.
  • the total elements: the total elements of the paginated list.
  • the current sort information: the property name and direction of the sort.

The controller fire events as soon as pagination information change (ex:selected page change). Those information can be observed by adding IPageChangedListener to the controller.

See Also:
Serialized Form
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static int DEFAULT_PAGE_INDEX  
    static int DEFAULT_PAGE_SIZE  
  • Constructor Summary

    Constructors 
    Constructor Description
    PageableController()
    Constructor with default page size.
    PageableController​(int pageSize)
    Constructor with page size.
  • Method Summary

    Modifier and Type Method Description
    void addPageChangedListener​(IPageChangedListener listener)
    Adds the listener to the collection of listeners who will be notified when the page controller changed ( the current page page size, total elements or sort change.
    int getCurrentPage()
    Returns the current page index.
    int getPageOffset()
    Returns the current page offset.
    int getPageSize()
    Returns the page size: number items to display per page.
    int getSortDirection()
    Returns the sort direction SWT.UP, SWT.DOWN.
    java.lang.String getSortPropertyName()
    Returns the property name used to sort.
    long getTotalElements()
    Returns the total elements.
    int getTotalPages()
    Returns the total pages.
    boolean hasNextPage()
    Returns true if there is a next page and false otherwise.
    boolean hasPreviousPage()
    Returns true if there is a previous page and false otherwise.
    boolean isFirstPage()
    Returns whether the current page is the first one.
    boolean isLastPage()
    Returns whether the current page is the last one.
    void removePageChangedListener​(IPageChangedListener listener)
    Removes the listener from the collection of listeners who will be notified when page controller changed ( the current page page size, total elements or sort change.
    void reset()
    Reset the current page index and force the fire events of page index changed.
    void setCurrentPage​(int currentPage)
    Set the current page index and fire events if the given page index is different from the current page index.
    void setLocale​(java.util.Locale locale)
    Set the local for the resources.
    void setPageSize​(int pageSize)
    Set the page size and fire events if the given page size is different from the current page size.
    void setSort​(java.lang.String propertyName, int sortDirection)
    Set the sort and fire events if the given sort is different from the current sort.
    void setTotalElements​(long totalElements)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • PageableController

      public PageableController()
      Constructor with default page size.
    • PageableController

      public PageableController​(int pageSize)
      Constructor with page size.
      Parameters:
      pageSize - size of the page (number items displayed per page).
  • Method Details

    • addPageChangedListener

      public void addPageChangedListener​(IPageChangedListener listener)
      Adds the listener to the collection of listeners who will be notified when the page controller changed ( the current page page size, total elements or sort change.
      Parameters:
      listener - the listener which should be notified when the controller change.
      listener -
      See Also:
      IPageChangedListener, removePageChangedListener(IPageChangedListener)
    • removePageChangedListener

      public void removePageChangedListener​(IPageChangedListener listener)
      Removes the listener from the collection of listeners who will be notified when page controller changed ( the current page page size, total elements or sort change.
      Parameters:
      listener - the listener which should no longer be notified
      See Also:
      IPageChangedListener, addPageChangedListener(IPageChangedListener)
    • hasPreviousPage

      public boolean hasPreviousPage()
      Returns true if there is a previous page and false otherwise.
      Returns:
      true if there is a previous page and false otherwise.
    • isFirstPage

      public boolean isFirstPage()
      Returns whether the current page is the first one.
      Returns:
    • hasNextPage

      public boolean hasNextPage()
      Returns true if there is a next page and false otherwise.
      Returns:
      true if there is a next page and false otherwise.
    • getCurrentPage

      public int getCurrentPage()
      Returns the current page index.
      Returns:
    • setCurrentPage

      public void setCurrentPage​(int currentPage)
      Set the current page index and fire events if the given page index is different from the current page index.
      Parameters:
      currentPage - new current page index.
    • getPageSize

      public int getPageSize()
      Returns the page size: number items to display per page.
      Returns:
    • setPageSize

      public void setPageSize​(int pageSize)
      Set the page size and fire events if the given page size is different from the current page size.
      Parameters:
      pageSize - page size: number items to display per page.
    • getTotalPages

      public int getTotalPages()
      Returns the total pages.
      Returns:
    • isLastPage

      public boolean isLastPage()
      Returns whether the current page is the last one.
      Returns:
    • setTotalElements

      public void setTotalElements​(long totalElements)
    • getTotalElements

      public long getTotalElements()
      Returns the total elements.
      Returns:
    • getPageOffset

      public int getPageOffset()
      Returns the current page offset.
      Returns:
    • setSort

      public void setSort​(java.lang.String propertyName, int sortDirection)
      Set the sort and fire events if the given sort is different from the current sort.
      Parameters:
      propertyName - the sort property name.
      sortDirection - the sort direction SWT.UP, SWT.DOWN.
    • getSortPropertyName

      public java.lang.String getSortPropertyName()
      Returns the property name used to sort.
      Returns:
      the sort property name.
    • getSortDirection

      public int getSortDirection()
      Returns the sort direction SWT.UP, SWT.DOWN.
      Returns:
    • reset

      public void reset()
      Reset the current page index and force the fire events of page index changed.
    • setLocale

      public void setLocale​(java.util.Locale locale)
      Set the local for the resources.
      Parameters:
      locale -