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 aHasRowsthat 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 interfaceSimplePager.ImageButtonsConstantsConstant for labeling the simple pager navigationalSimplePager.ImageButtonsstatic interfaceSimplePager.ResourcesA ClientBundle that provides images for this widget.static interfaceSimplePager.StyleStyles used by this widget.static classSimplePager.TextLocationThe 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 aSimplePagerwith the default text location.SimplePager(SimplePager.TextLocation location)Construct aSimplePagerwith the specified text location.SimplePager(SimplePager.TextLocation location, boolean showFastForwardButton, boolean showLastPageButton)Construct aSimplePagerwith the default resources, fast forward rows and default image button names.SimplePager(SimplePager.TextLocation location, boolean showFastForwardButton, int fastForwardRows, boolean showLastPageButton)Construct aSimplePagerwith the default resources and default image button names.SimplePager(SimplePager.TextLocation location, SimplePager.Resources resources, boolean showFastForwardButton, int fastForwardRows, boolean showLastPageButton)Construct aSimplePagerwith 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 aSimplePagerwith the specified resources.SimplePager(SimplePager.TextLocation location, SimplePager.Resources resources, boolean showFastForwardButton, int fastForwardRows, boolean showLastPageButton, SimplePager.ImageButtonsConstants imageButtonConstants)Construct aSimplePagerwith the specified resources.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.StringcreateText()Get the text to display in the pager that reflects the state of the pager.voidfirstPage()Go to the first page.intgetPage()Get the current page index.intgetPageCount()Get the number of pages based on the data size.booleanhasNextPage()Returns true if there is enough data such that a call toAbstractPager.nextPage()will succeed in moving the starting point of the table forward.booleanhasNextPages(int pages)Returns true if there is enough data to display a given number of additional pages.booleanhasPage(int index)Returns true if there is enough data such that the specified page is within range.booleanhasPreviousPage()Returns true if there is enough data such that a call toAbstractPager.previousPage()will succeed in moving the starting point of the table backward.booleanhasPreviousPages(int pages)Returns true if there is enough data to display a given number of previous pages.(package private) booleanisNextButtonDisabled()Check if the next button is disabled.(package private) booleanisPreviousButtonDisabled()Check if the previous button is disabled.voidlastPage()Go to the last page.voidlastPageStart()Set the page start to the last index that will still show a full page.voidnextPage()Advance the starting row by 'pageSize' rows.protected voidonRangeOrRowCountChanged()Called when the range or row count changes.voidpreviousPage()Move the starting row back by 'pageSize' rows.voidsetDisplay(HasRows display)Set theHasRowsto be paged.voidsetPage(int index)Go to a specific page.voidsetPageSize(int pageSize)Set the page size of the display.voidsetPageStart(int index)Set the page start index.voidstartLoading()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 aSimplePagerwith the default text location.
-
SimplePager
@UiConstructor public SimplePager(SimplePager.TextLocation location)
Construct aSimplePagerwith 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 aSimplePagerwith 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 aSimplePagerwith 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 aSimplePagerwith the specified resources.- Parameters:
location- the location of the text relative to the buttonsresources- theSimplePager.Resourcesto 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 aSimplePagerwith the specified resources.- Parameters:
location- the location of the text relative to the buttonsresources- theSimplePager.Resourcesto 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 aSimplePagerwith the specified resources and default image button names.- Parameters:
location- the location of the text relative to the buttonsresources- theSimplePager.Resourcesto 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:AbstractPagerGo to the first page.- Overrides:
firstPagein classAbstractPager
-
getPage
public int getPage()
Description copied from class:AbstractPagerGet 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:
getPagein 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:AbstractPagerGet the number of pages based on the data size.- Overrides:
getPageCountin classAbstractPager- Returns:
- the page count, or -1 if the display is not set
-
hasNextPage
public boolean hasNextPage()
Description copied from class:AbstractPagerReturns true if there is enough data such that a call toAbstractPager.nextPage()will succeed in moving the starting point of the table forward.- Overrides:
hasNextPagein classAbstractPager- Returns:
- true if there is a next page
-
hasNextPages
public boolean hasNextPages(int pages)
Description copied from class:AbstractPagerReturns true if there is enough data to display a given number of additional pages.- Overrides:
hasNextPagesin classAbstractPager- Parameters:
pages- the number of pages to query- Returns:
- true if there are
pagesnext pages
-
hasPage
public boolean hasPage(int index)
Description copied from class:AbstractPagerReturns true if there is enough data such that the specified page is within range.- Overrides:
hasPagein classAbstractPager- Parameters:
index- the page index- Returns:
- true if the specified page is in range
-
hasPreviousPage
public boolean hasPreviousPage()
Description copied from class:AbstractPagerReturns true if there is enough data such that a call toAbstractPager.previousPage()will succeed in moving the starting point of the table backward.- Overrides:
hasPreviousPagein classAbstractPager- Returns:
- true if there is a previous page
-
hasPreviousPages
public boolean hasPreviousPages(int pages)
Description copied from class:AbstractPagerReturns true if there is enough data to display a given number of previous pages.- Overrides:
hasPreviousPagesin classAbstractPager- Parameters:
pages- the number of previous pages to query- Returns:
- true if there are
pagesprevious pages
-
lastPage
public void lastPage()
Description copied from class:AbstractPagerGo to the last page.- Overrides:
lastPagein classAbstractPager
-
lastPageStart
public void lastPageStart()
Description copied from class:AbstractPagerSet the page start to the last index that will still show a full page.- Overrides:
lastPageStartin classAbstractPager
-
nextPage
public void nextPage()
Description copied from class:AbstractPagerAdvance the starting row by 'pageSize' rows.- Overrides:
nextPagein classAbstractPager
-
previousPage
public void previousPage()
Description copied from class:AbstractPagerMove the starting row back by 'pageSize' rows.- Overrides:
previousPagein classAbstractPager
-
setDisplay
public void setDisplay(HasRows display)
Description copied from class:AbstractPagerSet theHasRowsto be paged.- Overrides:
setDisplayin classAbstractPager- Parameters:
display- theHasRows- See Also:
AbstractPager.getDisplay()
-
setPage
public void setPage(int index)
Description copied from class:AbstractPagerGo to a specific page.- Overrides:
setPagein classAbstractPager- Parameters:
index- the page index- See Also:
AbstractPager.getPage()
-
setPageSize
public void setPageSize(int pageSize)
Description copied from class:AbstractPagerSet the page size of the display.- Overrides:
setPageSizein classAbstractPager- Parameters:
pageSize- the new page size- See Also:
AbstractPager.getPageSize()
-
setPageStart
public void setPageStart(int index)
Description copied from class:AbstractPagerSet the page start index.- Overrides:
setPageStartin 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:AbstractPagerCalled when the range or row count changes. Implement this method to update the pager.- Specified by:
onRangeOrRowCountChangedin 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.
-
-