public abstract class

AbstractHasData

extends Widget
implements HasKeyboardPagingPolicy Focusable HasData<T> HasKeyProvider<T>
java.lang.Object
   ↳ com.google.gwt.user.client.ui.UIObject
     ↳ com.google.gwt.user.client.ui.Widget
       ↳ com.google.gwt.user.cellview.client.AbstractHasData<T>
Known Direct Subclasses

Class Overview

An abstract Widget that implements HasData.

Summary

[Expand]
Inherited Constants
From class com.google.gwt.user.client.ui.UIObject
Public Constructors
AbstractHasData(Element elem, int pageSize, ProvidesKey<T> keyProvider)
Constructs an AbstractHasData with the given page size.
Public Methods
HandlerRegistration addCellPreviewHandler(Handler<T> handler)
Adds a CellPreviewEvent handler.
HandlerRegistration addRangeChangeHandler(RangeChangeEvent.Handler handler)
HandlerRegistration addRowCountChangeHandler(RowCountChangeEvent.Handler handler)
char getAccessKey()
Get the access key.
T getDisplayedItem(int indexOnPage)
This method is deprecated. use getVisibleItem(int) instead
List<T> getDisplayedItems()
This method is deprecated. use getVisibleItems() instead
ProvidesKey<T> getKeyProvider()
Return the key provider.
HasKeyboardPagingPolicy.KeyboardPagingPolicy getKeyboardPagingPolicy()
HasKeyboardSelectionPolicy.KeyboardSelectionPolicy getKeyboardSelectionPolicy()
final int getPageSize()
Return the range size.
final int getPageStart()
Return the range start.
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 SelectionModel used by this HasData.
int getTabIndex()
Gets the widget's position in the tab index.
T getVisibleItem(int indexOnPage)
Get the row value at the specified visible index.
int getVisibleItemCount()
Get the number of visible items being displayed.
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.
boolean isRowCountExact()
Check if the total row count is exact, or an estimate.
final void onBrowserEvent(Event event)
Handle browser events.
void redraw()
Redraw the widget using the existing data.
void setAccessKey(char key)
Sets the widget's 'access key'.
void setFocus(boolean focused)
Explicitly focus/unfocus this widget.
void setKeyboardPagingPolicy(HasKeyboardPagingPolicy.KeyboardPagingPolicy policy)
void setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy policy)
final void setPageSize(int pageSize)
Set the number of rows per page and refresh the view.
final void setPageStart(int pageStart)
Set the starting index of the current visible page.
final 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.
final void setRowData(List<? extends T> values)

Set the complete list of values to display on one page.

void setRowData(int start, List<? extends T> values)

Set a values associated with the rows in the visible range.

void setSelectionModel(SelectionModel<? super T> selectionModel, Handler<T> selectionEventManager)
Set the SelectionModel that defines which items are selected and the CellPreviewEvent.Handler that controls how user selection is handled.
void setSelectionModel(SelectionModel<? super T> selectionModel)
Set the SelectionModel used by this HasData.
void setTabIndex(int index)
Sets the widget's position in the tab index.
void setVisibleRange(Range range)
Set the visible range or rows.
final void setVisibleRange(int start, int length)
Set the visible range or rows.
void setVisibleRangeAndClearData(Range range, boolean forceRangeChangeEvent)

Set the visible range and clear the current visible data.

Protected Methods
boolean cellConsumesEventType(Cell<?> cell, String eventType)
Check if a cell consumes the specified event type.
void checkRowBounds(int row)
Check that the row is within the correct bounds.
Element convertToElements(SafeHtml html)
Convert the specified HTML into DOM elements and return the parent of the DOM elements.
abstract boolean dependsOnSelection()
Check whether or not the cells in the view depend on the selection state.
abstract Element getChildContainer()
Return the element that holds the rendered cells.
abstract Element getKeyboardSelectedElement()
Get the element that has keyboard selection.
int getKeyboardSelectedRow()
Get the row index of the keyboard selected row.
Object getValueKey(T value)
Get the key for the specified value.
abstract boolean isKeyboardNavigationSuppressed()
Check if keyboard navigation is being suppressed, such as when the user is editing a cell.
boolean isRowWithinBounds(int row)
Checks that the row is within bounds of the view.
void onBlur()
Called when the widget is blurred.
void onBrowserEvent2(Event event)
Called after onBrowserEvent(Event) completes.
void onFocus()
Called when the widget is focused.
void onUnload()
This method is called immediately before a widget will be detached from the browser's document.
void onUpdateSelection()
This method is deprecated. this method is never called by AbstractHasData, render the selected styles in renderRowValues(SafeHtmlBuilder, List, int, SelectionModel)
abstract void renderRowValues(SafeHtmlBuilder sb, List<T> values, int start, SelectionModel<? super T> selectionModel)
Render all row values into the specified SafeHtmlBuilder.
void replaceAllChildren(List<T> values, SafeHtml html)
Replace all children with the specified html.
void replaceChildren(List<T> values, int start, SafeHtml html)
Convert the specified HTML into DOM elements and replace the existing elements starting at the specified index.
abstract boolean resetFocusOnCell()
Reset focus on the currently focused cell.
void setFocusable(Element elem, boolean focusable)
Make an element focusable or not.
abstract void setKeyboardSelected(int index, boolean selected, boolean stealFocus)
Update an element to reflect its keyboard selected state.
void setSelected(Element elem, boolean selected)
This method is deprecated. this method is never called by AbstractHasData, render the selected styles in renderRowValues(SafeHtmlBuilder, List, int, SelectionModel)
[Expand]
Inherited Methods
From class com.google.gwt.user.client.ui.Widget
From class com.google.gwt.user.client.ui.UIObject
From class java.lang.Object
From interface com.google.gwt.event.logical.shared.HasAttachHandlers
From interface com.google.gwt.event.shared.HasHandlers
From interface com.google.gwt.user.cellview.client.HasKeyboardPagingPolicy
From interface com.google.gwt.user.cellview.client.HasKeyboardSelectionPolicy
From interface com.google.gwt.user.client.EventListener
From interface com.google.gwt.user.client.ui.Focusable
From interface com.google.gwt.user.client.ui.IsWidget
From interface com.google.gwt.view.client.HasCellPreviewHandlers
From interface com.google.gwt.view.client.HasData
From interface com.google.gwt.view.client.HasKeyProvider
From interface com.google.gwt.view.client.HasRows

