T - the data type of each rowpublic abstract class AbstractHasData<T> extends Composite implements HasData<T>, HasKeyProvider<T>, Focusable, HasKeyboardPagingPolicy
| Modifier and Type | Class and Description | 
|---|---|
| static class  | AbstractHasData.DefaultKeyboardSelectionHandler<T>Default implementation of a keyboard navigation handler. | 
| static class  | AbstractHasData.RedrawEventEvent fired when one or more existing rows are re-rendered. | 
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabledHasKeyboardPagingPolicy.KeyboardPagingPolicyHasKeyboardSelectionPolicy.KeyboardSelectionPolicy| Modifier and Type | Field and Description | 
|---|---|
| (package private) boolean | isFocusedA boolean indicating that the widget has focus. | 
DEBUG_ID_PREFIX| Constructor and Description | 
|---|
| AbstractHasData(Element elem,
               int pageSize,
               ProvidesKey<T> keyProvider)Constructs an  AbstractHasDatawith the given page size. | 
| AbstractHasData(Widget widget,
               int pageSize,
               ProvidesKey<T> keyProvider)Constructs an  AbstractHasDatawith the given page size. | 
| Modifier and Type | Method and Description | 
|---|---|
| HandlerRegistration | addCellPreviewHandler(CellPreviewEvent.Handler<T> handler)Adds a  CellPreviewEventhandler. | 
| HandlerRegistration | addLoadingStateChangeHandler(LoadingStateChangeEvent.Handler handler)Add a  LoadingStateChangeEvent.Handlerto be notified of changes in
 the loading state. | 
| HandlerRegistration | addRangeChangeHandler(RangeChangeEvent.Handler handler)Add a  RangeChangeEvent.Handler. | 
| HandlerRegistration | addRedrawHandler(AbstractHasData.RedrawEvent.Handler handler)Adds the given handler as a callback that is notified of events of type  AbstractHasData.RedrawEvent. | 
| HandlerRegistration | addRowCountChangeHandler(RowCountChangeEvent.Handler handler)Add a  RowCountChangeEvent.Handler. | 
| (package private) HandlerRegistration | addValueChangeHandler(ValueChangeHandler<java.util.List<T>> handler)Add a  ValueChangeHandlerthat is called when the display values
 change. | 
| (package private) void | adopt(Widget child)Adopt the specified widget. | 
| protected boolean | cellConsumesEventType(Cell<?> cell,
                     java.lang.String eventType)Check if a cell consumes the specified event type. | 
| protected void | checkRowBounds(int row)Check that the row is within the correct bounds. | 
| protected Element | convertToElements(SafeHtml html)Convert the specified HTML into DOM elements and return the parent of the
 DOM elements. | 
| (package private) static Element | convertToElements(Widget widget,
                 Element tmpElem,
                 SafeHtml html)Convenience method to convert the specified HTML into DOM elements and
 return the parent of the DOM elements. | 
| protected abstract boolean | dependsOnSelection()Check whether or not the cells in the view depend on the selection state. | 
| (package private) void | doAttach(Widget child)Attach a child. | 
| (package private) void | doDetach(Widget child)Detach a child. | 
| char | getAccessKey()Get the access key. | 
| protected abstract Element | getChildContainer()Return the element that holds the rendered cells. | 
| protected Element | getChildElement(int index)Get the element that represents the specified index. | 
| T | getDisplayedItem(int indexOnPage)Deprecated. 
 use  getVisibleItem(int)instead | 
| java.util.List<T> | getDisplayedItems()Deprecated. 
 use  getVisibleItems()instead | 
| HasKeyboardPagingPolicy.KeyboardPagingPolicy | getKeyboardPagingPolicy() | 
| protected abstract Element | getKeyboardSelectedElement()Get the element that has keyboard selection. | 
| int | getKeyboardSelectedRow()Get the index of the row that is currently selected via the keyboard,
 relative to the page start index. | 
