Package com.google.gwt.cell.client
Class IconCellDecorator<C>
- java.lang.Object
-
- com.google.gwt.cell.client.IconCellDecorator<C>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static interfaceIconCellDecorator.Template-
Nested classes/interfaces inherited from interface com.google.gwt.cell.client.Cell
Cell.Context
-
-
Constructor Summary
Constructors Constructor Description IconCellDecorator(ImageResource icon, Cell<C> cell)Construct a newIconCellDecorator.IconCellDecorator(ImageResource icon, Cell<C> cell, HasVerticalAlignment.VerticalAlignmentConstant valign, int spacing)Construct a newIconCellDecorator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleandependsOnSelection()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 (seeBrowserEventsfor useful constants).protected SafeHtmlgetIconHtml(C value)Get the safe HTML string that represents the icon.(package private) SafeHtmlgetImageHtml(ImageResource res, HasVerticalAlignment.VerticalAlignmentConstant valign, boolean isPlaceholder)Get the HTML representation of an image.booleanhandlesSelection()Check if this cell handles selection.booleanisEditing(Cell.Context context, Element parent, C value)Returns true if the cell is currently editing the data identified by the given element and key.protected booleanisIconUsed(C value)Check if the icon should be used for the value.voidonBrowserEvent(Cell.Context context, Element parent, C value, NativeEvent event, ValueUpdater<C> valueUpdater)Handle a browser event that took place within the cell.voidrender(Cell.Context context, C value, SafeHtmlBuilder sb)Render a cell as HTML into aSafeHtmlBuilder, suitable for passing toElement.setInnerHTML(String)on a container element.booleanresetFocus(Cell.Context context, Element parent, C value)Reset focus on the Cell.voidsetValue(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 usingElement.setInnerHTML(String).
-
-
-
Constructor Detail
-
IconCellDecorator
public IconCellDecorator(ImageResource icon, Cell<C> cell)
Construct a newIconCellDecorator. The icon and the content will be middle aligned by default.- Parameters:
icon- the icon to usecell- the cell to decorate
-
IconCellDecorator
public IconCellDecorator(ImageResource icon, Cell<C> cell, HasVerticalAlignment.VerticalAlignmentConstant valign, int spacing)
Construct a newIconCellDecorator.- Parameters:
icon- the icon to usecell- the cell to decoratevalign- the vertical alignment attribute of the contentsspacing- the pixel space between the icon and the cell
-
-
Method Detail
-
dependsOnSelection
public boolean dependsOnSelection()
Description copied from interface:CellCheck if this cell depends on the selection state.- Specified by:
dependsOnSelectionin interfaceCell<C>- Returns:
- true if dependent on selection, false if not
-
getConsumedEvents
public java.util.Set<java.lang.String> getConsumedEvents()
Description copied from interface:CellGet the set of events that this cell consumes (seeBrowserEventsfor useful constants). The container that uses this cell should only pass these events toCell.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.
- Specified by:
getConsumedEventsin interfaceCell<C>- Returns:
- the consumed events, or null if no events are consumed
- See Also:
BrowserEvents
-
handlesSelection
public boolean handlesSelection()
Description copied from interface:CellCheck if this cell handles selection. If the cell handles selection, then its container should not automatically handle selection.- Specified by:
handlesSelectionin interfaceCell<C>- Returns:
- true if the cell handles selection, false if not
-
isEditing
public boolean isEditing(Cell.Context context, Element parent, C value)
Description copied from interface:CellReturns true if the cell is currently editing the data identified by the given element and key. While a cell is editing, widgets containing the cell may choose to pass keystrokes directly to the cell rather than using them for navigation purposes.- Specified by:
isEditingin interfaceCell<C>- Parameters:
context- theCell.Contextof the cellparent- the parent Elementvalue- the value associated with the cell- Returns:
- true if the cell is in edit mode
-
onBrowserEvent
public void onBrowserEvent(Cell.Context context, Element parent, C value, NativeEvent event, ValueUpdater<C> valueUpdater)
Description copied from interface:CellHandle a browser event that took place within the cell. The default implementation returns null.- Specified by:
onBrowserEventin interfaceCell<C>- Parameters:
context- theCell.Contextof the cellparent- the parent Elementvalue- the value associated with the cellevent- the native browser eventvalueUpdater- aValueUpdater, or null if not specified
-
render
public void render(Cell.Context context, C value, SafeHtmlBuilder sb)
Description copied from interface:CellRender a cell as HTML into aSafeHtmlBuilder, suitable for passing toElement.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.
- Specified by:
renderin interfaceCell<C>- Parameters:
context- theCell.Contextof the cellvalue- the cell value to be renderedsb- theSafeHtmlBuilderto be written to
-
resetFocus
public boolean resetFocus(Cell.Context context, Element parent, C value)
Description copied from interface:CellReset focus on the Cell. This method is called if the cell has focus when it is refreshed.- Specified by:
resetFocusin interfaceCell<C>- Parameters:
context- theCell.Contextof the cellparent- the parent Elementvalue- the value associated with the cell- Returns:
- true if focus is taken, false if not
-
setValue
public void setValue(Cell.Context context, Element parent, C value)
Description copied from interface:CellThis method may be used by cell containers to set the value on a single cell directly, rather than usingElement.setInnerHTML(String). SeeAbstractCell.setValue(Context, Element, Object)for a default implementation that usesCell.render(Context, Object, SafeHtmlBuilder).- Specified by:
setValuein interfaceCell<C>- Parameters:
context- theCell.Contextof the cellparent- the parent Elementvalue- the value associated with the cell
-
getIconHtml
protected SafeHtml getIconHtml(C value)
Get the safe HTML string that represents the icon. Override this method to change the icon based on the value.- Parameters:
value- the value being rendered- Returns:
- the HTML string that represents the icon
-
isIconUsed
protected boolean isIconUsed(C value)
Check if the icon should be used for the value. If the icon should not be used, a placeholder of the same size will be used instead. The default implementations returns true.- Parameters:
value- the value being rendered- Returns:
- true to use the icon, false to use a placeholder
-
getImageHtml
SafeHtml getImageHtml(ImageResource res, HasVerticalAlignment.VerticalAlignmentConstant valign, boolean isPlaceholder)
Get the HTML representation of an image. Visible for testing.- Parameters:
res- theImageResourceto render as HTMLvalign- the vertical alignmentisPlaceholder- if true, do not include the background image- Returns:
- the rendered HTML
-
-