GWT 2.7.0

com.google.gwt.user.cellview.client
Class AbstractHasData<T>

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.google.gwt.user.client.ui.Composite
              extended by com.google.gwt.user.cellview.client.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

public abstract class AbstractHasData<T>
extends Composite
implements HasData<T>, HasKeyProvider<T>, Focusable, HasKeyboardPagingPolicy

An abstract Widget that implements HasData.


Nested Class Summary
static class AbstractHasData.DefaultKeyboardSelectionHandler<T>
          Default implementation of a keyboard navigation handler.
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
 
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)  boolean isFocused
          A boolean indicating that the widget has focus.
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
AbstractHasData(Element elem, int pageSize, ProvidesKey<T> keyProvider)
          Constructs an AbstractHasData with the given page size.
AbstractHasData(Widget widget, int pageSize, ProvidesKey<T> keyProvider)
          Constructs an AbstractHasData with the given page size.
 
Method Summary
 HandlerRegistration addCellPreviewHandler(CellPreviewEvent.Handler<T> handler)
          Adds a CellPreviewEvent handler.
 HandlerRegistration addLoadingStateChangeHandler(LoadingStateChangeEvent.Handler handler)
          Add a LoadingStateChangeEvent.Handler to be notified of changes in the loading state.
 HandlerRegistration addRangeChangeHandler(RangeChangeEvent.Handler handler)
          Add a RangeChangeEvent.Handler.
 HandlerRegistration addRowCountChangeHandler(RowCountChangeEvent.Handler handler)
          Add a RowCountChangeEvent.Handler.
(package private)  HandlerRegistration addValueChangeHandler(ValueChangeHandler<java.util.List<T>> handler)
          Add a ValueChangeHandler that 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()
          Get the HasKeyboardPagingPolicy.KeyboardPagingPolicy.
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()
          Get the HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.
 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 SelectionModel used by this HasData.
 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)
          Set the HasKeyboardPagingPolicy.KeyboardPagingPolicy.
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)
          Set the HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.
 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 SelectionModel used by this HasData.
 void setSelectionModel(SelectionModel<? super T> selectionModel, CellPreviewEvent.Handler<T> selectionEventManager)
          Set the SelectionModel that defines which items are selected and the CellPreviewEvent.Handler that 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.
 
Methods inherited from class com.google.gwt.user.client.ui.Composite
claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, onDetach, render, render, resolvePotentialElement, setWidget
 
Methods 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, unsinkEvents
 
Methods 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, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
 

Field Detail

isFocused

boolean isFocused
A boolean indicating that the widget has focus.

Constructor Detail

AbstractHasData

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

AbstractHasData

public AbstractHasData(Widget widget,
                       int pageSize,
                       ProvidesKey<T> keyProvider)
Constructs an AbstractHasData with the given page size.

Parameters:
widget - the parent Widget
pageSize - the page size
keyProvider - the key provider, or null
Method Detail

convertToElements

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.

Parameters:
html - the HTML to convert
tmpElem - a temporary element
Returns:
the parent element

replaceAllChildren

static void replaceAllChildren(Widget widget,
                               Element childContainer,
                               SafeHtml html)
Convenience method to replace all children of a Widget.

Parameters:
widget - the widget who's contents will be replaced
childContainer - the container that holds the contents
html - the html to set

replaceChildren

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. If the number of children specified exceeds the existing number of children, the remaining children should be appended.

Parameters:
widget - the widget who's contents will be replaced
childContainer - the container that holds the contents
newChildren - an element containing the new children
start - the start index to replace
html - the HTML to convert

addCellPreviewHandler

public HandlerRegistration addCellPreviewHandler(CellPreviewEvent.Handler<T> handler)
Description copied from interface: HasCellPreviewHandlers
Adds a CellPreviewEvent handler.

Specified by:
addCellPreviewHandler in interface HasCellPreviewHandlers<T>
Parameters:
handler - the handler
Returns:
the registration for the event

addLoadingStateChangeHandler

public HandlerRegistration addLoadingStateChangeHandler(LoadingStateChangeEvent.Handler handler)
Add a LoadingStateChangeEvent.Handler to be notified of changes in the loading state.