| HasKeyboardSelectionPolicy.KeyboardSelectionPolicy | getKeyboardSelectionPolicy() | 
| ProvidesKey<T> | getKeyProvider()Return the key provider. | 
| int | getPageSize()Return the range size. | 
| int | getPageStart()Return the range start. | 
| (package private) HasDataPresenter<T> | getPresenter() | 
| Element | getRowContainer()Return the outer element that contains all of the rendered row values. | 
| int | getRowCount()Get the total count of all rows. | 
| SelectionModel<? super T> | getSelectionModel()Get the  SelectionModelused by thisHasData. | 
| int | getTabIndex()Gets the widget's position in the tab index. | 
| java.lang.Object | getValueKey(T value)Get the key for the specified value. | 
| 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()Return the row values that the widget is currently displaying as an
 immutable list. | 
| Range | getVisibleRange()Get the range of visible rows. | 
| protected abstract boolean | isKeyboardNavigationSuppressed()Check if keyboard navigation is being suppressed, such as when the user is
 editing a cell. | 
| boolean | isRowCountExact()Check if the total row count is exact, or an estimate. | 
| protected boolean | isRowWithinBounds(int row)Checks that the row is within bounds of the view. | 
| protected void | onBlur()Called when the widget is blurred. | 
| void | onBrowserEvent(Event event)Handle browser events. | 
| protected void | onBrowserEvent2(Event event)Called after  onBrowserEvent(Event)completes. | 
| protected void | onFocus()Called when the widget is focused. | 
| protected void | onLoadingStateChanged(LoadingStateChangeEvent.LoadingState state)Called when the loading state changes. | 
| protected void | onUnload()This method is called immediately before a widget will be detached from the
 browser's document. | 
| void | redraw()Redraw the widget using the existing data. | 
| void | redrawRow(int absRowIndex)Redraw a single row using the existing data. | 
| protected abstract void | renderRowValues(SafeHtmlBuilder sb,
               java.util.List<T> values,
               int start,
               SelectionModel<? super T> selectionModel)Render all row values into the specified  SafeHtmlBuilder. | 
| protected void | replaceAllChildren(java.util.List<T> values,
                  SafeHtml html)Replace all children with the specified html. | 
| (package private) static void | replaceAllChildren(Widget widget,
                  Element childContainer,
                  SafeHtml html)Convenience method to replace all children of a Widget. | 
| protected void | replaceChildren(java.util.List<T> values,
               int start,
               SafeHtml html)Convert the specified HTML into DOM elements and replace the existing
 elements starting at the specified index. | 
| (package private) static void | replaceChildren(Widget widget,
               Element childContainer,
               Element newChildren,
               int start,
               SafeHtml html)Convenience method to convert the specified HTML into DOM elements and
 replace the existing elements starting at the specified index. | 
| protected abstract boolean | resetFocusOnCell()Reset focus on the currently focused cell. | 
| void | setAccessKey(char key)Sets the widget's 'access key'. | 
| void | setFocus(boolean focused)Explicitly focus/unfocus this widget. | 
| protected void | setFocusable(Element elem,
            boolean focusable)Make an element focusable or not. | 
| void | setKeyboardPagingPolicy(HasKeyboardPagingPolicy.KeyboardPagingPolicy policy) | 
| protected abstract void | setKeyboardSelected(int index,
                   boolean selected,
                   boolean stealFocus)Update an element to reflect its keyboard selected state. | 
| void | setKeyboardSelectedRow(int row)Set the keyboard selected row. | 
| void | setKeyboardSelectedRow(int row,
                      boolean stealFocus)Set the keyboard selected row and optionally focus on the new row. | 
