C
- the type that this Cell representspublic abstract class AbstractCell<C> extends Object implements Cell<C>
Cell
interface.
Cell.Context
Constructor and Description |
---|
AbstractCell(Set<String> consumedEvents)
Construct a new
AbstractCell with the specified consumed events. |
AbstractCell(String... consumedEvents)
Construct a new
AbstractCell with the specified consumed events. |
Modifier and Type | Method and Description |
---|---|
boolean |
dependsOnSelection()
Check if this cell depends on the selection state.
|
Set<String> |
getConsumedEvents()
Get the set of events that this cell consumes (see
BrowserEvents for useful
constants). |
boolean |
handlesSelection()
Check if this cell handles selection.
|
boolean |
isEditing(Cell.Context context,
Element parent,
C value)
Returns false.
|
void |
onBrowserEvent(Cell.Context context,
Element parent,
C value,
NativeEvent event,
ValueUpdater<C> valueUpdater)
Handle a browser event that took place within the cell.
|
protected void |
onEnterKeyDown(Cell.Context context,
Element parent,
C value,
NativeEvent event,
ValueUpdater<C> valueUpdater)
Called when the user triggers a
keydown event with the ENTER
key while focused on the cell. |
abstract void |
render(Cell.Context context,
C value,
SafeHtmlBuilder sb)
Render a cell as HTML into a
SafeHtmlBuilder , suitable for passing
to Element.setInnerHTML(String) on a container element. |
boolean |
resetFocus(Cell.Context context,
Element parent,
C value)
Reset focus on the Cell.
|
void |
setValue(Cell.Context context,
Element parent,
C value)
This method may be used by cell containers to set the value on a single
cell directly, rather than using
Element.setInnerHTML(String) . |
public AbstractCell(String... consumedEvents)
AbstractCell
with the specified consumed events.
The input arguments are passed by copy.consumedEvents
- the events
that this cell consumesBrowserEvents
public AbstractCell(Set<String> consumedEvents)
AbstractCell
with the specified consumed events.consumedEvents
- the events that this cell consumespublic boolean dependsOnSelection()
Cell
dependsOnSelection
in interface Cell<C>
public Set<String> getConsumedEvents()
Cell
BrowserEvents
for useful
constants). The container that uses this cell should only pass these events
to
Cell.onBrowserEvent(Context, Element, Object, NativeEvent, ValueUpdater)
when the event occurs.
The returned value should not be modified, and may be an unmodifiable set. Changes to the return value may not be reflected in the cell.
getConsumedEvents
in interface Cell<C>
BrowserEvents
public boolean handlesSelection()
Cell
handlesSelection
in interface Cell<C>
public boolean isEditing(Cell.Context context, Element parent, C value)
isEditing
in interface Cell<C>
context
- the Cell.Context
of the cellparent
- the parent Elementvalue
- the value associated with the cellpublic void onBrowserEvent(Cell.Context context, Element parent, C value, NativeEvent event, ValueUpdater<C> valueUpdater)
If you override this method to add support for events, remember to pass the event types that the cell expects into the constructor.
onBrowserEvent
in interface Cell<C>
context
- the Cell.Context
of the cellparent
- the parent Elementvalue
- the value associated with the cellevent
- the native browser eventvalueUpdater
- a ValueUpdater
, or null if not specifiedpublic abstract void render(Cell.Context context, C value, SafeHtmlBuilder sb)
Cell
SafeHtmlBuilder
, suitable for passing
to Element.setInnerHTML(String)
on a container element.
Note: If your cell contains natively focusable elements, such as buttons or input elements, be sure to set the tabIndex to -1 so that they do not steal focus away from the containing widget.
render
in interface Cell<C>
context
- the Cell.Context
of the cellvalue
- the cell value to be renderedsb
- the SafeHtmlBuilder
to be written topublic boolean resetFocus(Cell.Context context, Element parent, C value)
This method is a no-op and returns false. If your cell is editable or can be focused by the user, override this method to reset focus when the containing widget is refreshed.
resetFocus
in interface Cell<C>
context
- the Cell.Context
of the cellparent
- the parent Elementvalue
- the value associated with the cellpublic void setValue(Cell.Context context, Element parent, C value)
Cell
Element.setInnerHTML(String)
. See
Cell.setValue(Context, Element, Object)
for a default
implementation that uses Cell.render(Context, Object, SafeHtmlBuilder)
.setValue
in interface Cell<C>
context
- the Cell.Context
of the cellparent
- the parent Elementvalue
- the value associated with the cellprotected void onEnterKeyDown(Cell.Context context, Element parent, C value, NativeEvent event, ValueUpdater<C> valueUpdater)
keydown
event with the ENTER
key while focused on the cell. If your cell interacts with the user, you
should override this method to provide a consistent user experience. Your
widget must consume keydown
events for this method to be
called.context
- the Context
of the cellparent
- the parent Elementvalue
- the value associated with the cellevent
- the native browser eventvalueUpdater
- a ValueUpdater
, or null if not specifiedCopyright © 2018. All rights reserved.