wt.clients.beans.table
Class WTTableModel

java.lang.Object
  extended bywt.clients.beans.table.WTTableModel
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
WfWorkListModel

public class WTTableModel
extends Object
implements Serializable

This model manage all the informations to construct a table. This table would be created by using a subset of attributes that the model is managing.

See Also:
Serialized Form

Nested Class Summary
 class WTTableModel.GroupTableModel
          Provide a table model compatible with Swing that display the data based on the filtering, grouping and sorting parameters set in the WTTableModel.
 class WTTableModel.GroupTreeModel
           
 class WTTableModel.TableRowModel
          The table row model provide a table view of the data used for the grouping mechanism.
 
Field Summary
protected  Hashtable columnHashtable
          List all the column description
protected  Hashtable dataHashtable
          List all the item available
protected  Vector filterVector
          Vector that keep track of the filtering criteria
protected  Vector groupByVector
          Vector that keep track of the attributes that should be used for grouping
protected  WTTableModel.GroupTableModel groupTableModel
          Model of the table presenting the filtered and grouped items
protected  WTTableModel.GroupTreeModel groupTreeModel
          Model of the table presenting the different value of attributes used for grouping.
protected  Vector itemDisplayed
          List of item that should be displayed.
private  String itemIdentifier
          Identifier used to discriminate the key of an item
private static ResourceBundle rb
           
private static String RESOURCE
          Resources for localizing message text
protected  Vector sortByVector
          Vector that keep track of the attributes that should be used for sorting
protected  WTTableModel.TableRowModel tableRowModel
          Model of the tree presenting the different value of attributes used for grouping.
private static boolean VERBOSE
          Used for debugging
 
Constructor Summary
WTTableModel()
          Construct a new Table Model.
WTTableModel(String pItemIdentifier)
          Construct a new Table Model
 
Method Summary
 void addColumnDescription(String pColumnKey, TableColumn pTableColumn)
          Add a column description to the hashtable.
 void addColumnDescription(TableColumn pTableColumn)
          Add a column description to the hashtable using the identifier for the column as the key.
 void addDisplayColumn(String pColumnKey)
          Add a column to the list of column that should be displayed.
 void addDisplayColumns(Vector pColumnKeyList)
          Add a list column to the list of columns that should be displayed.
 void addItem(Hashtable pItem)
          Add an item to the list of items for the model.
 Enumeration allColumnDescription()
          Answer all the column descriptions available in the model
 Enumeration allColumnDescriptionKey()
          Answer all the column description keys available in the model
 boolean columnInFilter(String pColumnKey)
          Check if pColumnKey is a column used for filtering
 boolean columnInGroup(String pColumnKey)
          Check if pColumnKey is a column used for grouping
 boolean columnInSort(String pColumnKey)
          Check if pColumnKey is a column used for sorting
 boolean columnIsDisplayed(String pColumnKey)
          Check if pColumnKey is displayed
 Enumeration getAttributeList()
          Answer the list of all the item currently displayed
 TableColumn getColumnDescription(String pColumnKey)
          Answer the column description associated to the specified key.
 Vector getFilter()
          Answer the set of filter criteria used for the current model.
 Vector getGroupBy()
          Answer the list of attributes used for grouping
 WTTableModel.GroupTableModel getGroupTableModel()
          Answer a table model that contains the items matching the filter and group criteria.
 TreeModel getGroupTreeModel()
          Answer a tree model representing all the items that match the filter criteria.
 String getItemIdentifier()
          Answer the attribute key used for discriminating the items.
 String getItemIdentifierValueAt(int row)
          Retrieve the value of the item identifier for the specified row.
The number of row is based on the displayed list.
 Vector getSortBy()
          Answer the list of attributes used in the sorting mechanism of the current model.
 WTTableModel.TableRowModel getTableRowModel()
          Answer a table model where the columns are the one specified for grouping
