com.arsdigita.toolbox.ui
Class AbstractCollectionTable

java.lang.Object
  extended bycom.arsdigita.bebop.Completable
      extended bycom.arsdigita.bebop.SimpleComponent
          extended bycom.arsdigita.bebop.TextStylable
              extended bycom.arsdigita.bebop.BlockStylable
                  extended bycom.arsdigita.bebop.Table
                      extended bycom.arsdigita.toolbox.ui.AbstractCollectionTable
All Implemented Interfaces:
BebopConstants, Cloneable, Component, Lockable, PaginationModelBuilder

public abstract class AbstractCollectionTable
extends Table
implements PaginationModelBuilder

This provides a base table to show the elements of a DomainCollection

Version:
$Revision: #11 $ $Date: 2004/04/07 $
Author:
Randy Graebner

Nested Class Summary
 
Nested classes inherited from class com.arsdigita.bebop.Table
Table.MatrixTableModelBuilder
 
Field Summary
static String ASCENDING
           
static String DESCENDING
           
static String DIRECTION
           
 
Fields inherited from class com.arsdigita.bebop.Table
CELL_EVENT, EMPTY_MODEL, SEP, versionId
 
Fields inherited from class com.arsdigita.bebop.BlockStylable
ABSBOTTOM, ABSMIDDLE, BASELINE, BOTTOM, CENTER, FULL_WIDTH, INSERT, LEFT, MIDDLE, RIGHT, TEXTTOP, TOP
 
Fields inherited from class com.arsdigita.bebop.SimpleComponent
m_attr
 
Fields inherited from interface com.arsdigita.bebop.util.BebopConstants
BEBOP_BORDER, BEBOP_BOXPANEL, BEBOP_CELL, BEBOP_CHECKBOX, BEBOP_CHECKBOXGROUP, BEBOP_COLUMNPANEL, BEBOP_DATE, BEBOP_DATETIME, BEBOP_DHTMLEDITOR, BEBOP_FORMERRORS, BEBOP_FORMWIDGET, BEBOP_GRIDPANEL, BEBOP_LIST, BEBOP_MULTISELECT, BEBOP_OPTION, BEBOP_PAD, BEBOP_PADFRAME, BEBOP_PANELROW, BEBOP_PORTAL, BEBOP_PORTLET, BEBOP_RADIO, BEBOP_RADIOGROUP, BEBOP_SEG_BODY, BEBOP_SEG_HEADER, BEBOP_SEG_PANEL, BEBOP_SEGMENT, BEBOP_SELECT, BEBOP_TABLE, BEBOP_TABLEBODY, BEBOP_TABLEROW, BEBOP_TEXTAREA
 
Fields inherited from interface com.arsdigita.bebop.Component
BEBOP_XML_NS, CLASS, ID, ON_CLICK, STYLE
 
Constructor Summary
AbstractCollectionTable(RequestLocal collection)
          This expects to receive a RequestLocal that will return the appropriate DomainCollection to be displayed
 
Method Summary
protected  TableColumn addColumn(String label, String attribute, boolean isSortable, String type)
          This adds the column to the table use the default table cell renderer
protected  TableColumn addColumn(String label, String attribute, boolean isSortable, TableCellRenderer renderer, String type)
          This adds the column to the table.
 void generateExtraXMLAttributes(PageState state, Element element)
          Adds type-specific XML attributes to the XML element representing this link.
protected  String getColumnType(int index)
           
 String getDefaultOrder()
          Get the key of the default column which will be used to sort the entries
 DomainCollection getDomainCollection(PageState state)
          This returns the collection that is displayed by this table.
 String getOrderDirection(PageState s)
           
 BigDecimal getSelectedTask(PageState ps)
           
 int getTotalSize(Paginator paginator, PageState s)
          Paginate the query according to the paginator component.
protected abstract  TableModel makeTableModel(PageState ps)
          This method should return the table model to use.
 void register(Page p)
          Register the ordering parameter
 void setDefaultOrder(String attribute)
          Set the key of the default column which will be used to sort the entries.
 void setDefaultOrderDirection(String direction)
          The default sort order
 void setOrderDirection(PageState s, String dir)
          Set the sort direction
protected  void tableCellSelected(PageState ps, Object key, int index)
           
protected  void tableHeadSelected(PageState ps, int index)
           
 String toggleOrderDirection(PageState s)
          Toggle the sort direction between ascending and descending
 
Methods inherited from class com.arsdigita.bebop.Table
addTableActionListener, children, clearSelection, createTableActionListener, fireCellSelected, fireHeadSelected, generateXML, getBorder, getCellPadding, getCellSpacing, getColumn, getColumnModel, getColumnSelectionModel, getControler, getDefaultCellRenderer, getEmptyView, getHeader, getModelBuilder, getRowSelectionModel, getStriped, getTableModel, getWidth, isSelectedCell, isSelectedColumn, isSelectedRow, lock, removeTableActionListener, respond, setBorder, setCellPadding, setCellSpacing, setColumn, setColumnModel, setColumnSelectionModel, setDefaultCellRenderer, setEmptyView, setHeader, setModelBuilder, setRowSelectionModel, setStriped, setWidth
 