Public Constructors

public AbstractHasData (Element elem, int pageSize, ProvidesKey<T> keyProvider)

Constructs an AbstractHasData with the given page size.

Parameters
elem the parent Element
pageSize the page size
keyProvider the key provider, or null

Public Methods

public HandlerRegistration addCellPreviewHandler (Handler<T> handler)

Adds a CellPreviewEvent handler.

Parameters
handler the handler
Returns
  • the registration for the event

public HandlerRegistration addRangeChangeHandler (RangeChangeEvent.Handler handler)

Parameters
handler the handler
Returns

public HandlerRegistration addRowCountChangeHandler (RowCountChangeEvent.Handler handler)

Parameters
handler the handler
Returns

public char getAccessKey ()

Get the access key.

Returns
  • the access key, or -1 if not set

public T getDisplayedItem (int indexOnPage)

This method is deprecated.
use getVisibleItem(int) instead

Get 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

public List<T> getDisplayedItems ()

This method is deprecated.
use getVisibleItems() instead

Return the row values that the widget is currently displaying as an immutable list.

Returns
  • a List of displayed items

public ProvidesKey<T> getKeyProvider ()

Return the key provider.

Returns

public HasKeyboardPagingPolicy.KeyboardPagingPolicy getKeyboardPagingPolicy ()

Returns
  • the paging policy

public HasKeyboardSelectionPolicy.KeyboardSelectionPolicy getKeyboardSelectionPolicy ()

Returns
  • the selection policy

public final int getPageSize ()

Return the range size.

Returns
  • the size of the range as an int

public final int getPageStart ()

Return the range start.

Returns
  • the start of the range as an int

public Element getRowContainer ()

Return the outer element that contains all of the rendered row values. This method delegates to getChildContainer();

Returns
  • the Element that contains the rendered row values

public int getRowCount ()

Get the total count of all rows.

Returns
  • the total row count

public SelectionModel<? super T> getSelectionModel ()

Get the SelectionModel used by this HasData.

Returns

public int getTabIndex ()

Gets the widget's position in the tab index.

Returns
  • the widget's tab index

public T getVisibleItem (int indexOnPage)

Get 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

public int getVisibleItemCount ()

Get 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.

Returns
  • the number of visible items on the page

public List<T> getVisibleItems ()

Return the row values that the widget is currently displaying as an immutable list.

Returns
  • a List of displayed items

public Range getVisibleRange ()

Get the range of visible rows.

Returns
  • the visible range

public boolean isRowCountExact ()

Check if the total row count is exact, or an estimate.

Returns
  • true if exact, false if an estimate

public final void onBrowserEvent (Event event)

Handle browser events. Subclasses should override onBrowserEvent2(Event) if they want to extend browser event handling.

Parameters
event the event received

public void redraw ()

Redraw the widget using the existing data.

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.

Parameters
key the widget's access key
See Also

public void setFocus (boolean focused)

Explicitly focus/unfocus this widget. Only one widget can have focus at a time, and the widget that does will receive all keyboard events.

Parameters
focused whether this widget should take focus or release it

public void setKeyboardPagingPolicy (HasKeyboardPagingPolicy.KeyboardPagingPolicy policy)

Parameters
policy the paging policy

public void setKeyboardSelectionPolicy (HasKeyboardSelectionPolicy.KeyboardSelectionPolicy policy)

Parameters
policy the selection policy