| void | setKeyboardSelectionHandler(CellPreviewEvent.Handler<T> keyboardSelectionReg)Set the handler that handles keyboard selection/navigation. | 
| void | setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy policy) | 
| void | setPageSize(int pageSize)Set the number of rows per page and refresh the view. | 
| void | setPageStart(int pageStart)Set the starting index of the current visible page. | 
| void | setRowCount(int count)Set the exact total count of all rows. | 
| void | setRowCount(int size,
           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 | setRowData(java.util.List<? extends T> values)
 Set the complete list of values to display on one page. | 
| protected void | setSelected(Element elem,
           boolean selected)Deprecated. 
 this method is never called by AbstractHasData, render the
             selected styles in
              renderRowValues(SafeHtmlBuilder, List, int, SelectionModel) | 
| void | setSelectionModel(SelectionModel<? super T> selectionModel)Set the  SelectionModelused by thisHasData. | 
| void | setSelectionModel(SelectionModel<? super T> selectionModel,
                 CellPreviewEvent.Handler<T> selectionEventManager)Set the  SelectionModelthat defines which items are selected and
 theCellPreviewEvent.Handlerthat
 controls how user selection is handled. | 
| void | setTabIndex(int index)Sets the widget's position in the tab index. | 
| 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. | 
| (package private) void | showOrHide(Element element,
          boolean show)Show or hide an element. | 
claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, onDetach, render, render, resolvePotentialElement, setWidgetaddAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, onLoad, removeFromParent, setLayoutData, sinkEvents, unsinkEventsaddStyleDependentName, 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, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitfireEventpublic AbstractHasData(Element elem, int pageSize, ProvidesKey<T> keyProvider)
AbstractHasData with the given page size.elem - the parent ElementpageSize - the page sizekeyProvider - the key provider, or nullpublic AbstractHasData(Widget widget, int pageSize, ProvidesKey<T> keyProvider)
AbstractHasData with the given page size.widget - the parent WidgetpageSize - the page sizekeyProvider - the key provider, or nullstatic Element convertToElements(Widget widget, Element tmpElem, SafeHtml html)
html - the HTML to converttmpElem - a temporary elementstatic void replaceAllChildren(Widget widget, Element childContainer, SafeHtml html)
widget - the widget who's contents will be replacedchildContainer - the container that holds the contentshtml - the html to setstatic void replaceChildren(Widget widget, Element childContainer, Element newChildren, int start, SafeHtml html)
widget - the widget who's contents will be replacedchildContainer - the container that holds the contentsnewChildren - an element containing the new childrenstart - the start index to replacehtml - the HTML to convertpublic HandlerRegistration addCellPreviewHandler(CellPreviewEvent.Handler<T> handler)
HasCellPreviewHandlersCellPreviewEvent handler.addCellPreviewHandler in interface HasCellPreviewHandlers<T>handler - the handlerpublic HandlerRegistration addLoadingStateChangeHandler(LoadingStateChangeEvent.Handler handler)
LoadingStateChangeEvent.Handler to be notified of changes in
 the loading state.handler - the handlepublic 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 HandlerRegistration addRedrawHandler(AbstractHasData.RedrawEvent.Handler handler)
AbstractHasData.RedrawEvent.public char getAccessKey()
setAccessKey(char)@Deprecated public T getDisplayedItem(int indexOnPage)
getVisibleItem(int) insteadindexOnPage - the index on the page@Deprecated public java.util.List<T> getDisplayedItems()
getVisibleItems() insteadpublic HasKeyboardPagingPolicy.KeyboardPagingPolicy getKeyboardPagingPolicy()
HasKeyboardPagingPolicygetKeyboardPagingPolicy in interface HasKeyboardPagingPolicyHasKeyboardPagingPolicy.setKeyboardPagingPolicy(KeyboardPagingPolicy)public int getKeyboardSelectedRow()
 This is not same as the selected row in the SelectionModel. The
 keyboard selected row refers to the row that the user navigated to via the
 keyboard or mouse.
 
public HasKeyboardSelectionPolicy.KeyboardSelectionPolicy getKeyboardSelectionPolicy()
HasKeyboardSelectionPolicygetKeyboardSelectionPolicy in interface HasKeyboardSelectionPolicyHasKeyboardSelectionPolicy.setKeyboardSelectionPolicy(KeyboardSelectionPolicy)public ProvidesKey<T> getKeyProvider()
HasKeyProvidergetKeyProvider in interface HasKeyProvider<T>ProvidesKey instancepublic final int getPageSize()
getVisibleRange(), 
setPageSize(int)public final int getPageStart()
getVisibleRange(), 
setPageStart(int)public Element getRowContainer()
getChildContainer();Element that contains the rendered row valuespublic int getRowCount()
HasRowsgetRowCount in interface HasRowsHasRows.setRowCount(int)public SelectionModel<? super T> getSelectionModel()
HasDataSelectionModel used by this HasData.getSelectionModel in interface HasData<T>SelectionModelHasData.setSelectionModel(SelectionModel)public int getTabIndex()
FocusablegetTabIndex in interface Focusablepublic java.lang.Object getValueKey(T value)
value - the valuepublic 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()
getVisibleItems in interface HasData<T>public Range getVisibleRange()
HasRowsgetVisibleRange in interface HasRowsHasRows.setVisibleRange(Range), 
HasRows.setVisibleRange(int, int)public boolean isRowCountExact()
HasRowsisRowCountExact in interface HasRowspublic final void onBrowserEvent(Event event)
onBrowserEvent2(Event) if they want to extend browser event
 handling.onBrowserEvent in interface EventListeneronBrowserEvent in class Compositeevent - the event receivedonBrowserEvent2(Event)public void redraw()
public void redrawRow(int absRowIndex)
absRowIndex - the absolute row index to redrawpublic void setAccessKey(char key)
setAccessKey in interface Focusablekey - the widget's access keygetAccessKey()public void setFocus(boolean focused)
FocusableGWTTestCase#delayTestFinish for more information on how to do this.public void setKeyboardPagingPolicy(HasKeyboardPagingPolicy.KeyboardPagingPolicy policy)
HasKeyboardPagingPolicysetKeyboardPagingPolicy in interface HasKeyboardPagingPolicypolicy - the paging policyHasKeyboardPagingPolicy.getKeyboardPagingPolicy()public final void setKeyboardSelectedRow(int row)
If keyboard selection is disabled, this method does nothing.
If the keyboard selected row is outside of the range of the current page (that is, less than 0 or greater than or equal to the page size), the page or range will be adjusted depending on the keyboard paging policy. If the keyboard paging policy is limited to the current range, the row index will be clipped to the current page.
row - the row index relative to the page startpublic void setKeyboardSelectedRow(int row,
                                   boolean stealFocus)
row - the row index relative to the page startstealFocus - true to focus on the new rowsetKeyboardSelectedRow(int)public void setKeyboardSelectionHandler(CellPreviewEvent.Handler<T> keyboardSelectionReg)
public void setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy policy)
HasKeyboardSelectionPolicysetKeyboardSelectionPolicy in interface HasKeyboardSelectionPolicypolicy - the selection policyHasKeyboardSelectionPolicy.getKeyboardSelectionPolicy()public final void setPageSize(int pageSize)
pageSize - the page sizesetVisibleRange(Range), 
getPageSize()public final void setPageStart(int pageStart)
pageStart - the index of the row that should appear at the start of
          the pagesetVisibleRange(Range), 