Parameters:
handler - the handle
Returns:
the registration for the handler

addRangeChangeHandler

public HandlerRegistration addRangeChangeHandler(RangeChangeEvent.Handler handler)
Description copied from interface: HasRows
Add a RangeChangeEvent.Handler.

Specified by:
addRangeChangeHandler in interface HasRows
Parameters:
handler - the handler
Returns:
a HandlerRegistration to remove the handler

addRowCountChangeHandler

public HandlerRegistration addRowCountChangeHandler(RowCountChangeEvent.Handler handler)
Description copied from interface: HasRows
Add a RowCountChangeEvent.Handler.

Specified by:
addRowCountChangeHandler in interface HasRows
Parameters:
handler - the handler
Returns:
a HandlerRegistration to remove the handler

getAccessKey

public char getAccessKey()
Get the access key.

Returns:
the access key, or -1 if not set
See Also:
setAccessKey(char)

getDisplayedItem

@Deprecated
public T getDisplayedItem(int indexOnPage)
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

getDisplayedItems

@Deprecated
public java.util.List<T> getDisplayedItems()
Deprecated. use getVisibleItems() instead

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

Returns:
a List of displayed items

getKeyboardPagingPolicy

public HasKeyboardPagingPolicy.KeyboardPagingPolicy getKeyboardPagingPolicy()
Description copied from interface: HasKeyboardPagingPolicy
Get the HasKeyboardPagingPolicy.KeyboardPagingPolicy.

Specified by:
getKeyboardPagingPolicy in interface HasKeyboardPagingPolicy
Returns:
the paging policy
See Also:
HasKeyboardPagingPolicy.setKeyboardPagingPolicy(KeyboardPagingPolicy)

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

public HasKeyboardSelectionPolicy.KeyboardSelectionPolicy getKeyboardSelectionPolicy()
Description copied from interface: HasKeyboardSelectionPolicy
Get the HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.

Specified by:
getKeyboardSelectionPolicy in interface HasKeyboardSelectionPolicy
Returns:
the selection policy
See Also:
HasKeyboardSelectionPolicy.setKeyboardSelectionPolicy(KeyboardSelectionPolicy)

getKeyProvider

public ProvidesKey<T> getKeyProvider()
Description copied from interface: HasKeyProvider
Return the key provider.

Specified by:
getKeyProvider in interface HasKeyProvider<T>
Returns:
the ProvidesKey instance

getPageSize

public final int getPageSize()
Return the range size.

Returns:
the size of the range as an int
See Also:
getVisibleRange(), setPageSize(int)

getPageStart

public final int getPageStart()
Return the range start.

Returns:
the start of the range as an int
See Also:
getVisibleRange(), setPageStart(int)

getRowContainer

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

getRowCount

public int getRowCount()
Description copied from interface: HasRows
Get the total count of all rows.

Specified by:
getRowCount in interface HasRows
Returns:
the total row count
See Also:
HasRows.setRowCount(int)

getSelectionModel

public SelectionModel<? super T> getSelectionModel()
Description copied from interface: HasData
Get the SelectionModel used by this HasData.

Specified by:
getSelectionModel in interface HasData<T>
Returns:
the SelectionModel
See Also:
HasData.setSelectionModel(SelectionModel)

getTabIndex

public int getTabIndex()
Description copied from interface: Focusable
Gets the widget's position in the tab index.

Specified by:
getTabIndex in interface Focusable
Returns:
the widget's tab index

getValueKey

public java.lang.Object getValueKey(T value)
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

public T getVisibleItem(int indexOnPage)
Description copied from interface: HasData
Get the row value at the specified visible index. Index 0 corresponds to the first item on the page.

Specified by:
getVisibleItem in interface HasData<T>
Parameters:
indexOnPage - the index on the page
Returns:
the row value

getVisibleItemCount

public int getVisibleItemCount()
Description copied from interface: HasData
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.

Specified by:
getVisibleItemCount in interface HasData<T>
Returns:
the number of visible items on the page

getVisibleItems

public java.util.List<T> getVisibleItems()
Return the row values that the widget is currently displaying as an immutable list.