public final void setPageSize (int pageSize)

Set the number of rows per page and refresh the view.

Parameters
pageSize the page size

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

public final void setRowCount (int count)

Set the exact total count of all rows. This method defers to setRowCount(int, boolean).

Parameters
count the exact total count

public void setRowCount (int size, boolean isExact)

Set the total count of all rows, specifying whether the count is exact or an estimate.

Parameters
size the total count
isExact true if the count is exact, false if an estimate

public final void setRowData (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.

public void setRowData (int start, List<? extends T> values)

Set 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 the specified values. You must call setRowCount(int) to set the total number of rows in the display. You should also use setRowCount(int) to remove rows when the total number of rows decreases.

Parameters
start the start index of the data
values the values within the range

public void setSelectionModel (SelectionModel<? super T> selectionModel, Handler<T> selectionEventManager)

Set the SelectionModel that defines which items are selected and the CellPreviewEvent.Handler that controls how user selection is handled.

Parameters
selectionModel the SelectionModel that defines selection
selectionEventManager the handler that controls user selection

public void setSelectionModel (SelectionModel<? super T> selectionModel)

Set the SelectionModel used by this HasData.

Parameters
selectionModel the SelectionModel

public void setTabIndex (int index)

Sets 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 -1 will cause this widget to be removed from the tab order.

Parameters
index the widget's tab index

public void setVisibleRange (Range range)

Set the visible range or rows.

Parameters
range the visible range

public final void setVisibleRange (int start, int length)

Set the visible range or rows. This method defers to setVisibleRange(Range).

Parameters
start the start index
length the length

public void setVisibleRangeAndClearData (Range range, boolean forceRangeChangeEvent)

Set 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.

Parameters
range the new Range
forceRangeChangeEvent true to fire a RangeChangeEvent even if the Range doesn't change

Protected Methods

protected boolean cellConsumesEventType (Cell<?> cell, String eventType)

Check if a cell consumes the specified event type.

Parameters
cell the cell
eventType the event type to check
Returns
  • true if consumed, false if not

protected void checkRowBounds (int row)

Check that the row is within the correct bounds.

Parameters
row row index to check

protected Element convertToElements (SafeHtml html)

Convert the specified HTML into DOM elements and return the parent of the DOM elements.

Parameters
html the HTML to convert
Returns
  • the parent element

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

protected abstract Element getChildContainer ()

Return the element that holds the rendered cells.

Returns

protected abstract Element getKeyboardSelectedElement ()

Get the element that has keyboard selection.

Returns
  • the keyboard selected element

protected int getKeyboardSelectedRow ()

Get the row index of the keyboard selected row.

Returns
  • the row index

protected Object getValueKey (T value)

Get the key for the specified value.

Parameters
value the value
Returns
  • the key

protected abstract boolean isKeyboardNavigationSuppressed ()

Check if keyboard navigation is being suppressed, such as when the user is editing a cell.

Returns
  • true if suppressed, false if not

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

protected void onBlur ()

Called when the widget is blurred.

protected void onBrowserEvent2 (Event event)

Called after onBrowserEvent(Event) completes.

Parameters
event the event that was fired

protected void onFocus ()

Called when the widget is focused.

protected void onUnload ()

This method is called immediately before a widget will be detached from the browser's document.

protected void onUpdateSelection ()

This method is deprecated.
this method is never called by AbstractHasData, render the selected styles in renderRowValues(SafeHtmlBuilder, List, int, SelectionModel)

Called when selection changes.

protected abstract void renderRowValues (SafeHtmlBuilder sb, List<T> values, int start, SelectionModel<? super T> selectionModel)

Render all row values into the specified SafeHtmlBuilder.

Parameters
sb the SafeHtmlBuilder to render into
values the row values
start the absolute start index of the values
selectionModel the SelectionModel

protected void replaceAllChildren (List<T> values, SafeHtml html)

Replace all children with the specified html.

Parameters
values the values of the new children
html the html to render in the child

protected void replaceChildren (List<T> values, int start, SafeHtml html)

Convert the specified HTML into DOM elements and replace the existing elements starting at the specified index. If the number of children specified exceeds the existing number of children, the remaining children should be appended.

Parameters
values the values of the new children
start the start index to be replaced, relative to the page start
html the HTML to convert

protected abstract boolean resetFocusOnCell ()

Reset focus on the currently focused cell.

Returns
  • true if focus is taken, false if not

protected void setFocusable (Element elem, boolean focusable)

Make an element focusable or not.

Parameters
elem the element
focusable true to make focusable, false to make unfocusable

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 element
selected true if selected, false if not
stealFocus true if the row should steal focus, false if not

protected void setSelected (Element elem, boolean selected)

This method is deprecated.
this method is never called by AbstractHasData, render the selected styles in renderRowValues(SafeHtmlBuilder, List, int, SelectionModel)

Update an element to reflect its selected state.

Parameters
elem the element to update
selected true if selected, false if not