Class SimplePager
- java.lang.Object
-
- com.google.gwt.user.client.ui.UIObject
-
- com.google.gwt.user.client.ui.Widget
-
- com.google.gwt.user.client.ui.Composite
-
- com.google.gwt.user.cellview.client.AbstractPager
-
- com.google.gwt.user.cellview.client.SimplePager
-
- All Implemented Interfaces:
HasAttachHandlers
,HasHandlers
,EventListener
,HasVisibility
,IsRenderable
,IsWidget
public class SimplePager extends AbstractPager
A pager for controlling aHasRows
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); } }
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
SimplePager.ImageButtonsConstants
Constant for labeling the simple pager navigationalSimplePager.ImageButton
sstatic interface
SimplePager.Resources
A ClientBundle that provides images for this widget.static interface
SimplePager.Style
Styles used by this widget.static class
SimplePager.TextLocation
The location of the text relative to the paging buttons.-
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
-
-
Field Summary
-
Fields inherited from class com.google.gwt.user.cellview.client.AbstractPager
rangeChangeHandler, rowCountChangeHandler
-
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
-
-
Constructor Summary
Constructors Constructor Description SimplePager()
Construct aSimplePager
with the default text location.SimplePager(SimplePager.TextLocation location)
Construct aSimplePager
with the specified text location.SimplePager(SimplePager.TextLocation location, boolean showFastForwardButton, boolean showLastPageButton)
Construct aSimplePager
with the default resources, fast forward rows and default image button names.SimplePager(SimplePager.TextLocation location, boolean showFastForwardButton, int fastForwardRows, boolean showLastPageButton)
Construct aSimplePager
with the default resources and default image button names.SimplePager(SimplePager.TextLocation location, SimplePager.Resources resources, boolean showFastForwardButton, int fastForwardRows, boolean showLastPageButton)
Construct aSimplePager
with the specified resources and default image button names.SimplePager(SimplePager.TextLocation location, SimplePager.Resources resources, boolean showFastForwardButton, int fastForwardRows, boolean showLastPageButton, boolean showFirstPageButton, SimplePager.ImageButtonsConstants imageButtonConstants)
Construct aSimplePager
with the specified resources.SimplePager(SimplePager.TextLocation location, SimplePager.Resources resources, boolean showFastForwardButton, int fastForwardRows, boolean showLastPageButton, SimplePager.ImageButtonsConstants imageButtonConstants)
Construct aSimplePager
with the specified resources.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
createText()
Get the text to display in the pager that reflects the state of the pager.void
firstPage()
Go to the first page.int
getPage()
Get the current page index.int
getPageCount()
Get the number of pages based on the data size.boolean
hasNextPage()
Returns true if there is enough data such that a call toAbstractPager.nextPage()
will succeed in moving the starting point of the table forward.boolean
hasNextPages(int pages)
Returns true if there is enough data to display a given number of additional pages.boolean
hasPage(int index)
Returns true if there is enough data such that the specified page is within range.boolean
hasPreviousPage()
Returns true if there is enough data such that a call toAbstractPager.previousPage()
will succeed in moving the starting point of the table backward.boolean
hasPreviousPages(int pages)
Returns true if there is enough data to display a given number of previous pages.(package private) boolean
isNextButtonDisabled()
Check if the next button is disabled.(package private) boolean
isPreviousButtonDisabled()
Check if the previous button is disabled.void
lastPage()
Go to the last page.void
lastPageStart()
Set the page start to the last index that will still show a full page.void
nextPage()
Advance the starting row by 'pageSize' rows.protected void
onRangeOrRowCountChanged()
Called when the range or row count changes.void
previousPage()
Move the starting row back by 'pageSize' rows.void
setDisplay(HasRows display)
Set theHasRows
to be paged.void
setPage(int index)
Go to a specific page.void
setPageSize(int pageSize)
Set the page size of the display.void
setPageStart(int index)
Set the page start index.void
startLoading()
Let the page know that the table is loading.-
Methods inherited from class com.google.gwt.user.cellview.client.AbstractPager
getDisplay, getPageSize, getPageStart, isRangeLimited, setRangeLimited
-
Methods inherited from class com.google.gwt.user.client.ui.Composite
claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, onBrowserEvent, onDetach, render, render, resolvePotentialElement, setWidget
-
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
-
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString
-
-
-
-
Constructor Detail
-
SimplePager
public SimplePager()
Construct aSimplePager
with the default text location.
-
SimplePager
@UiConstructor public SimplePager(SimplePager.TextLocation location)
Construct aSimplePager
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 aSimplePager
with the default resources, fast forward rows and default image button names.- Parameters:
location
- the location of the text relative to the buttonsshowFastForwardButton
- if true, show a fast-forward button that advances by a larger increment than a single pageshowLastPageButton
- if true, show a button to go to the last page
-
SimplePager
public SimplePager(SimplePager.TextLocation location, boolean showFastForwardButton, int fastForwardRows, boolean showLastPageButton)
Construct aSimplePager
with the default resources and default image button names.- Parameters:
location
- the location of the text relative to the buttonsshowFastForwardButton
- if true, show a fast-forward button that advances by a larger increment than a single pagefastForwardRows
- the number of rows to jump when fast forwardingshowLastPageButton
- 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 aSimplePager
with the specified resources.- Parameters:
location
- the location of the text relative to the buttonsresources
- theSimplePager.Resources
to useshowFastForwardButton
- if true, show a fast-forward button that advances by a larger increment than a single pagefastForwardRows
- the number of rows to jump when fast forwardingshowLastPageButton
- if true, show a button to go to the last pageimageButtonConstants
- 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 aSimplePager
with the specified resources.- Parameters:
location
- the location of the text relative to the buttonsresources
- theSimplePager.Resources
to useshowFastForwardButton
- if true, show a fast-forward button that advances by a larger increment than a single pagefastForwardRows
- the number of rows to jump when fast forwardingshowLastPageButton
- if true, show a button to go to the last pageshowFirstPageButton
- if true, show a button to go to the first pageimageButtonConstants
- Constants that contain the image button names
-
SimplePager
public SimplePager(SimplePager.TextLocation location, SimplePager.Resources resources, boolean showFastForwardButton, int fastForwardRows, boolean showLastPageButton)
Construct aSimplePager
with the specified resources and default image button names.- Parameters:
location
- the location of the text relative to the buttonsresources
- theSimplePager.Resources
to useshowFastForwardButton
- if true, show a fast-forward button that advances by a larger increment than a single pagefastForwardRows
- the number of rows to jump when fast forwardingshowLastPageButton
- if true, show a button to go to the last page
-
-
Method Detail
-
firstPage
public void firstPage()
Description copied from class:AbstractPager
Go to the first page.- Overrides:
firstPage
in classAbstractPager
-
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 classAbstractPager
- Returns:
- the page index, or -1 if the display is not set
- See Also:
AbstractPager.setPage(int)
-
getPageCount
public int getPageCount()
Description copied from class:AbstractPager
Get the number of pages based on the data size.- Overrides:
getPageCount
in classAbstractPager
- 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 toAbstractPager.nextPage()
will succeed in moving the starting point of the table forward.- Overrides:
hasNextPage
in classAbstractPager
- 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 classAbstractPager
- 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 classAbstractPager
- 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 toAbstractPager.previousPage()
will succeed in moving the starting point of the table backward.- Overrides:
hasPreviousPage
in classAbstractPager
- 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 classAbstractPager
- 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 classAbstractPager
-
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 classAbstractPager
-
nextPage
public void nextPage()
Description copied from class:AbstractPager
Advance the starting row by 'pageSize' rows.- Overrides:
nextPage
in classAbstractPager
-
previousPage
public void previousPage()
Description copied from class:AbstractPager
Move the starting row back by 'pageSize' rows.- Overrides:
previousPage
in classAbstractPager
-
setDisplay
public void setDisplay(HasRows display)
Description copied from class:AbstractPager
Set theHasRows
to be paged.- Overrides:
setDisplay
in classAbstractPager
- Parameters:
display
- theHasRows
- See Also:
AbstractPager.getDisplay()
-
setPage
public void setPage(int index)
Description copied from class:AbstractPager
Go to a specific page.- Overrides:
setPage
in classAbstractPager
- Parameters:
index
- the page index- See Also:
AbstractPager.getPage()
-
setPageSize
public void setPageSize(int pageSize)
Description copied from class:AbstractPager
Set the page size of the display.- Overrides:
setPageSize
in classAbstractPager
- Parameters:
pageSize
- the new page size- See Also:
AbstractPager.getPageSize()
-
setPageStart
public void setPageStart(int index)
Description copied from class:AbstractPager
Set the page start index.- Overrides:
setPageStart
in classAbstractPager
- Parameters:
index
- the index- See Also:
AbstractPager.getPageStart()
-
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 classAbstractPager
-
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.
-
-