Specified by:
getVisibleItems in interface HasData<T>
Returns:
a List of displayed items

getVisibleRange

public Range getVisibleRange()
Description copied from interface: HasRows
Get the range of visible rows.

Specified by:
getVisibleRange in interface HasRows
Returns:
the visible range
See Also:
HasRows.setVisibleRange(Range), HasRows.setVisibleRange(int, int)

isRowCountExact

public boolean isRowCountExact()
Description copied from interface: HasRows
Check if the total row count is exact, or an estimate.

Specified by:
isRowCountExact in interface HasRows
Returns:
true if exact, false if an estimate

onBrowserEvent

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

Specified by:
onBrowserEvent in interface EventListener
Overrides:
onBrowserEvent in class Composite
Parameters:
event - the event received
See Also:
onBrowserEvent2(Event)

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:
setAccessKey in interface Focusable
Parameters:
key - the widget's access key
See Also:
getAccessKey()

setFocus

public void setFocus(boolean focused)
Description copied from interface: Focusable
Explicitly focus/unfocus this widget. Only one widget can have focus at a time, and the widget that does will receive all keyboard events.

Specified by:
setFocus in interface Focusable
Parameters:
focused - whether this widget should take focus or release it

setKeyboardPagingPolicy

public void setKeyboardPagingPolicy(HasKeyboardPagingPolicy.KeyboardPagingPolicy policy)
Description copied from interface: HasKeyboardPagingPolicy
Set the HasKeyboardPagingPolicy.KeyboardPagingPolicy.

Specified by:
setKeyboardPagingPolicy in interface HasKeyboardPagingPolicy
Parameters:
policy - the paging policy
See Also:
HasKeyboardPagingPolicy.getKeyboardPagingPolicy()

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 start
stealFocus - true to focus on the new row
See Also:
setKeyboardSelectedRow(int)

setKeyboardSelectionHandler

public void setKeyboardSelectionHandler(CellPreviewEvent.Handler<T> keyboardSelectionReg)
Set the handler that handles keyboard selection/navigation.


setKeyboardSelectionPolicy

public void setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy policy)
Description copied from interface: HasKeyboardSelectionPolicy
Set the HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.

Specified by:
setKeyboardSelectionPolicy in interface HasKeyboardSelectionPolicy
Parameters:
policy - the selection policy
See Also:
HasKeyboardSelectionPolicy.getKeyboardSelectionPolicy()

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:
setVisibleRange(Range), getPageSize()

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:
setVisibleRange(Range), getPageStart()

setRowCount

public final void setRowCount(int count)
Description copied from interface: HasRows
Set the exact total count of all rows. This method defers to HasRows.setRowCount(int, boolean).

Specified by:
setRowCount in interface HasRows
Parameters:
count - the exact total count
See Also:
HasRows.getRowCount()

setRowCount

public void setRowCount(int size,
                        boolean isExact)
Description copied from interface: HasRows
Set the total count of all rows, specifying whether the count is exact or an estimate.

Specified by:
setRowCount in interface HasRows
Parameters:
size - the total count
isExact - true if the count is exact, false if an estimate
See Also:
HasRows.getRowCount()

setRowData

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.

Parameters:
values -

setRowData

public void setRowData(int start,
                       java.util.List<? extends T> values)
Description copied from interface: HasData

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

Specified by:
setRowData in interface HasData<T>
Parameters:
start - the start index of the data
values - the values within the range

setSelectionModel

public void setSelectionModel(SelectionModel<? super T> selectionModel)
Set the 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.

Specified by:
setSelectionModel in interface HasData<T>
Parameters:
selectionModel - the SelectionModel
See Also:
setSelectionModel(SelectionModel, com.google.gwt.view.client.CellPreviewEvent.Handler), getSelectionModel()

setSelectionModel