Methods inherited from class com.arsdigita.bebop.BlockStylable
setBorder, setBorder, setBorderColor, setHorizontalAlignment, setMargin, setMargin, setPadding, setPadding, setVerticalAlignment
 
Methods inherited from class com.arsdigita.bebop.TextStylable
setBackgroundColor, setColor
 
Methods inherited from class com.arsdigita.bebop.SimpleComponent
clone, exportAttributes, getAttribute, getClassAttr, getIdAttr, getKey, getMetaDataAttribute, getStyleAttr, hasAttributes, isLocked, isVisible, register, setAttribute, setClassAttr, setIdAttr, setKey, setMetaDataAttribute, setStyleAttr, setVisible
 
Methods inherited from class com.arsdigita.bebop.Completable
addCompletionListener, fireCompletionEvent
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.arsdigita.bebop.PaginationModelBuilder
isVisible
 

Field Detail

DIRECTION

public static final String DIRECTION
See Also:
Constant Field Values

ASCENDING

public static final String ASCENDING
See Also:
Constant Field Values

DESCENDING

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

AbstractCollectionTable

public AbstractCollectionTable(RequestLocal collection)
This expects to receive a RequestLocal that will return the appropriate DomainCollection to be displayed

Method Detail

register

public void register(Page p)
Register the ordering parameter

Specified by:
register in interface Component
Overrides:
register in class Table
Parameters:
p - the page that contains this table

setDefaultOrderDirection

public void setDefaultOrderDirection(String direction)
The default sort order

Parameters:
direction - The direction (either ASCENDING or DESCENDING)

getOrderDirection

public String getOrderDirection(PageState s)
Parameters:
s - the page state
Returns:
the order by which the currently selected column will be sorted; will be either ASCENDING or DESCENDING

setOrderDirection

public void setOrderDirection(PageState s,
                              String dir)
Set the sort direction

Parameters:
s - the page state
dir - the direction in which the current column should be sorted; either ASCENDING or DESCENDING

toggleOrderDirection

public String toggleOrderDirection(PageState s)
Toggle the sort direction between ascending and descending

Parameters:
s - the page state
Returns:
the new order direction; will be either ASCENDING or DESCENDING

setDefaultOrder

public void setDefaultOrder(String attribute)
Set the key of the default column which will be used to sort the entries. This requires that the passed in attribute is an attribute that has already been used for an added column.

Parameters:
attribute - the default attribute to sort by

getDefaultOrder

public String getDefaultOrder()
Get the key of the default column which will be used to sort the entries

Returns:
the default attribute to sort by, or null if no default has been set

addColumn

protected TableColumn addColumn(String label,
                                String attribute,
                                boolean isSortable,
                                String type)
This adds the column to the table use the default table cell renderer


addColumn

protected TableColumn addColumn(String label,
                                String attribute,
                                boolean isSortable,
                                TableCellRenderer renderer,
                                String type)
This adds the column to the table.

Parameters:
label - The label for the header of the column
attribute - The corresponding attribute in the table
renderer - The cell renderer to use to display the column
type - The type of the column so that we can later look up the index of the column

getSelectedTask

public BigDecimal getSelectedTask(PageState ps)

tableCellSelected

protected void tableCellSelected(PageState ps,
                                 Object key,
                                 int index)

tableHeadSelected

protected void tableHeadSelected(PageState ps,
                                 int index)

getTotalSize

public int getTotalSize(Paginator paginator,
                        PageState s)
Paginate the query according to the paginator component. This method will be automatically called by the Paginator component to which this DataTable has been added as the model builder.

Specified by:
getTotalSize in interface PaginationModelBuilder
Parameters:
paginator - the parent Paginator
s - the current page state
Returns:
the total number of rows in the query

getDomainCollection

public DomainCollection getDomainCollection(PageState state)
This returns the collection that is displayed by this table.


getColumnType

protected String getColumnType(int index)
Parameters:
index - This is the index to look up
Returns:
this returns the string type that was passed in when the column was created

makeTableModel

protected abstract TableModel makeTableModel(PageState ps)
This method should return the table model to use. In most cases, you are going to just want to iterate through your DomianCollection, returning the correctly values in getElementAt


generateExtraXMLAttributes

public void generateExtraXMLAttributes(PageState state,
                                       Element element)
Description copied from class: Table
Adds type-specific XML attributes to the XML element representing this link. Subclasses should override this method if they introduce more attributes than the ones generateXML produces by default.

Overrides:
generateExtraXMLAttributes in class Table
Parameters:
state - represents the current request
element - the XML element representing this table


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