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

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

public class IconCellDecorator<C>
extends AbstractCell<C>

A Cell decorator that adds an icon to another Cell.

Note: This class is new and its interface subject to change.


Constructor Summary
IconCellDecorator(ImageResource icon, Cell<C> cell)
          Construct a new IconCellDecorator.
IconCellDecorator(ImageResource icon, Cell<C> cell, HasVerticalAlignment.VerticalAlignmentConstant valign, int spacing)
          Construct a new IconCellDecorator.
 
Method Summary
 boolean consumesEvents()
          Returns true if the cell is interested in browser events.
 boolean dependsOnSelection()
          Check if this cell depends on the selection state.
 java.lang.Object onBrowserEvent(Element parent, C value, java.lang.Object viewData, NativeEvent event, ValueUpdater<C> valueUpdater)
          Handle a browser event that took place within the cell.
 void render(C value, java.lang.Object viewData, java.lang.StringBuilder sb)
          Render a cell as HTML into a StringBuilder, suitable for passing to Element.setInnerHTML(java.lang.String) on a container element.
 void setValue(Element parent, C value, java.lang.Object viewData)
          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 java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IconCellDecorator

public IconCellDecorator(ImageResource icon,
                         Cell<C> cell)
Construct a new IconCellDecorator. The icon and the content will be middle aligned by default.

Parameters:
icon - the icon to use
cell - the cell to decorate

IconCellDecorator

public IconCellDecorator(ImageResource icon,
                         Cell<C> cell,
                         HasVerticalAlignment.VerticalAlignmentConstant valign,
                         int spacing)
Construct a new IconCellDecorator.

Parameters:
icon - the icon to use
cell - the cell to decorate
valign - the vertical alignment attribute of the contents
spacing - the pixel space between the icon and the cell
Method Detail

consumesEvents

public boolean consumesEvents()
Description copied from interface: Cell
Returns true if the cell is interested in browser events. The default implementation returns false.

Specified by:
consumesEvents in interface Cell<C>
Overrides:
consumesEvents in class AbstractCell<C>

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 dependant on selection, false if not

onBrowserEvent

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

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
viewData - the view data associated with the cell, or null
event - the native browser event
valueUpdater - a ValueUpdater, or null
Returns:
a view data object which may be the one passed in or a new object

render

public void render(C value,
                   java.lang.Object viewData,
                   java.lang.StringBuilder sb)
Description copied from interface: Cell
Render a cell as HTML into a StringBuilder, suitable for passing to Element.setInnerHTML(java.lang.String) on a container element.

Specified by:
render in interface Cell<C>
Specified by:
render in class AbstractCell<C>
Parameters:
value - the cell value to be rendered
viewData - view data associated with the cell
sb - the StringBuilder to be written to

setValue

public void setValue(Element parent,
                     C value,
                     java.lang.Object viewData)
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, StringBuilder).

Specified by:
setValue in interface Cell<C>
Overrides:
setValue in class AbstractCell<C>
Parameters:
parent - the parent Element
value - the value associated with the cell
viewData - the view data associated with the cell, or null