private  boolean matchFilter(Hashtable pItem)
          Evaluate the item to know if it should be used for the tree.
 void refreshModel()
          Regenerate the different model and warned the different listener who have subscribed to the different model.
 void removeAllDisplayColumns()
          Remove all the columns from the list of column that should be displayed.
 void removeColumnDescription(String pColumnKey)
          Remove the column description associated to the key from the column list.
 void removeColumnFromFilter(String pColumnKey)
          Remove pColumnKey from the group of column that should be used for filtering.
 void removeColumnFromGroup(String pColumnKey)
          Remove pColumnKey from the group of column that should be used for grouping.
 void removeColumnFromSort(String pColumnKey)
          Remove pColumnKey from the sort of column that should be used for sorting.
 void removeDisplayColumn(String pColumnKey)
          Remove a column to the list of column that should be displayed.
 void removeDisplayColumn(TableColumn pColumn)
          Remove a column to the list of column that should be displayed.
 void removeItem(Hashtable pItem)
          Remove the item from the model.
 void removeItem(String pItemKey)
          Remove the item with specified key from the model.
 void setDisplayColumns(String[] pColumns)
          Set the columns that should be displayed in the system.
 void setDisplayColumns(Vector pColumns)
          Remove the previous column available and replace with the new set of column specified in pColumns.
 void setFilter(Vector pFilterVector)
          Set the filtering mechanism using an ordered list of filter criteria
 void setGroupBy(Vector pGroupByVector)
          Set the Grouping for the current model.
 void setItemIdentifier(String pItemIdentifier)
          Set the attribute key that would be used for discrimating an item.
private  void setItemIdentifier(String pItemIdentifier, boolean bRefreshRequired)
          Set the attribute key that would be used for discrimating an item.
 void setSortBy(Vector pSortByVector)
          Set the column used for sorting the attributes.
private  void validateColumnExistence(String pColumnKey)
          Validate if a column in the model have its key equal to pColumnKey.
private  void validateColumnExistence(TableColumn pColumn)
          Validate if pColumn exists in the model.
private  void validateColumnListExistence(Enumeration pColumnKeyEnumeration)
          Validate that the set of column provided exist in the model.
private  void validateFilter(Vector pFilterVector)
          Validate the filter pFilterVector.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

itemIdentifier

private String itemIdentifier
Identifier used to discriminate the key of an item


groupByVector

protected Vector groupByVector
Vector that keep track of the attributes that should be used for grouping


sortByVector

protected Vector sortByVector
Vector that keep track of the attributes that should be used for sorting


filterVector

protected Vector filterVector
Vector that keep track of the filtering criteria


itemDisplayed

protected Vector itemDisplayed
List of item that should be displayed. This list is ordered based on the filtering, grouping and sorting options.


groupTableModel

protected WTTableModel.GroupTableModel groupTableModel
Model of the table presenting the filtered and grouped items


tableRowModel

protected WTTableModel.TableRowModel tableRowModel
Model of the tree presenting the different value of attributes used for grouping. Leafs of the tree are item identifiers


groupTreeModel

protected WTTableModel.GroupTreeModel groupTreeModel
Model of the table presenting the different value of attributes used for grouping. The last column is the item identifier.


columnHashtable

protected Hashtable columnHashtable
List all the column description


dataHashtable

protected Hashtable dataHashtable
List all the item available


RESOURCE

private static final String RESOURCE
Resources for localizing message text

See Also:
Constant Field Values

rb

private static ResourceBundle rb

VERBOSE

private static boolean VERBOSE
Used for debugging

Constructor Detail

WTTableModel

public WTTableModel()
Construct a new Table Model. This operation is designed for IDE.
You MUST set an identifier before using an instance created by that operation.

See Also:
setItemIdentifier()

WTTableModel

public WTTableModel(String pItemIdentifier)
Construct a new Table Model

Method Detail

refreshModel

public void refreshModel()
Regenerate the different model and warned the different listener who have subscribed to the different model.


setItemIdentifier

private void setItemIdentifier(String pItemIdentifier,
                               boolean bRefreshRequired)
Set the attribute key that would be used for discrimating an item. Only called by the constructor.

Parameters:
pItemIdentifier - the attribute key

setItemIdentifier

public void setItemIdentifier(String pItemIdentifier)
Set the attribute key that would be used for discrimating an item.

Parameters:
pItemIdentifier - the attribute key

getItemIdentifier

public String getItemIdentifier()
Answer the attribute key used for discriminating the items.

Returns:
String the attribute key

addColumnDescription

public void addColumnDescription(TableColumn pTableColumn)
Add a column description to the hashtable using the identifier for the column as the key.

Parameters:
pTableColumn -
See Also:
TableColumn.getIdentifier()

addColumnDescription

public void addColumnDescription(String pColumnKey,
                                 TableColumn pTableColumn)
Add a column description to the hashtable.

Parameters:
pColumnKey -
pTableColumn -

getColumnDescription

public TableColumn getColumnDescription(String pColumnKey)
Answer the column description associated to the specified key.

Parameters:
pColumnKey -
Returns:
TableColumn

removeColumnDescription

public void removeColumnDescription(String pColumnKey)
                             throws PropertyVetoException
Remove the column description associated to the key from the column list.

