T - the data type of items in the listclass HasDataPresenter<T> extends java.lang.Object implements HasData<T>, HasKeyProvider<T>, HasKeyboardPagingPolicy
 Presenter implementation of HasData that presents data for various
 cell based widgets. This class contains most of the shared logic used by
 these widgets, making it easier to test the common code.
 
In proper MVP design, user code would interact with the presenter. However, that would complicate the widget code. Instead, each widget owns its own presenter and contains its own View. The widget forwards commands through to the presenter, which then updates the widget via the view. This keeps the user facing API simpler.
 Updates are not pushed to the view immediately. Instead, the presenter
 collects updates and resolves them all in a finally command. This reduces the
 total number of DOM manipulations, and makes it easier to handle side effects
 in user code triggered by the rendering pass. The view is responsible for
 called flush() to force the presenter to synchronize the view when
 needed.
 
| Modifier and Type | Class and Description | 
|---|---|
| (package private) static interface  | HasDataPresenter.ElementIteratorAn iterator over DOM elements. | 
| (package private) static interface  | HasDataPresenter.View<T>The view that this presenter presents. | 
HasKeyboardPagingPolicy.KeyboardPagingPolicyHasKeyboardSelectionPolicy.KeyboardSelectionPolicy| Modifier and Type | Field and Description | 
|---|---|
| (package private) static int | PAGE_INCREMENTThe number of rows to jump when PAGE_UP or PAGE_DOWN is pressed and the
  HasKeyboardPagingPolicy.KeyboardPagingPolicyisHasKeyboardPagingPolicy.KeyboardPagingPolicy.INCREASE_RANGE. | 
| Constructor and Description | 
|---|
| HasDataPresenter(HasData<T> display,
                HasDataPresenter.View<T> view,
                int pageSize,
                ProvidesKey<T> keyProvider)Construct a new  HasDataPresenter. | 
| Modifier and Type | Method and Description | 
|---|---|
| HandlerRegistration | addCellPreviewHandler(CellPreviewEvent.Handler<T> handler)Adds a  CellPreviewEventhandler. | 
| HandlerRegistration | addLoadingStateChangeHandler(LoadingStateChangeEvent.Handler handler) | 
| HandlerRegistration | addRangeChangeHandler(RangeChangeEvent.Handler handler)Add a  RangeChangeEvent.Handler. | 
| HandlerRegistration | addRowCountChangeHandler(RowCountChangeEvent.Handler handler)Add a  RowCountChangeEvent.Handler. | 
| (package private) java.util.List<Range> | calculateModifiedRanges(JsArrayInteger modifiedRows,
                       int pageStart,
                       int pageEnd)Combine the modified row indexes into as many as two  Ranges,
 optimizing to have the fewest unmodified rows within the ranges. | 
| void | clearKeyboardSelectedRowValue()Clear the row value associated with the keyboard selected row. | 
| void | clearSelectionModel()Clear the  SelectionModelwithout updating the view. | 
| void | fireEvent(GwtEvent<?> event)Fires the given event to the handlers listening to the event's type. | 
| void | flush()Flush pending changes to the view. | 
| int | getCurrentPageSize()Get the current page size. | 
| HasKeyboardPagingPolicy.KeyboardPagingPolicy | getKeyboardPagingPolicy() | 
| int | getKeyboardSelectedRow()Get the index of the keyboard selected row relative to the page start. | 
| int | getKeyboardSelectedRowInView()Get the index of the keyboard selected row relative to the page start as it
 appears in the view, regardless of whether or not there is a pending
 change. | 
| T | getKeyboardSelectedRowValue()Get the value that the user selected. | 
| HasKeyboardSelectionPolicy.KeyboardSelectionPolicy | getKeyboardSelectionPolicy() | 
| ProvidesKey<T> | getKeyProvider()Return the key provider. | 
| int | getRowCount()Get the overall data size. | 
| SelectionModel<? super T> | getSelectionModel()Get the  SelectionModelused by thisHasData. | 
| T | getVisibleItem(int indexOnPage)Get the row value at the specified visible index. | 
| int | getVisibleItemCount()Get the number of visible items being displayed. | 
| java.util.List<T> | getVisibleItems()Get an  Iterablecomposed of all of the visible items. | 
| Range | getVisibleRange()Return the range of data being displayed. | 
| boolean | hasPendingState()Check whether or not there is a pending state. | 
| boolean | isEmpty()Check whether or not the data set is empty. | 
| boolean | isRowCountExact()Check if the total row count is exact, or an estimate. | 
| void | redraw()Redraw the list with the current data. | 
| protected void | scheduleFinally(Scheduler.ScheduledCommand command)Schedules the command. | 
| void | setKeyboardPagingPolicy(HasKeyboardPagingPolicy.KeyboardPagingPolicy policy) | 
| void | setKeyboardSelectedRow(int index,
                      boolean stealFocus,
                      boolean forceUpdate)Set the row index of the keyboard selected element. | 
