net.sf.echobinding.table
Class BoundTable<T>

java.lang.Object
  extended by nextapp.echo2.app.Component
      extended by nextapp.echo2.app.Table
          extended by net.sf.echobinding.table.BoundTable<T>
Type Parameters:
T - The type of the obejcts in the list.
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, nextapp.echo2.app.event.ActionListener, nextapp.echo2.app.RenderIdSupport
Direct Known Subclasses:
ListEditor, SelectableTable

public class BoundTable<T>
extends nextapp.echo2.app.Table
implements nextapp.echo2.app.event.ActionListener, java.beans.PropertyChangeListener

A data bound table. Displays a list of items in form of a table. The columns of the table are defined by the property adapters of the given BindingContext. A BoundTable uses by default the DefaultDataBoundTableCellRenderer for rendering its cells.

See Also:
Serialized Form

Field Summary
protected  BindingContext _ctx
          The binding context.
protected  java.util.List<T> _list
          The list of items.
 
Fields inherited from class nextapp.echo2.app.Table
ACTION_LISTENERS_CHANGED_PROPERTY, AUTO_CREATE_COLUMNS_FROM_MODEL_CHANGED_PROPERTY, COLUMN_MODEL_CHANGED_PROPERTY, DEFAULT_HEADER_RENDERER_CHANGED_PROPERTY, DEFAULT_RENDERER_CHANGED_PROPERTY, DEFAULT_TABLE_CELL_RENDERER, HEADER_ROW, HEADER_VISIBLE_CHANGED_PROPERTY, INPUT_ACTION, MODEL_CHANGED_PROPERTY, PROPERTY_ACTION_COMMAND, PROPERTY_BORDER, PROPERTY_INSETS, PROPERTY_ROLLOVER_BACKGROUND, PROPERTY_ROLLOVER_BACKGROUND_IMAGE, PROPERTY_ROLLOVER_ENABLED, PROPERTY_ROLLOVER_FONT, PROPERTY_ROLLOVER_FOREGROUND, PROPERTY_SELECTION_BACKGROUND, PROPERTY_SELECTION_BACKGROUND_IMAGE, PROPERTY_SELECTION_ENABLED, PROPERTY_SELECTION_FONT, PROPERTY_SELECTION_FOREGROUND, PROPERTY_WIDTH, SELECTION_CHANGED_PROPERTY, SELECTION_MODEL_CHANGED_PROPERTY
 
Fields inherited from class nextapp.echo2.app.Component
CHILDREN_CHANGED_PROPERTY, ENABLED_CHANGED_PROPERTY, FOCUS_TRAVERSAL_INDEX_CHANGED_PROPERTY, FOCUS_TRAVERSAL_PARTICIPANT_CHANGED_PROPERTY, LAYOUT_DIRECTION_CHANGED_PROPERTY, LOCALE_CHANGED_PROPERTY, PROPERTY_BACKGROUND, PROPERTY_FONT, PROPERTY_FOREGROUND, PROPERTY_LAYOUT_DATA, STYLE_CHANGED_PROPERTY, STYLE_NAME_CHANGED_PROPERTY, VISIBLE_CHANGED_PROPERTY
 
Constructor Summary
BoundTable(java.util.List<T> list, BindingContext ctx)
          Creates a data bound table using a list.
BoundTable(java.lang.String listAdapterId, BindingContext ctx)
          Creates a data bound table using a list adapter.
 
Method Summary
 void actionPerformed(nextapp.echo2.app.event.ActionEvent event)
           
 BoundTable<T> addColumn(java.lang.Integer columnIndex, java.lang.String adapterId)
          Adds a column at the specified position to the table.
 BoundTable<T> addColumn(java.lang.String adapterId)
          Adds a column for the specified adpater to the table.
protected  java.lang.Object[][] createTableData()
          Creates the table data.
protected  java.lang.Object[] createTableHeaderData()
          Creates the table header data.
