Class AbstractHasData<T>
- Type Parameters:
T- the data type of each row
- All Implemented Interfaces:
HasAttachHandlers,HasHandlers,HasKeyboardPagingPolicy,HasKeyboardSelectionPolicy,EventListener,Focusable,HasVisibility,IsRenderable,IsWidget,HasCellPreviewHandlers<T>,HasData<T>,HasKeyProvider<T>,HasRows
- Direct Known Subclasses:
AbstractCellTable,CellList
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDefault implementation of a keyboard navigation handler.static classEvent fired when one or more existing rows are re-rendered.Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabledNested classes/interfaces inherited from interface com.google.gwt.user.cellview.client.HasKeyboardPagingPolicy
HasKeyboardPagingPolicy.KeyboardPagingPolicyNested classes/interfaces inherited from interface com.google.gwt.user.cellview.client.HasKeyboardSelectionPolicy
HasKeyboardSelectionPolicy.KeyboardSelectionPolicy -
Field Summary
FieldsModifier and TypeFieldDescription(package private) booleanA boolean indicating that the widget has focus.Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX -
Constructor Summary
ConstructorsConstructorDescriptionAbstractHasData(Element elem, int pageSize, ProvidesKey<T> keyProvider) Constructs anAbstractHasDatawith the given page size.AbstractHasData(Widget widget, int pageSize, ProvidesKey<T> keyProvider) Constructs anAbstractHasDatawith the given page size. -
Method Summary
Modifier and TypeMethodDescriptionaddCellPreviewHandler(CellPreviewEvent.Handler<T> handler) Adds aCellPreviewEventhandler.Add aLoadingStateChangeEvent.Handlerto be notified of changes in the loading state.Add aRangeChangeEvent.Handler.Adds the given handler as a callback that is notified of events of typeAbstractHasData.RedrawEvent.Add aRowCountChangeEvent.Handler.(package private) final HandlerRegistrationaddValueChangeHandler(ValueChangeHandler<List<T>> handler) Add aValueChangeHandlerthat is called when the display values change.(package private) voidAdopt the specified widget.protected booleancellConsumesEventType(Cell<?> cell, String eventType) Check if a cell consumes the specified event type.protected voidcheckRowBounds(int row) Check that the row is within the correct bounds.protected ElementconvertToElements(SafeHtml html) Convert the specified HTML into DOM elements and return the parent of the DOM elements.(package private) static ElementconvertToElements(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 booleanCheck whether or not the cells in the view depend on the selection state.(package private) voidAttach a child.(package private) voidDetach a child.charGet the access key.protected abstract ElementReturn the element that holds the rendered cells.protected ElementgetChildElement(int index) Get the element that represents the specified index.getDisplayedItem(int indexOnPage) Deprecated.Deprecated.usegetVisibleItems()insteadprotected abstract ElementGet the element that has keyboard selection.intGet the index of the row that is currently selected via the keyboard, relative to the page start index.Return the key provider.final intReturn the range size.final intReturn the range start.(package private) HasDataPresenter<T>Return the outer element that contains all of the rendered row values.intGet the total count of all rows.SelectionModel<? super T>Get theSelectionModelused by thisHasData.intGets the widget's position in the tab index.getValueKey(T value) Get the key for the specified value.getVisibleItem(int indexOnPage) Get the row value at the specified visible index.intGet the number of visible items being displayed.Return the row values that the widget is currently displaying as an immutable list.Get the range of visible rows.protected abstract booleanCheck if keyboard navigation is being suppressed, such as when the user is editing a cell.booleanCheck if the total row count is exact, or an estimate.protected booleanisRowWithinBounds(int row) Checks that the row is within bounds of the view.protected voidonBlur()Called when the widget is blurred.final voidonBrowserEvent(Event event) Handle browser events.protected voidonBrowserEvent2(Event event) Called afteronBrowserEvent(Event)completes.protected voidonFocus()Called when the widget is focused.protected voidCalled when the loading state changes.protected voidonUnload()This method is called immediately before a widget will be detached from the browser's document.voidredraw()Redraw the widget using the existing data.voidredrawRow(int absRowIndex) Redraw a single row using the existing data.protected abstract voidrenderRowValues(SafeHtmlBuilder sb, List<T> values, int start, SelectionModel<? super T> selectionModel) Render all row values into the specifiedSafeHtmlBuilder.(package private) static voidreplaceAllChildren(Widget widget, Element childContainer, SafeHtml html) Convenience method to replace all children of a Widget.protected voidreplaceAllChildren(List<T> values, SafeHtml html) Replace all children with the specified html.(package private) static voidreplaceChildren(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 voidreplaceChildren(List<T> values, int start, SafeHtml html) Convert the specified HTML into DOM elements and replace the existing elements starting at the specified index.protected abstract booleanReset focus on the currently focused cell.voidsetAccessKey(char key) Sets the widget's 'access key'.voidsetFocus(boolean focused) Explicitly focus/unfocus this widget.protected voidsetFocusable(Element elem, boolean focusable) Make an element focusable or not.voidprotected abstract voidsetKeyboardSelected(int index, boolean selected, boolean stealFocus) Update an element to reflect its keyboard selected state.final voidsetKeyboardSelectedRow(int row) Set the keyboard selected row.voidsetKeyboardSelectedRow(int row, boolean stealFocus) Set the keyboard selected row and optionally focus on the new row.voidsetKeyboardSelectionHandler(CellPreviewEvent.Handler<T> keyboardSelectionReg) Set the handler that handles keyboard selection/navigation.voidfinal voidsetPageSize(int pageSize) Set the number of rows per page and refresh the view.final voidsetPageStart(int pageStart) Set the starting index of the current visible page.final voidsetRowCount(int count) Set the exact total count of all rows.voidsetRowCount(int size, boolean isExact) Set the total count of all rows, specifying whether the count is exact or an estimate.voidsetRowData(int start, List<? extends T> values) Set a values associated with the rows in the visible range.final voidsetRowData(List<? extends T> values) Set the complete list of values to display on one page.protected voidsetSelected(Element elem, boolean selected) Deprecated.this method is never called by AbstractHasData, render the selected styles inrenderRowValues(SafeHtmlBuilder, List, int, SelectionModel)voidsetSelectionModel(SelectionModel<? super T> selectionModel) Set theSelectionModelused by thisHasData.voidsetSelectionModel(SelectionModel<? super T> selectionModel, CellPreviewEvent.Handler<T> selectionEventManager) Set theSelectionModelthat defines which items are selected and theCellPreviewEvent.Handlerthat controls how user selection is handled.voidsetTabIndex(int index) Sets the widget's position in the tab index.final voidsetVisibleRange(int start, int length) Set the visible range or rows.voidsetVisibleRange(Range range) Set the visible range or rows.voidsetVisibleRangeAndClearData(Range range, boolean forceRangeChangeEvent) Set the visible range and clear the current visible data.(package private) voidshowOrHide(Element element, boolean show) Show or hide an element.Methods inherited from class com.google.gwt.user.client.ui.Composite
claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, onDetach, render, render, resolvePotentialElement, setWidgetMethods 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, removeFromParent, setLayoutData, sinkEvents, unsinkEventsMethods 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, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
-
Field Details
-
isFocused
boolean isFocusedA boolean indicating that the widget has focus.
-
-
Constructor Details
-
AbstractHasData
Constructs anAbstractHasDatawith the given page size.- Parameters:
elem- the parentElementpageSize- the page sizekeyProvider- the key provider, or null
-
AbstractHasData
Constructs anAbstractHasDatawith the given page size.- Parameters:
widget- the parentWidgetpageSize- the page sizekeyProvider- the key provider, or null
-
-
Method Details
-
addCellPreviewHandler
Description copied from interface:HasCellPreviewHandlersAdds aCellPreviewEventhandler.- Specified by:
addCellPreviewHandlerin interfaceHasCellPreviewHandlers<T>- Parameters:
handler- the handler- Returns:
- the registration for the event
-
addLoadingStateChangeHandler
Add aLoadingStateChangeEvent.Handlerto be notified of changes in the loading state.- Parameters:
handler- the handle- Returns:
- the registration for the handler
-
addRangeChangeHandler
Description copied from interface:HasRowsAdd aRangeChangeEvent.Handler.- Specified by:
addRangeChangeHandlerin interfaceHasRows- Parameters:
handler- the handler- Returns:
- a
HandlerRegistrationto remove the handler
-
addRowCountChangeHandler
Description copied from interface:HasRowsAdd aRowCountChangeEvent.Handler.- Specified by:
addRowCountChangeHandlerin interfaceHasRows- Parameters:
handler- the handler- Returns:
- a
HandlerRegistrationto remove the handler
-
addRedrawHandler
Adds the given handler as a callback that is notified of events of typeAbstractHasData.RedrawEvent. -
getAccessKey
public char getAccessKey()Get the access key.- Returns:
- the access key, or -1 if not set
- See Also:
-
getDisplayedItem
Deprecated.usegetVisibleItem(int)insteadGet the row value at the specified visible index. Index 0 corresponds to the first item on the page.- Parameters:
indexOnPage- the index on the page- Returns:
- the row value
-
getDisplayedItems
Deprecated.usegetVisibleItems()insteadReturn the row values that the widget is currently displaying as an immutable list.- Returns:
- a List of displayed items
-
getKeyboardPagingPolicy
Description copied from interface:HasKeyboardPagingPolicy- Specified by:
getKeyboardPagingPolicyin interfaceHasKeyboardPagingPolicy- Returns:
- the paging policy
- See Also:
-
getKeyboardSelectedRow
public int getKeyboardSelectedRow()Get the index of the row that is currently selected via the keyboard, relative to the page start index.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.- Returns:
- the currently selected row, or -1 if none selected
-
getKeyboardSelectionPolicy
Description copied from interface:HasKeyboardSelectionPolicy- Specified by:
getKeyboardSelectionPolicyin interfaceHasKeyboardSelectionPolicy- Returns:
- the selection policy
- See Also:
-
getKeyProvider
Description copied from interface:HasKeyProviderReturn the key provider.- Specified by:
getKeyProviderin interfaceHasKeyProvider<T>- Returns:
- the
ProvidesKeyinstance
-
getPageSize
public final int getPageSize()Return the range size.- Returns:
- the size of the range as an int
- See Also:
-
getPageStart
public final int getPageStart()Return the range start.- Returns:
- the start of the range as an int
- See Also:
-
getRowContainer
Return the outer element that contains all of the rendered row values. This method delegates togetChildContainer();- Returns:
- the
Elementthat contains the rendered row values
-
getRowCount
public int getRowCount()Description copied from interface:HasRowsGet the total count of all rows.- Specified by:
getRowCountin interfaceHasRows- Returns:
- the total row count
- See Also:
-
getSelectionModel
Description copied from interface:HasDataGet theSelectionModelused by thisHasData.- Specified by:
getSelectionModelin interfaceHasData<T>- Returns:
- the
SelectionModel - See Also:
-
getTabIndex
public int getTabIndex()Description copied from interface:FocusableGets the widget's position in the tab index.- Specified by:
getTabIndexin interfaceFocusable- Returns:
- the widget's tab index
-
getValueKey
Get the key for the specified value. If a keyProvider is not specified or the value is null, the value is returned. If the key provider is specified, it is used to get the key from the value.- Parameters:
value- the value- Returns:
- the key
-
getVisibleItem
Description copied from interface:HasDataGet the row value at the specified visible index. Index 0 corresponds to the first item on the page.- Specified by:
getVisibleItemin interfaceHasData<T>- Parameters:
indexOnPage- the index on the page- Returns:
- the row value
-
getVisibleItemCount
public int getVisibleItemCount()Description copied from interface:HasDataGet the number of visible items being displayed. Note that this value might be less than the page size if there is not enough data to fill the page.- Specified by:
getVisibleItemCountin interfaceHasData<T>- Returns:
- the number of visible items on the page
-
getVisibleItems
Return the row values that the widget is currently displaying as an immutable list.- Specified by:
getVisibleItemsin interfaceHasData<T>- Returns:
- a List of displayed items
-
getVisibleRange
Description copied from interface:HasRowsGet the range of visible rows.- Specified by:
getVisibleRangein interfaceHasRows- Returns:
- the visible range
- See Also:
-
isRowCountExact
public boolean isRowCountExact()Description copied from interface:HasRowsCheck if the total row count is exact, or an estimate.- Specified by:
isRowCountExactin interfaceHasRows- Returns:
- true if exact, false if an estimate
-
onBrowserEvent
Handle browser events. Subclasses should overrideonBrowserEvent2(Event)if they want to extend browser event handling.- Specified by:
onBrowserEventin interfaceEventListener- Overrides:
onBrowserEventin classComposite- Parameters:
event- the event received- See Also:
-
redraw
public void redraw()Redraw the widget using the existing data. -
redrawRow
public void redrawRow(int absRowIndex) Redraw a single row using the existing data.- Parameters:
absRowIndex- the absolute row index to redraw
-
setAccessKey
public void setAccessKey(char key) Sets the widget's 'access key'. This key is used (in conjunction with a browser-specific modifier key) to automatically focus the widget.- Specified by:
setAccessKeyin interfaceFocusable- Parameters:
key- the widget's access key- See Also:
-
setFocus
public void setFocus(boolean focused) Description copied from interface:FocusableExplicitly focus/unfocus this widget. Only one widget can have focus at a time, and the widget that does will receive all keyboard events. NOTE: Most browsers fire FocusEvents asynchronously. Especially within GWT tests, you'll need to make your test asynchronous to properly do verifications. SeeGWTTestCase#delayTestFinishfor more information on how to do this. -
setKeyboardPagingPolicy
Description copied from interface:HasKeyboardPagingPolicy- Specified by:
setKeyboardPagingPolicyin interfaceHasKeyboardPagingPolicy- Parameters:
policy- the paging policy- See Also:
-
setKeyboardSelectedRow
public final void setKeyboardSelectedRow(int row) Set the keyboard selected row. The row index is the index relative to the current page start index.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.
- Parameters:
row- the row index relative to the page start
-
setKeyboardSelectedRow
public void setKeyboardSelectedRow(int row, boolean stealFocus) Set the keyboard selected row and optionally focus on the new row.- Parameters:
row- the row index relative to the page startstealFocus- true to focus on the new row- See Also:
-
setKeyboardSelectionHandler
Set the handler that handles keyboard selection/navigation. -
setKeyboardSelectionPolicy
Description copied from interface:HasKeyboardSelectionPolicy- Specified by:
setKeyboardSelectionPolicyin interfaceHasKeyboardSelectionPolicy- Parameters:
policy- the selection policy- See Also:
-
setPageSize
public final void setPageSize(int pageSize) Set the number of rows per page and refresh the view.- Parameters:
pageSize- the page size- See Also:
-
setPageStart
public final void setPageStart(int pageStart) Set the starting index of the current visible page. The actual page start will be clamped in the range [0, getSize() - 1].- Parameters:
pageStart- the index of the row that should appear at the start of the page- See Also:
-
setRowCount
public final void setRowCount(int count) Description copied from interface:HasRowsSet the exact total count of all rows. This method defers toHasRows.setRowCount(int, boolean).- Specified by:
setRowCountin interfaceHasRows- Parameters:
count- the exact total count- See Also:
-
setRowCount
public void setRowCount(int size, boolean isExact) Description copied from interface:HasRowsSet the total count of all rows, specifying whether the count is exact or an estimate.- Specified by:
setRowCountin interfaceHasRows- Parameters:
size- the total countisExact- true if the count is exact, false if an estimate- See Also:
-
setRowData
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, andsetRowData(int, List)with a start of 0 and the specified list of values.- Parameters:
values-
-
setRowData
Description copied from interface: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 useHasRows.setRowCount(int)to remove rows when the total number of rows decreases.- Specified by:
setRowDatain interfaceHasData<T>- Parameters:
start- the start index of the datavalues- the values within the range
-
setSelectionModel
Set theSelectionModelused by thisHasData.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
DefaultSelectionEventManagerusingsetSelectionModel(SelectionModel, com.google.gwt.view.client.CellPreviewEvent.Handler).DefaultSelectionEventManagerprovides some default implementations to handle checkbox based selection, as well as a blacklist or whitelist of columns to prevent or allow selection.- Specified by:
setSelectionModelin interfaceHasData<T>- Parameters:
selectionModel- theSelectionModel- See Also:
-
setSelectionModel
public void setSelectionModel(SelectionModel<? super T> selectionModel, CellPreviewEvent.Handler<T> selectionEventManager) Set theSelectionModelthat defines which items are selected and theCellPreviewEvent.Handlerthat controls how user selection is handled.- Parameters:
selectionModel- theSelectionModelthat defines selectionselectionEventManager- the handler that controls user selection
-
setTabIndex
public void setTabIndex(int index) Description copied from interface:FocusableSets the widget's position in the tab index. If more than one widget has the same tab index, each such widget will receive focus in an arbitrary order. Setting the tab index to-1will cause this widget to be removed from the tab order.- Specified by:
setTabIndexin interfaceFocusable- Parameters:
index- the widget's tab index
-
setVisibleRange
public final void setVisibleRange(int start, int length) Description copied from interface:HasRowsSet the visible range or rows. This method defers toHasRows.setVisibleRange(Range).- Specified by:
setVisibleRangein interfaceHasRows- Parameters:
start- the start indexlength- the length- See Also:
-
setVisibleRange
Description copied from interface:HasRowsSet the visible range or rows.- Specified by:
setVisibleRangein interfaceHasRows- Parameters:
range- the visible range- See Also:
-
setVisibleRangeAndClearData
Description copied from interface:HasDataSet the visible range and clear the current visible data.
If the second argument
forceRangeChangeEventis true, aRangeChangeEventwill be fired even if the range does not change. If false, aRangeChangeEventwill only be fired if the range changes.- Specified by:
setVisibleRangeAndClearDatain interfaceHasData<T>- Parameters:
range- the newRangeforceRangeChangeEvent- true to fire aRangeChangeEventeven if theRangedoesn't change
-
cellConsumesEventType
Check if a cell consumes the specified event type.- Parameters:
cell- the celleventType- the event type to check- Returns:
- true if consumed, false if not
-
checkRowBounds
protected void checkRowBounds(int row) Check that the row is within the correct bounds.- Parameters:
row- row index to check- Throws:
IndexOutOfBoundsException
-
dependsOnSelection
protected abstract boolean dependsOnSelection()Check whether or not the cells in the view depend on the selection state.- Returns:
- true if cells depend on selection, false if not
-
getChildContainer
Return the element that holds the rendered cells.- Returns:
- the container
Element
-
getChildElement
Get the element that represents the specified index.- Parameters:
index- the index of the row value- Returns:
- the child element, or null if it does not exist
-
getKeyboardSelectedElement
Get the element that has keyboard selection.- Returns:
- the keyboard selected element
-
isRowWithinBounds
protected boolean isRowWithinBounds(int row) Checks that the row is within bounds of the view.- Parameters:
row- row index to check- Returns:
- true if within bounds, false if not
-
onBlur
protected void onBlur()Called when the widget is blurred. -
onBrowserEvent2
Called afteronBrowserEvent(Event)completes.- Parameters:
event- the event that was fired
-
onFocus
protected void onFocus()Called when the widget is focused. -
onLoadingStateChanged
Called when the loading state changes. By default, this implementation fires aLoadingStateChangeEvent.- Parameters:
state- the new loading state
-
onUnload
protected void onUnload()Description copied from class:WidgetThis method is called immediately before a widget will be detached from the browser's document. -
resetFocusOnCell
protected abstract boolean resetFocusOnCell()Reset focus on the currently focused cell.- Returns:
- true if focus is taken, false if not
-
setFocusable
Make an element focusable or not.- Parameters:
elem- the elementfocusable- true to make focusable, false to make unfocusable
-
setKeyboardSelected
protected abstract void setKeyboardSelected(int index, boolean selected, boolean stealFocus) Update an element to reflect its keyboard selected state.- Parameters:
index- the index of the elementselected- true if selected, false if notstealFocus- true if the row should steal focus, false if not
-
setSelected
Deprecated.this method is never called by AbstractHasData, render the selected styles inrenderRowValues(SafeHtmlBuilder, List, int, SelectionModel)Update an element to reflect its selected state.- Parameters:
elem- the element to updateselected- true if selected, false if not
-
adopt
Adopt the specified widget.- Parameters:
child- the child to adopt
-
doAttach
Attach a child.- Parameters:
child- the child to attach
-
doDetach
Detach a child.- Parameters:
child- the child to detach
-
getPresenter
HasDataPresenter<T> getPresenter() -
showOrHide
Show or hide an element.- Parameters:
element- the elementshow- true to show, false to hide
getVisibleItem(int)instead