| void | setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy policy) | 
| void | setRowCount(int count)Set the exact total count of all rows. | 
| void | setRowCount(int count,
           boolean isExact)Set the total count of all rows, specifying whether the count is exact or
 an estimate. | 
| void | setRowData(int start,
          java.util.List<? extends T> values)
 Set a values associated with the rows in the visible range. | 
| void | setSelectionModel(SelectionModel<? super T> selectionModel)Set the  SelectionModelused by thisHasData. | 
| void | setVisibleRange(int start,
               int length)Set the visible range or rows. | 
| void | setVisibleRange(Range range)Set the visible range or rows. | 
| void | setVisibleRangeAndClearData(Range range,
                           boolean forceRangeChangeEvent)
 Set the visible range and clear the current visible data. | 
static final int PAGE_INCREMENT
HasKeyboardPagingPolicy.KeyboardPagingPolicy is
 HasKeyboardPagingPolicy.KeyboardPagingPolicy.INCREASE_RANGE.public HasDataPresenter(HasData<T> display, HasDataPresenter.View<T> view, int pageSize, ProvidesKey<T> keyProvider)
HasDataPresenter.display - the display that is being presentedview - the view implementationpageSize - the default page sizepublic HandlerRegistration addCellPreviewHandler(CellPreviewEvent.Handler<T> handler)
HasCellPreviewHandlersCellPreviewEvent handler.addCellPreviewHandler in interface HasCellPreviewHandlers<T>handler - the handlerpublic HandlerRegistration addLoadingStateChangeHandler(LoadingStateChangeEvent.Handler handler)
public HandlerRegistration addRangeChangeHandler(RangeChangeEvent.Handler handler)
HasRowsRangeChangeEvent.Handler.addRangeChangeHandler in interface HasRowshandler - the handlerHandlerRegistration to remove the handlerpublic HandlerRegistration addRowCountChangeHandler(RowCountChangeEvent.Handler handler)
HasRowsRowCountChangeEvent.Handler.addRowCountChangeHandler in interface HasRowshandler - the handlerHandlerRegistration to remove the handlerpublic void clearKeyboardSelectedRowValue()
public void clearSelectionModel()
SelectionModel without updating the view.public void fireEvent(GwtEvent<?> event)
HasHandlers
 Any exceptions thrown by handlers will be bundled into a
 UmbrellaException and then re-thrown after all handlers have
 completed. An exception thrown by a handler will not prevent other handlers
 from executing.
