com.vaadin.client.renderers
Class ComplexRenderer<T>

java.lang.Object
  extended by com.vaadin.client.renderers.ComplexRenderer<T>
All Implemented Interfaces:
Renderer<T>
Direct Known Subclasses:
WidgetRenderer

public abstract class ComplexRenderer<T>
extends java.lang.Object
implements Renderer<T>

Base class for renderers that needs initialization and destruction logic (override #init(FlyweightCell) and #destroy(FlyweightCell) and event handling (see #onBrowserEvent(Cell, NativeEvent), getConsumedEvents() and #onActivate().

Also provides a helper method for hiding the cell contents by overriding #setContentVisible(FlyweightCell, boolean)

Since:
7.4.0
Author:
Vaadin Ltd

Constructor Summary
ComplexRenderer()
           
 
Method Summary
 void destroy()
          Called when the renderer is deemed to be destroyed and no longer used by the Grid.
 void destroy(RendererCellReference cell)
          Called after the cell is deemed to be destroyed and no longer used by the Grid.
 java.util.Collection<java.lang.String> getConsumedEvents()
          Returns the events that the renderer should consume.
abstract  void init(RendererCellReference cell)
          Called at initialization stage.
 boolean onActivate(CellReference<?> cell)
          Called when the cell is activated by pressing enter, double clicking or performing a double tap on the cell.
 boolean onBrowserEvent(CellReference<?> cell, NativeEvent event)
          Called whenever a registered event is triggered in the column the renderer renders.
 void setContentVisible(RendererCellReference cell, boolean hasData)
          Used by Grid to toggle whether to show actual data or just an empty placeholder while data is loading.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.vaadin.client.renderers.Renderer
render
 

Constructor Detail

ComplexRenderer

public ComplexRenderer()
Method Detail

init

public abstract void init(RendererCellReference cell)
Called at initialization stage. Perform any initialization here e.g. attach handlers, attach widgets etc.

Parameters:
cell - The cell. Note that the cell is not to be stored outside of the method as the cell instance will change. See FlyweightCell

destroy

public void destroy(RendererCellReference cell)
Called after the cell is deemed to be destroyed and no longer used by the Grid. Called after the cell element is detached from the DOM.

The row object in the cell reference will be null since the row might no longer be present in the data source.

Parameters:
cell - The cell. Note that the cell is not to be stored outside of the method as the cell instance will change. See FlyweightCell

getConsumedEvents

public java.util.Collection<java.lang.String> getConsumedEvents()
Returns the events that the renderer should consume. These are also the events that the Grid will pass to #onBrowserEvent(Cell, NativeEvent) when they occur.

Returns:
a list of consumed events
See Also:
com.google.gwt.dom.client.BrowserEvents

onBrowserEvent

public boolean onBrowserEvent(CellReference<?> cell,
                              NativeEvent event)
Called whenever a registered event is triggered in the column the renderer renders.

The events that triggers this needs to be returned by the getConsumedEvents() method.

Returns boolean telling if the event has been completely handled and should not cause any other actions.

Parameters:
cell - Object containing information about the cell the event was triggered on.
event - The original DOM event
Returns:
true if event should not be handled by grid

setContentVisible

public void setContentVisible(RendererCellReference cell,
                              boolean hasData)
Used by Grid to toggle whether to show actual data or just an empty placeholder while data is loading. This method is invoked whenever a cell changes between data being available and data missing.

Default implementation hides content by setting visibility: hidden to all elements inside the cell. Text nodes are left as is - renderers that add such to the root element need to implement explicit support hiding them.

Parameters:
cell - The cell
hasData - Has the cell content been loaded from the data source

onActivate

public boolean onActivate(CellReference<?> cell)
Called when the cell is activated by pressing enter, double clicking or performing a double tap on the cell.

Parameters:
cell - the activated cell
Returns:
true if event was handled and should not be interpreted as a generic gesture by Grid.

destroy

public void destroy()
Called when the renderer is deemed to be destroyed and no longer used by the Grid.



Copyright © 2000-2014 Vaadin Ltd. All Rights Reserved.