|
GWT 2.7.0 | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.google.gwt.user.cellview.client.HasDataPresenter<T>
T - the data type of items in the listclass HasDataPresenter<T>
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.
| Nested Class Summary | |
|---|---|
(package private) static interface |
HasDataPresenter.ElementIterator
An iterator over DOM elements. |
(package private) static interface |
HasDataPresenter.View<T>
The view that this presenter presents. |
| Nested classes/interfaces inherited from interface com.google.gwt.user.cellview.client.HasKeyboardPagingPolicy |
|---|
HasKeyboardPagingPolicy.KeyboardPagingPolicy |
| Nested classes/interfaces inherited from interface com.google.gwt.user.cellview.client.HasKeyboardSelectionPolicy |
|---|
HasKeyboardSelectionPolicy.KeyboardSelectionPolicy |
| Field Summary | |
|---|---|
(package private) static int |
PAGE_INCREMENT
The number of rows to jump when PAGE_UP or PAGE_DOWN is pressed and the HasKeyboardPagingPolicy.KeyboardPagingPolicy is
HasKeyboardPagingPolicy.KeyboardPagingPolicy.INCREASE_RANGE. |
| Constructor Summary | |
|---|---|
HasDataPresenter(HasData<T> display,
HasDataPresenter.View<T> view,
int pageSize,
ProvidesKey<T> keyProvider)
Construct a new HasDataPresenter. |
|
| Method Summary | |
|---|---|
HandlerRegistration |
addCellPreviewHandler(CellPreviewEvent.Handler<T> handler)
Adds a CellPreviewEvent handler. |
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 SelectionModel without 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()
Get the HasKeyboardPagingPolicy.KeyboardPagingPolicy. |
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()
Get the HasKeyboardSelectionPolicy.KeyboardSelectionPolicy. |
ProvidesKey<T> |
getKeyProvider()
Return the key provider. |
int |
getRowCount()
Get the overall data size. |
SelectionModel<? super T> |
getSelectionModel()
Get the SelectionModel used by this HasData. |
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 Iterable composed 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)
Set the HasKeyboardPagingPolicy.KeyboardPagingPolicy. |
void |
setKeyboardSelectedRow(int index,
boolean stealFocus,
boolean forceUpdate)
Set the row index of the keyboard selected element. |
void |
setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy policy)
Set the HasKeyboardSelectionPolicy.KeyboardSelectionPolicy. |
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 SelectionModel used by this HasData. |
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
static final int PAGE_INCREMENT
HasKeyboardPagingPolicy.KeyboardPagingPolicy is
HasKeyboardPagingPolicy.KeyboardPagingPolicy.INCREASE_RANGE.
| Constructor Detail |
|---|
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 size| Method Detail |
|---|
public HandlerRegistration addCellPreviewHandler(CellPreviewEvent.Handler<T> handler)
HasCellPreviewHandlersCellPreviewEvent handler.
addCellPreviewHandler in interface HasCellPreviewHandlers<T>handler - the handler
public HandlerRegistration addLoadingStateChangeHandler(LoadingStateChangeEvent.Handler handler)
public HandlerRegistration addRangeChangeHandler(RangeChangeEvent.Handler handler)
HasRowsRangeChangeEvent.Handler.
addRangeChangeHandler in interface HasRowshandler - the handler
HandlerRegistration to remove the handlerpublic HandlerRegistration addRowCountChangeHandler(RowCountChangeEvent.Handler handler)
HasRowsRowCountChangeEvent.Handler.
addRowCountChangeHandler in interface HasRowshandler - the handler
HandlerRegistration 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 event
java.lang.UnsupportedOperationExceptionpublic void flush()
public int getCurrentPageSize()
public HasKeyboardPagingPolicy.KeyboardPagingPolicy getKeyboardPagingPolicy()
HasKeyboardPagingPolicyHasKeyboardPagingPolicy.KeyboardPagingPolicy.
getKeyboardPagingPolicy in interface HasKeyboardPagingPolicyHasKeyboardPagingPolicy.setKeyboardPagingPolicy(KeyboardPagingPolicy)public int getKeyboardSelectedRow()
public int getKeyboardSelectedRowInView()
public T getKeyboardSelectedRowValue()
public HasKeyboardSelectionPolicy.KeyboardSelectionPolicy getKeyboardSelectionPolicy()
HasKeyboardSelectionPolicyHasKeyboardSelectionPolicy.KeyboardSelectionPolicy.
getKeyboardSelectionPolicy in interface HasKeyboardSelectionPolicyHasKeyboardSelectionPolicy.setKeyboardSelectionPolicy(KeyboardSelectionPolicy)public ProvidesKey<T> getKeyProvider()
HasKeyProvider
getKeyProvider 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)
HasData
getVisibleItem in interface HasData<T>indexOnPage - the index on the page
public int getVisibleItemCount()
HasData
getVisibleItemCount 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()
HasRows
isRowCountExact in interface HasRowspublic void redraw()
public void setKeyboardPagingPolicy(HasKeyboardPagingPolicy.KeyboardPagingPolicy policy)
HasKeyboardPagingPolicyHasKeyboardPagingPolicy.KeyboardPagingPolicy.
setKeyboardPagingPolicy 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)
HasKeyboardSelectionPolicyHasKeyboardSelectionPolicy.KeyboardSelectionPolicy.
setKeyboardSelectionPolicy in interface HasKeyboardSelectionPolicypolicy - the selection policyHasKeyboardSelectionPolicy.getKeyboardSelectionPolicy()public final void setRowCount(int count)
HasRowsHasRows.setRowCount(int, boolean).
setRowCount in interface HasRowscount - the exact total count
java.lang.UnsupportedOperationExceptionHasRows.getRowCount()
public void setRowCount(int count,
boolean isExact)
HasRows
setRowCount 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 length
java.lang.UnsupportedOperationExceptionHasRows.getVisibleRange()public void setVisibleRange(Range range)
HasRows
setVisibleRange 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 execute
java.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
|
GWT 2.7.0 | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||