fireEvent in interface HasHandlersevent - the eventjava.lang.UnsupportedOperationExceptionpublic void flush()
public int getCurrentPageSize()
public HasKeyboardPagingPolicy.KeyboardPagingPolicy getKeyboardPagingPolicy()
HasKeyboardPagingPolicygetKeyboardPagingPolicy in interface HasKeyboardPagingPolicyHasKeyboardPagingPolicy.setKeyboardPagingPolicy(KeyboardPagingPolicy)public int getKeyboardSelectedRow()
public int getKeyboardSelectedRowInView()
public T getKeyboardSelectedRowValue()
public HasKeyboardSelectionPolicy.KeyboardSelectionPolicy getKeyboardSelectionPolicy()
HasKeyboardSelectionPolicygetKeyboardSelectionPolicy in interface HasKeyboardSelectionPolicyHasKeyboardSelectionPolicy.setKeyboardSelectionPolicy(KeyboardSelectionPolicy)public ProvidesKey<T> getKeyProvider()
HasKeyProvidergetKeyProvider in interface HasKeyProvider<T>ProvidesKey instancepublic int getRowCount()
getRowCount in interface HasRowsHasRows.setRowCount(int)public SelectionModel<? super T> getSelectionModel()
HasDataSelectionModel used by this HasData.getSelectionModel in interface HasData<T>SelectionModelHasData.setSelectionModel(SelectionModel)public T getVisibleItem(int indexOnPage)
HasDatagetVisibleItem in interface HasData<T>indexOnPage - the index on the pagepublic int getVisibleItemCount()
HasDatagetVisibleItemCount in interface HasData<T>public java.util.List<T> getVisibleItems()
HasDataIterable composed of all of the visible items.getVisibleItems in interface HasData<T>Iterable instancepublic Range getVisibleRange()
getVisibleRange in interface HasRowsHasRows.setVisibleRange(Range), 
HasRows.setVisibleRange(int, int)public boolean hasPendingState()
public boolean isEmpty()
public boolean isRowCountExact()
HasRowsisRowCountExact in interface HasRowspublic void redraw()
public void setKeyboardPagingPolicy(HasKeyboardPagingPolicy.KeyboardPagingPolicy policy)
HasKeyboardPagingPolicysetKeyboardPagingPolicy in interface HasKeyboardPagingPolicypolicy - the paging policyHasKeyboardPagingPolicy.getKeyboardPagingPolicy()public void setKeyboardSelectedRow(int index,
                                   boolean stealFocus,
                                   boolean forceUpdate)
index - the row indexstealFocus - true to steal focusforceUpdate - force the update even if the row didn't changepublic void setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy policy)
HasKeyboardSelectionPolicysetKeyboardSelectionPolicy in interface HasKeyboardSelectionPolicypolicy - the selection policyHasKeyboardSelectionPolicy.getKeyboardSelectionPolicy()public final void setRowCount(int count)
HasRowsHasRows.setRowCount(int, boolean).setRowCount in interface HasRowscount - the exact total countjava.lang.UnsupportedOperationExceptionHasRows.getRowCount()public void setRowCount(int count,
                        boolean isExact)
HasRowssetRowCount in interface HasRowscount - the total countisExact - true if the count is exact, false if an estimateHasRows.getRowCount()public void setRowData(int start,
                       java.util.List<? extends T> values)
HasDataSet a values associated with the rows in the visible range.
 This method does not replace all rows in the display; it replaces
 the row values starting at the specified start index through the length of
 the specified values. You must call HasRows.setRowCount(int) to set
 the total number of rows in the display. You should also use
 HasRows.setRowCount(int) to remove rows when the total number of rows
 decreases.
 
setRowData in interface HasData<T>start - the start index of the datavalues - the values within the rangepublic void setSelectionModel(SelectionModel<? super T> selectionModel)
HasDataSelectionModel used by this HasData.setSelectionModel in interface HasData<T>selectionModel - the SelectionModelHasData.getSelectionModel()public final void setVisibleRange(int start,
                                  int length)
HasRowsHasRows.setVisibleRange(Range).setVisibleRange in interface HasRowsstart - the start indexlength - the lengthjava.lang.UnsupportedOperationExceptionHasRows.getVisibleRange()public void setVisibleRange(Range range)
HasRowssetVisibleRange in interface HasRowsrange - the visible rangeHasRows.getVisibleRange()public void setVisibleRangeAndClearData(Range range, boolean forceRangeChangeEvent)
HasDataSet the visible range and clear the current visible data.
 If the second argument forceRangeChangeEvent is true, a
 RangeChangeEvent will be fired even if the range does not change.
 If false, a RangeChangeEvent will only be fired if the range
 changes.
 
setVisibleRangeAndClearData in interface HasData<T>range - the new RangeforceRangeChangeEvent - true to fire a RangeChangeEvent even
          if the Range doesn't changeprotected void scheduleFinally(Scheduler.ScheduledCommand command)
Protected so that subclasses can override to use an alternative scheduler.
command - the command to executejava.util.List<Range> calculateModifiedRanges(JsArrayInteger modifiedRows, int pageStart, int pageEnd)
Ranges,
 optimizing to have the fewest unmodified rows within the ranges. Using two
 ranges covers the most common use cases of selecting one row, selecting a
 range, moving selection from one row to another, or moving keyboard
 selection.
 
 Visible for testing.
This method has the side effect of sorting the modified rows.
modifiedRows - the unordered indexes of modified rows