Parameters:
pColumnKey - the key of the column that should be removed.
Throws:
PropertyVetoException - if pColumnKey is not a valid key.

allColumnDescription

public Enumeration allColumnDescription()
Answer all the column descriptions available in the model

Returns:
Enumeration an Enumeration of all the TableColumn available

allColumnDescriptionKey

public Enumeration allColumnDescriptionKey()
Answer all the column description keys available in the model

Returns:
Enumeration an Enumeration of keys from the column description available

validateColumnListExistence

private void validateColumnListExistence(Enumeration pColumnKeyEnumeration)
                                  throws PropertyVetoException
Validate that the set of column provided exist in the model. Each key is verified individually.

Parameters:
pColumnKeyEnumeration - an enumeration of columns key
Throws:
PropertyVetoException - if one of the column does not exist

validateColumnExistence

private void validateColumnExistence(String pColumnKey)
                              throws PropertyVetoException
Validate if a column in the model have its key equal to pColumnKey.

Parameters:
pColumnKey - the key of the column
Throws:
PropertyVetoException - if the column does not exist

validateColumnExistence

private void validateColumnExistence(TableColumn pColumn)
                              throws PropertyVetoException
Validate if pColumn exists in the model.

Parameters:
pColumn - the column to be tested
Throws:
PropertyVetoException - if the column does not exist

setGroupBy

public void setGroupBy(Vector pGroupByVector)
                throws PropertyVetoException
Set the Grouping for the current model. The command is expecting an ordered list of valid attribute key.

Parameters:
pGroupByVector - the ordered set of attributes used for grouping
Throws:
PropertyVetoException - if one column specified doesn't exist

getGroupBy

public Vector getGroupBy()
Answer the list of attributes used for grouping

Returns:
Vector a vector of attributes

columnInGroup

public boolean columnInGroup(String pColumnKey)
                      throws PropertyVetoException
Check if pColumnKey is a column used for grouping

Parameters:
pColumnKey - the key of the column that should be tested
Returns:
boolean true if the column is used in the current group criteria,
Throws:
PrpertyVetoException - if pColumnKey is not a valid key.
PropertyVetoException

removeColumnFromGroup

public void removeColumnFromGroup(String pColumnKey)
                           throws PropertyVetoException
Remove pColumnKey from the group of column that should be used for grouping.

Parameters:
pColumnKey - the column to remove from the group
Throws:
PropertyVetoException - if pColumnKey is not a valid key.

setSortBy

public void setSortBy(Vector pSortByVector)
               throws PropertyVetoException
Set the column used for sorting the attributes. The method is expecting an ordered list of valid attributes key.

Parameters:
pSortByVector - the ordered list of key attributes used for sorting
Throws:
PropertyVetoException - if one column specified doesn't exist

getSortBy

public Vector getSortBy()
Answer the list of attributes used in the sorting mechanism of the current model.

Returns:
Vector an ordered list of attributes key

columnInSort

public boolean columnInSort(String pColumnKey)
                     throws PropertyVetoException
Check if pColumnKey is a column used for sorting

Parameters:
pColumnKey - the key of the column that should be tested
Returns:
boolean true if the column is used in the current sort criteria,
Throws:
PrpertyVetoException - if pColumnKey is not a valid key.
PropertyVetoException

removeColumnFromSort

public void removeColumnFromSort(String pColumnKey)
                          throws PropertyVetoException
Remove pColumnKey from the sort of column that should be used for sorting.

Parameters:
pColumnKey - the column to remove from the sort
Throws:
PropertyVetoException - if pColumnKey is not a valid key.

setFilter

public void setFilter(Vector pFilterVector)
               throws PropertyVetoException
Set the filtering mechanism using an ordered list of filter criteria

Parameters:
pFilterVector - the ordered list of filter
Throws:
PropertyVetoExecption - if the filter is not valid for this model
PropertyVetoException

getFilter

public Vector getFilter()
Answer the set of filter criteria used for the current model.

Returns:
Vector the set of filter criteria

columnInFilter

public boolean columnInFilter(String pColumnKey)
                       throws PropertyVetoException
Check if pColumnKey is a column used for filtering

Parameters:
pColumnKey - the key of the column that should be tested
Returns:
boolean true if the column is used in the current filter,
Throws:
PropertyVetoException - if pColumnKey is not a valid key.

removeColumnFromFilter

public void removeColumnFromFilter(String pColumnKey)
                            throws PropertyVetoException
Remove pColumnKey from the group of column that should be used for filtering.