protected  nextapp.echo2.app.table.TableModel createTableModel()
          Creates the table model.
 nextapp.echo2.app.event.ActionListener getActionListener()
          Returns the action listener.
 java.lang.String getAdapterId(int col)
          Returns the adapter id for the specified column.
 BindingContext getBindingContext(int rowIndex)
          Returns the binding context for the specified row.
 java.util.List<PropertyAdapter> getColumnAdapters()
          Returns the column adapters.
 BindingContext getContext()
           
 DetailsHandler getDetailHandler()
           
 nextapp.echo2.app.Color getHeaderBackground()
          Returns the header background color.
protected  T getItem(int row)
          Returns the item for the specified row index.
 java.util.List<T> getList()
          Returns the list.
protected  nextapp.echo2.app.table.TableCellRenderer getTableCellRenderer()
          Gets the table cell renderer.
protected  BoundTableHeaderRenderer getTableHeaderRenderer()
          Gets the table header renderer.
 void init()
           
protected  void initialize()
          Initializes the table.
 void propertyChange(java.beans.PropertyChangeEvent event)
           
 boolean removeColumn(java.lang.String adapterId)
          Removes a column from the table.
 void setActionListener(nextapp.echo2.app.event.ActionListener actionListener)
          Sets the action listener.
 void setColumnAdapters(java.util.List<PropertyAdapter> columnAdapters)
          Sets the column adapters.
 void setContext(BindingContext ctx)
           
 void setDetailHandler(DetailsHandler detailHandler)
           
 void setHeaderBackground(nextapp.echo2.app.Color headerBackground)
          Sets the header background color.
 void setList(java.util.List<T> list)
          Sets the list.
protected  void showDetails(int columnIndex, int rowIndex)
           
 
Methods inherited from class nextapp.echo2.app.Table
addActionListener, createDefaultColumnsFromModel, doRender, getActionCommand, getBorder, getCellComponent, getColumnModel, getDefaultHeaderRenderer, getDefaultRenderer, getInsets, getModel, getRolloverBackground, getRolloverBackgroundImage, getRolloverFont, getRolloverForeground, getSelectionBackground, getSelectionBackgroundImage, getSelectionFont, getSelectionForeground, getSelectionModel, getWidth, hasActionListeners, invalidate, isAutoCreateColumnsFromModel, isHeaderVisible, isRolloverEnabled, isSelectionEnabled, processInput, removeActionListener, setActionCommand, setAutoCreateColumnsFromModel, setBorder, setColumnModel, setDefaultHeaderRenderer, setDefaultRenderer, setHeaderVisible, setInsets, setModel, setRolloverBackground, setRolloverBackgroundImage, setRolloverEnabled, setRolloverFont, setRolloverForeground, setSelectionBackground, setSelectionBackgroundImage, setSelectionEnabled, setSelectionFont, setSelectionForeground, setSelectionModel, setWidth, validate
 
Methods inherited from class nextapp.echo2.app.Component
add, add, addPropertyChangeListener, dispose, firePropertyChange, getApplicationInstance, getBackground, getComponent, getComponent, getComponentCount, getComponents, getEventListenerList, getFocusTraversalIndex, getFont, getForeground, getId, getIndexedProperty, getLayoutData, getLayoutDirection, getLocale, getParent, getProperty, getRenderId, getRenderIndexedProperty, getRenderIndexedProperty, getRenderLayoutDirection, getRenderLocale, getRenderProperty, getRenderProperty, getStyle, getStyleName, getVisibleComponent, getVisibleComponentCount, getVisibleComponents, hasEventListenerList, indexOf, isAncestorOf, isEnabled, isFocusTraversalParticipant, isRegistered, isRenderEnabled, isRenderVisible, isValidChild, isValidParent, isVisible, remove, remove, removeAll, removePropertyChangeListener, setBackground, setEnabled, setFocusTraversalIndex, setFocusTraversalParticipant, setFont, setForeground, setId, setIndexedProperty, setLayoutData, setLayoutDirection, setLocale, setProperty, setRenderId, setStyle, setStyleName, setVisible, verifyInput, visibleIndexOf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_list

protected java.util.List<T> _list
The list of items.


_ctx

protected BindingContext _ctx
The binding context.

Constructor Detail

BoundTable

public BoundTable(java.util.List<T> list,
                  BindingContext ctx)
Creates a data bound table using a list.

Parameters:
list - the list of items
ctx - the binding context

BoundTable

public BoundTable(java.lang.String listAdapterId,
                  BindingContext ctx)