getPageStart()public final void setRowCount(int count)
HasRowsHasRows.setRowCount(int, boolean).setRowCount in interface HasRowscount - the exact total countHasRows.getRowCount()public void setRowCount(int size,
                        boolean isExact)
HasRowssetRowCount in interface HasRowssize - the total countisExact - true if the count is exact, false if an estimateHasRows.getRowCount()public final void setRowData(java.util.List<? extends T> values)
Set the complete list of values to display on one page.
 Equivalent to calling setRowCount(int) with the length of the list
 of values, setVisibleRange(Range) from 0 to the size of the list
 of values, and setRowData(int, List) with a start of 0 and the
 specified list of values.
 
values - 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)
SelectionModel used by this HasData.
 
 
 By default, selection occurs when the user clicks on a Cell or presses the
 spacebar. If you need finer control over selection, you can specify a
 DefaultSelectionEventManager using
 setSelectionModel(SelectionModel, com.google.gwt.view.client.CellPreviewEvent.Handler). DefaultSelectionEventManager provides some default
 implementations to handle checkbox based selection, as well as a blacklist
 or whitelist of columns to prevent or allow selection.
 
setSelectionModel in interface HasData<T>selectionModel - the SelectionModelsetSelectionModel(SelectionModel,
      com.google.gwt.view.client.CellPreviewEvent.Handler), 