Parameters:
pColumnKey - the column to remove from the filter
Throws:
PropertyVetoException - if pColumnKey is not a valid key.

validateFilter

private void validateFilter(Vector pFilterVector)
                     throws PropertyVetoException
Validate the filter pFilterVector.

Parameters:
pFilterVector - the filter vector to be checked
Throws:
PropertyVetoException - if the filter is not valid.

matchFilter

private boolean matchFilter(Hashtable pItem)
Evaluate the item to know if it should be used for the tree. Tests would be made using the filter option set for the model

Parameters:
pItem - the item that has to be tested
Returns:
boolean true if the item matchs the filter criterias
See Also:
#setFilter()

addItem

public void addItem(Hashtable pItem)
             throws PropertyVetoException
Add an item to the list of items for the model.

Parameters:
pItem - hashtable of value with the key as the hashcode of the data
Throws:
PropertyVetoException - if the item does not contain the identifier key
PropertyVetoException - if the identifier already exists

removeItem

public void removeItem(String pItemKey)
Remove the item with specified key from the model.

Parameters:
pItemKey - key of the item to remove from the model

removeItem

public void removeItem(Hashtable pItem)
Remove the item from the model. The key should be in the hashtable for being able to be removed.

Parameters:
pItem - item to remove from the model

getItemIdentifierValueAt

public String getItemIdentifierValueAt(int row)
Retrieve the value of the item identifier for the specified row.
The number of row is based on the displayed list.

Returns:
String the item identifier of the specified row
Throws:
See Also:
itemIdentifier

getAttributeList

public Enumeration getAttributeList()
Answer the list of all the item currently displayed

Returns:
Enumeration

getGroupTableModel

public WTTableModel.GroupTableModel getGroupTableModel()
Answer a table model that contains the items matching the filter and group criteria. The order is based on the group criteria. The columns of the table are the one added as display columns.

Returns:
GroupTableModel the table model
See Also:
#addDisplayColumns(), #addDisplayColumn()

getTableRowModel

public WTTableModel.TableRowModel getTableRowModel()
Answer a table model where the columns are the one specified for grouping

Returns:
TableRowModel the table model
See Also:
#setGroupBy()

getGroupTreeModel

public TreeModel getGroupTreeModel()
Answer a tree model representing all the items that match the filter criteria. The hierarchy is based on the grouping option.

Returns:
TreeModel the tree model of the table
See Also:
#setGroupBy(), #setFilter()

addDisplayColumns

public void addDisplayColumns(Vector pColumnKeyList)
                       throws PropertyVetoException
Add a list column to the list of columns that should be displayed.

Parameters:
pColumnKeyList - the list of keys of the column to be displayed
Throws:
PropertyVetoException - if one key does not match with any defined column

addDisplayColumn

public void addDisplayColumn(String pColumnKey)
                      throws PropertyVetoException
Add a column to the list of column that should be displayed.

Parameters:
pColumnKey - the key of the column to be displayed
Throws:
PropertyVetoException - if the key does not match with any defined column

removeDisplayColumn

public void removeDisplayColumn(String pColumnKey)
                         throws PropertyVetoException
Remove a column to the list of column that should be displayed.

Parameters:
pColumnKey - the key of the column to be removed from the display
Throws:
PropertyVetoException - if the key does not match with any defined column

removeDisplayColumn

public void removeDisplayColumn(TableColumn pColumn)
                         throws PropertyVetoException
Remove a column to the list of column that should be displayed.

Parameters:
pColumn - the column to be removed from the display
Throws:
PropertyVetoException - if the column does not exist in the model

removeAllDisplayColumns

public void removeAllDisplayColumns()
Remove all the columns from the list of column that should be displayed.


setDisplayColumns

public void setDisplayColumns(Vector pColumns)
                       throws PropertyVetoException
Remove the previous column available and replace with the new set of column specified in pColumns.

Parameters:
pColumns - the new set of columns that should be used for the display
Throws:
PropertyVetoException - if one of the column specified doesn't exist

setDisplayColumns

public void setDisplayColumns(String[] pColumns)
                       throws PropertyVetoException
Set the columns that should be displayed in the system.

Parameters:
pColumns - array of column key
Throws:
PropertyVetoException - if one of the columns specified doesn't exist

columnIsDisplayed

public boolean columnIsDisplayed(String pColumnKey)
                          throws PropertyVetoException
Check if pColumnKey is displayed

Parameters:
pColumnKey - the key of the column that should be tested
Returns:
boolean true if the column is currently displayed
Throws:
PropertyVetoException - if pColumnKey is not a valid key.