public class PageableController
extends java.lang.Object
implements java.io.Serializable
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.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_PAGE_INDEX |
static int |
DEFAULT_PAGE_SIZE |
Constructor and Description |
---|
PageableController()
Constructor with default page size.
|
PageableController(int pageSize)
Constructor with page size.
|
Modifier and Type | Method and 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) |
public static final int DEFAULT_PAGE_INDEX
public static final int DEFAULT_PAGE_SIZE
public PageableController()
public PageableController(int pageSize)
pageSize
- size of the page (number items displayed per page).public void addPageChangedListener(IPageChangedListener listener)
listener
- the listener which should be notified when the controller
change.listener
- IPageChangedListener
,
removePageChangedListener(IPageChangedListener)
public void removePageChangedListener(IPageChangedListener listener)
listener
- the listener which should no longer be notifiedIPageChangedListener
,
addPageChangedListener(IPageChangedListener)
public boolean hasPreviousPage()
public boolean isFirstPage()
public boolean hasNextPage()
public int getCurrentPage()
public void setCurrentPage(int currentPage)
currentPage
- new current page index.public int getPageSize()
public void setPageSize(int pageSize)
pageSize
- page size: number items to display per page.public int getTotalPages()
public boolean isLastPage()
public void setTotalElements(long totalElements)
public long getTotalElements()
public int getPageOffset()
public void setSort(java.lang.String propertyName, int sortDirection)
propertyName
- the sort property name.sortDirection
- the sort direction SWT.UP
, SWT.DOWN
.public java.lang.String getSortPropertyName()
public int getSortDirection()
SWT.UP
, SWT.DOWN
.public void reset()
public void setLocale(java.util.Locale locale)
locale
-