Creates a data bound table using a list adapter.

Parameters:
listAdapterId - the list adapter id
ctx - the binding context
Method Detail

init

public void init()
Overrides:
init in class nextapp.echo2.app.Component

addColumn

public BoundTable<T> addColumn(java.lang.String adapterId)
Adds a column for the specified adpater to the table.

Parameters:
adapterId - the adapter id
Returns:
the data bound table

removeColumn

public boolean removeColumn(java.lang.String adapterId)
Removes a column from the table.

Parameters:
adapterId - The adapter id of the column to be removed
Returns:
true, if the column was successfully removed, false else

addColumn

public BoundTable<T> addColumn(java.lang.Integer columnIndex,
                               java.lang.String adapterId)
Adds a column at the specified position to the table.

Parameters:
adapterId - the adapter id
columnIndex - the column index
Returns:
the data bound table

initialize

protected void initialize()
Initializes the table. Extracts the table headers from the binding context and creates the table data.


getTableHeaderRenderer

protected BoundTableHeaderRenderer getTableHeaderRenderer()
Gets the table header renderer.

Returns:
the table header renderer

getTableCellRenderer

protected nextapp.echo2.app.table.TableCellRenderer getTableCellRenderer()
Gets the table cell renderer.

Returns:
the table cell renderer

createTableModel

protected nextapp.echo2.app.table.TableModel createTableModel()
Creates the table model.

Returns:
the table model

createTableData

protected java.lang.Object[][] createTableData()
Creates the table data.

Returns:
the object[][]

createTableHeaderData

protected java.lang.Object[] createTableHeaderData()
Creates the table header data.

Returns:
the object[]

getAdapterId

public java.lang.String getAdapterId(int col)
Returns the adapter id for the specified column. The adapter id can be used in the TableCellRenderer to create data bound widgets.

Parameters:
col - the col
Returns:
the binding id for the given column index

getBindingContext

public BindingContext getBindingContext(int rowIndex)
Returns the binding context for the specified row. The binding id can be used in the TableCellRenderer to create data bound widgets.

Parameters:
rowIndex - the index of the row
Returns:
the binding context for the given row index

actionPerformed

public void actionPerformed(nextapp.echo2.app.event.ActionEvent event)
Specified by:
actionPerformed in interface nextapp.echo2.app.event.ActionListener

getActionListener

public nextapp.echo2.app.event.ActionListener getActionListener()
Returns the action listener.

Returns:
the action listener

setActionListener

public void setActionListener(nextapp.echo2.app.event.ActionListener actionListener)
Sets the action listener.

Parameters:
actionListener - the action listener

getItem

protected T getItem(int row)
Returns the item for the specified row index.

Parameters:
row - - the row index
Returns:
the item for the given row index

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener

getColumnAdapters

public java.util.List<PropertyAdapter> getColumnAdapters()
Returns the column adapters.

Returns:
Returns the property adapters for this table.

setColumnAdapters

public void setColumnAdapters(java.util.List<PropertyAdapter> columnAdapters)
Sets the column adapters.

Parameters:
columnAdapters - The column adapters to set.

getList

public java.util.List<T> getList()
Returns the list.

Returns:
Returns the list.

setList

public void setList(java.util.List<T> list)
Sets the list.

Parameters:
list - The list to set.

getHeaderBackground

public nextapp.echo2.app.Color getHeaderBackground()
Returns the header background color.

Returns:
the header background color

setHeaderBackground

public void setHeaderBackground(nextapp.echo2.app.Color headerBackground)
Sets the header background color.

Parameters:
headerBackground - the header background

showDetails

protected void showDetails(int columnIndex,
                           int rowIndex)
Parameters:
columnIndex -
rowIndex -

getDetailHandler

public DetailsHandler getDetailHandler()
Returns:
Returns the detailHandler.

setDetailHandler

public void setDetailHandler(DetailsHandler detailHandler)
Parameters:
detailHandler - The detailHandler to set.

getContext

public BindingContext getContext()
Returns:
Returns the ctx.

setContext

public void setContext(BindingContext ctx)
Parameters:
ctx - The ctx to set.


Copyright © 2007. All Rights Reserved.