GWT 2.1.0

com.google.gwt.cell.client
Class CompositeCell<C>

java.lang.Object
  extended by com.google.gwt.cell.client.AbstractCell<C>
      extended by com.google.gwt.cell.client.CompositeCell<C>
Type Parameters:
C - the type that this Cell represents
All Implemented Interfaces:
Cell<C>

public class CompositeCell<C>
extends AbstractCell<C>

A Cell that is composed of other Cells.

When this cell is rendered, it will render each component Cell inside a span. If the component Cell uses block level elements (such as a Div), the component cells will stack vertically.


Constructor Summary
CompositeCell(java.util.List<HasCell<C,?>> hasCells)
          Construct a new CompositeCell.
 
Method Summary
 boolean dependsOnSelection()
          Check if this cell depends on the selection state.
 java.util.Set<java.lang.String> getConsumedEvents()
          Get the set of events that this cell consumes.
protected  Element getContainerElement(Element parent)
          Get the element that acts as the container for all children.
 boolean handlesSelection()
          Check if this cell handles selection.
 void onBrowserEvent(Element parent, C value, java.lang.Object key, NativeEvent event, ValueUpdater<C> valueUpdater)
          Handle a browser event that took place within the cell.
 void render(C value, java.lang.Object key, SafeHtmlBuilder sb)
          Render a cell as HTML into a SafeHtmlBuilder, suitable for passing to Element.setInnerHTML(java.lang.String) on a container element.
protected
<X> void
render(C value, java.lang.Object key, SafeHtmlBuilder sb, HasCell<C,X> hasCell)
          Render the composite cell as HTML into a SafeHtmlBuilder, suitable for passing to Element.setInnerHTML(java.lang.String) on a container element.
 boolean resetFocus(Element parent, C value, java.lang.Object key)
          Reset focus on the Cell.
 void setValue(Element parent, C object, java.lang.Object key)
          This method may be used by cell containers to set the value on a single cell directly, rather than using Element.setInnerHTML(String).
 
Methods inherited from class com.google.gwt.cell.client.AbstractCell
isEditing, onEnterKeyDown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompositeCell

public CompositeCell(java.util.List<HasCell<C,?>> hasCells)
Construct a new CompositeCell.

Parameters:
hasCells - the cells that makeup the composite
Method Detail

dependsOnSelection

public boolean dependsOnSelection()
Description copied from interface: Cell
Check if this cell depends on the selection state.

Specified by:
dependsOnSelection in interface Cell<C>
Overrides:
dependsOnSelection in class AbstractCell<C>
Returns:
true if dependent on selection, false if not

getConsumedEvents

public java.util.Set<java.lang.String> getConsumedEvents()
Description copied from interface: Cell
Get the set of events that this cell consumes. The container that uses this cell should only pass these events to Cell.onBrowserEvent(Element, Object, Object, NativeEvent, ValueUpdater).

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.

Specified by:
getConsumedEvents in interface Cell<C>
Overrides:
getConsumedEvents in class AbstractCell<C>
Returns:
the consumed events, or null if no events are consumed

handlesSelection

public boolean handlesSelection()
Description copied from interface: Cell
Check if this cell handles selection. If the cell handles selection, then its container should not automatically handle selection.

Specified by:
handlesSelection in interface Cell<C>
Overrides:
handlesSelection in class AbstractCell<C>
Returns:
true if the cell handles selection, false if not

onBrowserEvent

public void onBrowserEvent(Element parent,
                           C value,
                           java.lang.Object key,
                           NativeEvent event,
                           ValueUpdater<C> valueUpdater)
Description copied from class: AbstractCell
Handle a browser event that took place within the cell. The default implementation returns null.

If you override this method to add support for events, remember to pass the event types that the cell expects into the constructor.

Specified by:
onBrowserEvent in interface Cell<C>
Overrides:
onBrowserEvent in class AbstractCell<C>
Parameters:
parent - the parent Element
value - the value associated with the cell
key - the unique key associated with the row object
event - the native browser event
valueUpdater - a ValueUpdater, or null if not specified

render

public void render(C value,
                   java.lang.Object key,
                   SafeHtmlBuilder sb)
Description copied from interface: Cell
Render a cell as HTML into a SafeHtmlBuilder, suitable for passing to Element.setInnerHTML(java.lang.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.

Specified by:
render in interface Cell<C>
Specified by:
render in class AbstractCell<C>
Parameters:
value - the cell value to be rendered
key - the unique key associated with the row object
sb - the SafeHtmlBuilder to be written to

resetFocus

public boolean resetFocus(Element parent,
                          C value,
                          java.lang.Object key)
Description copied from class: AbstractCell
Reset focus on the Cell. This method is called if the cell has focus when it is refreshed.

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.

Specified by:
resetFocus in interface Cell<C>
Overrides:
resetFocus in class AbstractCell<C>
Parameters:
parent - the parent Element
value - the value associated with the cell
key - the unique key associated with the row object
Returns:
true if focus is taken, false if not

setValue

public void setValue(Element parent,
                     C object,
                     java.lang.Object key)
Description copied from interface: Cell
This method may be used by cell containers to set the value on a single cell directly, rather than using Element.setInnerHTML(String). See AbstractCell.setValue(Element, Object, Object) for a default implementation that uses Cell.render(Object, Object, SafeHtmlBuilder).

Specified by:
setValue in interface Cell<C>
Overrides:
setValue in class AbstractCell<C>
Parameters:
parent - the parent Element
object - the value associated with the cell
key - the unique key associated with the row object

getContainerElement

protected Element getContainerElement(Element parent)
Get the element that acts as the container for all children. If children are added directly to the parent, the parent is the container. If children are added in a table row, the row is the parent.

Parameters:
parent - the parent element of the cell
Returns:
the container element

render

protected <X> void render(C value,
                          java.lang.Object key,
                          SafeHtmlBuilder sb,
                          HasCell<C,X> hasCell)
Render the composite cell as HTML into a SafeHtmlBuilder, suitable for passing to Element.setInnerHTML(java.lang.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.

Parameters:
value - the cell value to be rendered
key - the unique key associated with the row object
sb - the SafeHtmlBuilder to be written to
hasCell - a HasCell instance containing the cells to be rendered within this cell

GWT 2.1.0