com.arsdigita.bebop.table
Class DefaultTableCellRenderer

java.lang.Object
  extended bycom.arsdigita.util.LockableImpl
      extended bycom.arsdigita.bebop.table.DefaultTableCellRenderer
All Implemented Interfaces:
Lockable, TableCellRenderer

public class DefaultTableCellRenderer
extends LockableImpl
implements TableCellRenderer

The default renderer for table cells. This renderer is used by the Table component for rendering the table headers and cells if no other renderer is specified.

This renderer can operate in two different modes: active and inactive mode. In inactive mode, all objects are rendered by converting them to a string and enclosing that string in a Label. If the renderer is in active mode, this label is further enclosed in a control link. When the user clicks on this link, the table will fire an TableActionEvent whose getKey() and getColumn() method return the values of the key and column parameters that were passed into getComponent.

In a nutshell, an active renderer will let the user click a link that causes a TableActionEvent for the corresponding cell, while an inactive renderer will display the values just as strings, thus making it impossible for the user to cause such an event.

Version:
$Id: //core-platform/dev/src/com/arsdigita/bebop/table/DefaultTableCellRenderer.java#9 $
Author:
David Lutterkort
See Also:
Table, TableActionEvent

Field Summary
static String versionId
           
 
Constructor Summary
DefaultTableCellRenderer()
          Creates a new table cell renderer.
DefaultTableCellRenderer(boolean active)
          Creates a new table cell renderer.
 
Method Summary
 Component getComponent(Table table, PageState state, Object value, boolean isSelected, Object key, int row, int column)
          Return the component that should be used to render the given value.
 boolean isActive()
          Return true if the renderer is in active mode.
 void setActive(boolean v)
          Set the renderer to active or inactive mode.
 
Methods inherited from class com.arsdigita.util.LockableImpl
isLocked, lock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values
Constructor Detail

DefaultTableCellRenderer

public DefaultTableCellRenderer()
Creates a new table cell renderer. The table cell renderer is in inactive mode.


DefaultTableCellRenderer

public DefaultTableCellRenderer(boolean active)
Creates a new table cell renderer. The active argument specifies whether the renderer should be active or not.

Parameters:
active - true if the renderer should generate links instead of just static labels.
Method Detail

isActive

public final boolean isActive()
Return true if the renderer is in active mode. A rendererin active mode will enclose the objects it renders in links that, when clicked, will cause the containing table to fire a TableActionEvent.

Returns:
true if the renderer is in active mode.

setActive

public void setActive(boolean v)
Set the renderer to active or inactive mode.

Parameters:
v - true if the renderer should operate in active mode.

getComponent

public Component getComponent(Table table,
                              PageState state,
                              Object value,
                              boolean isSelected,
                              Object key,
                              int row,
                              int column)
Return the component that should be used to render the given value. Returns a Label if the renderer is active, and a ControlLink if the renderer is inactive.

Specified by:
getComponent in interface TableCellRenderer
Parameters:
table - the table requesting the rendering.
state - represents the state of the current request.
value - the data element to render as returned by the table model's getElementAt(column).
isSelected - true if this item is selected.
key - the key identifying this row (and possibly column) as returned by the table model's getKeyAt(column)
row - the number of the row in the table, the first row has number 0.
column - the number of the table column.
Returns:
the component that should be used to render the value.
See Also:
TableColumnModel


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2337 UTC