getSelectionModel()public void setSelectionModel(SelectionModel<? super T> selectionModel, CellPreviewEvent.Handler<T> selectionEventManager)
SelectionModel that defines which items are selected and
 the CellPreviewEvent.Handler that
 controls how user selection is handled.selectionModel - the SelectionModel that defines selectionselectionEventManager - the handler that controls user selectionpublic void setTabIndex(int index)
Focusable-1 will cause this widget to
 be removed from the tab order.setTabIndex in interface Focusableindex - the widget's tab indexpublic final void setVisibleRange(int start,
                                  int length)
HasRowsHasRows.setVisibleRange(Range).setVisibleRange in interface HasRowsstart - the start indexlength - the lengthHasRows.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 boolean cellConsumesEventType(Cell<?> cell, java.lang.String eventType)
cell - the celleventType - the event type to checkprotected void checkRowBounds(int row)
row - row index to checkjava.lang.IndexOutOfBoundsExceptionprotected Element convertToElements(SafeHtml html)
html - the HTML to convertprotected abstract boolean dependsOnSelection()
protected abstract Element getChildContainer()
Elementprotected Element getChildElement(int index)
index - the index of the row valueprotected abstract Element getKeyboardSelectedElement()
protected abstract boolean isKeyboardNavigationSuppressed()
protected boolean isRowWithinBounds(int row)
row - row index to checkprotected void onBlur()
protected void onBrowserEvent2(Event event)
onBrowserEvent(Event) completes.event - the event that was firedprotected void onFocus()
protected void onLoadingStateChanged(LoadingStateChangeEvent.LoadingState state)
LoadingStateChangeEvent.state - the new loading stateprotected void onUnload()
Widgetprotected abstract void renderRowValues(SafeHtmlBuilder sb, java.util.List<T> values, int start, SelectionModel<? super T> selectionModel) throws java.lang.UnsupportedOperationException
SafeHtmlBuilder.
 
 
 Subclasses can optionally throw an UnsupportedOperationException if
 they prefer to render the rows in
 replaceAllChildren(List, SafeHtml) and
 replaceChildren(List, int, SafeHtml). In this case, the
 SafeHtml argument will be null. Though a bit hacky, this is
 designed to supported legacy widgets that use SafeHtmlBuilder, and
 newer widgets that use other builders, such as the ElementBuilder API.
 
sb - the SafeHtmlBuilder to render intovalues - the row valuesstart - the absolute start index of the valuesselectionModel - the SelectionModeljava.lang.UnsupportedOperationException - if the values will be rendered in
           replaceAllChildren(List, SafeHtml) and
           replaceChildren(List, int, SafeHtml)protected void replaceAllChildren(java.util.List<T> values, SafeHtml html)
values - the values of the new childrenhtml - the html to render, or null if
          renderRowValues(SafeHtmlBuilder, List, int, SelectionModel)
          throws an UnsupportedOperationExceptionprotected void replaceChildren(java.util.List<T> values, int start, SafeHtml html)
values - the values of the new childrenstart - the start index to be replaced, relative to the page starthtml - the html to render, or null if
          renderRowValues(SafeHtmlBuilder, List, int, SelectionModel)
          throws an UnsupportedOperationExceptionprotected abstract boolean resetFocusOnCell()
protected void setFocusable(Element elem, boolean focusable)
elem - the elementfocusable - true to make focusable, false to make unfocusableprotected abstract void setKeyboardSelected(int index,
                                            boolean selected,
                                            boolean stealFocus)
index - the index of the elementselected - true if selected, false if notstealFocus - true if the row should steal focus, false if not@Deprecated protected void setSelected(Element elem, boolean selected)
renderRowValues(SafeHtmlBuilder, List, int, SelectionModel)elem - the element to updateselected - true if selected, false if notfinal HandlerRegistration addValueChangeHandler(ValueChangeHandler<java.util.List<T>> handler)
ValueChangeHandler that is called when the display values
 change. Used by CellBrowser to detect when the displayed data
 changes.handler - the handlerHandlerRegistration to remove the handlervoid adopt(Widget child)
child - the child to adoptvoid doAttach(Widget child)
child - the child to attachvoid doDetach(Widget child)
child - the child to detachHasDataPresenter<T> getPresenter()
void showOrHide(Element element, boolean show)
element - the elementshow - true to show, false to hide