public void setSelectionModel(SelectionModel<? super T> selectionModel,
                              CellPreviewEvent.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

setTabIndex

public void setTabIndex(int index)
Description copied from interface: Focusable
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.

Specified by:
setTabIndex in interface Focusable
Parameters:
index - the widget's tab index

setVisibleRange

public final void setVisibleRange(int start,
                                  int length)
Description copied from interface: HasRows
Set the visible range or rows. This method defers to HasRows.setVisibleRange(Range).

Specified by:
setVisibleRange in interface HasRows
Parameters:
start - the start index
length - the length
See Also:
HasRows.getVisibleRange()

setVisibleRange

public void setVisibleRange(Range range)
Description copied from interface: HasRows
Set the visible range or rows.

Specified by:
setVisibleRange in interface HasRows
Parameters:
range - the visible range
See Also:
HasRows.getVisibleRange()

setVisibleRangeAndClearData

public void setVisibleRangeAndClearData(Range range,
                                        boolean forceRangeChangeEvent)
Description copied from interface: HasData

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.

Specified by:
setVisibleRangeAndClearData in interface HasData<T>
Parameters:
range - the new Range
forceRangeChangeEvent - true to fire a RangeChangeEvent even if the Range doesn't change

cellConsumesEventType

protected boolean cellConsumesEventType(Cell<?> cell,
                                        java.lang.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

checkRowBounds

protected void checkRowBounds(int row)
Check that the row is within the correct bounds.

Parameters:
row - row index to check
Throws:
java.lang.IndexOutOfBoundsException

convertToElements

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

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

protected abstract Element getChildContainer()
Return the element that holds the rendered cells.

Returns:
the container Element

getChildElement

protected Element getChildElement(int index)
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

protected abstract Element getKeyboardSelectedElement()
Get the element that has keyboard selection.

Returns:
the keyboard selected element

isKeyboardNavigationSuppressed

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

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

protected void onBrowserEvent2(Event event)
Called after onBrowserEvent(Event) completes.

Parameters:
event - the event that was fired

onFocus

protected void onFocus()
Called when the widget is focused.


onLoadingStateChanged

protected void onLoadingStateChanged(LoadingStateChangeEvent.LoadingState state)
Called when the loading state changes. By default, this implementation fires a LoadingStateChangeEvent.

Parameters:
state - the new loading state

onUnload

protected void onUnload()
Description copied from class: Widget
This method is called immediately before a widget will be detached from the browser's document.

Overrides:
onUnload in class Widget

renderRowValues

protected abstract void renderRowValues(SafeHtmlBuilder sb,
                                        java.util.List<T> values,
                                        int start,
                                        SelectionModel<? super T> selectionModel)
                                 throws java.lang.UnsupportedOperationException
Render all row values into the specified 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.

Parameters:
sb - the SafeHtmlBuilder to render into
values - the row values
start - the absolute start index of the values
selectionModel - the SelectionModel
Throws:
java.lang.UnsupportedOperationException - if the values will be rendered in replaceAllChildren(List, SafeHtml) and replaceChildren(List, int, SafeHtml)

replaceAllChildren

protected void replaceAllChildren(java.util.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, or null if renderRowValues(SafeHtmlBuilder, List, int, SelectionModel) throws an UnsupportedOperationException

replaceChildren

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. 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 render, or null if renderRowValues(SafeHtmlBuilder, List, int, SelectionModel) throws an UnsupportedOperationException

resetFocusOnCell

protected abstract boolean resetFocusOnCell()
Reset focus on the currently focused cell.

Returns:
true if focus is taken, false if not

setFocusable

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

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

setSelected

@Deprecated
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)

Update an element to reflect its selected state.

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

addValueChangeHandler

final HandlerRegistration addValueChangeHandler(ValueChangeHandler<java.util.List<T>> handler)
Add a ValueChangeHandler that is called when the display values change. Used by CellBrowser to detect when the displayed data changes.

Parameters:
handler - the handler
Returns:
a HandlerRegistration to remove the handler

adopt

void adopt(Widget child)
Adopt the specified widget.

Parameters:
child - the child to adopt

doAttach

void doAttach(Widget child)
Attach a child.

Parameters:
child - the child to attach

doDetach

void doDetach(Widget child)
Detach a child.

Parameters:
child - the child to detach

getPresenter

HasDataPresenter<T> getPresenter()

showOrHide

void showOrHide(Element element,
                boolean show)
Show or hide an element.

Parameters:
element - the element
show - true to show, false to hide

GWT 2.7.0