com.sapportals.htmlb.table

Class DefaultTableViewModel

java.lang.Object
  extended bycom.sapportals.htmlb.table.DefaultTableViewModel
All Implemented Interfaces:
TableViewModel

public class DefaultTableViewModel
extends Object
implements TableViewModel

default implementation for Interface TableViewModel

Copyright 2004 SAP AG


Field Summary
protected  Vector columns
           
protected  Vector dataVector
           
protected  IndexedLinkedList keyColumn
           
protected  Vector visibleColumns
           
 
Constructor Summary
DefaultTableViewModel()
          constructs a empty table data model
DefaultTableViewModel(Object[] columnNames)
          constrcuts a DefaultTableViewModel without table data, only the table column names
DefaultTableViewModel(Object[][] data, Object[] columnNames)
          constructs a table data model with a data array and column names
DefaultTableViewModel(Object[][] data, Object[] columnNames, boolean columnAutoCreated)
          constructs a table data model with a data array and column names
DefaultTableViewModel(Vector columnNames)
          constructs a DefaultTableViewModel without table data, only columnNames
DefaultTableViewModel(Vector data, Vector columnNames)
          constructs a table data model with the data vector and the column names
DefaultTableViewModel(Vector data, Vector columnNames, boolean columnAutoCreated)
          constructs a table model with the data as a Vector and columnnames as a Vector. with the third boolean parameter columnAutoCreated, you can determine if the visible columns (for display) should be automatically created or not.
 
Method Summary
 TableColumn addColumn(String columnKey)
          adds a column which should be rendered.
 void addKeyColumn(int columnIndex)
          adds a key column
 TableColumn getColumn(String columnID)
          returns the column with the specified name
 TableColumn getColumnAt(int columnIndex)
          returns the column at columnIndex
 int getColumnCount()
          returns the number of visible columns in the table
 String getColumnName(int columnIndex)
          returns the name of the column at columnIndex
 Vector getColumns()
          returns the columns
 IndexedLinkedList getKeyColumn()
          returns the key column for the table
 int getRowCount()
          returns the number of rows in the model
 AbstractDataType getValueAt(int rowIndex, int columnIndex)
          returns the value at rowIndex and columnIndex
 AbstractDataType getValueAt(int rowIndex, String columnKey)
          returns the value at rowIndex and column with the name columnName
 void removeColumn(String columnKey)
          removes a column from the model
 void setColumnName(String columnName, int columnIndex)
          sets the name of a column
 void setColumnName(String columnName, String columnKey)
          sets the name of a column
 void setDataVector(Object[][] data, Object[] columnNames)
          sets the data vector of the table model
 void setDataVector(Object[][] data, Object[] columnNames, boolean columnAutoCreated)
          sets the data vector of the table model
 void setKeyColumn(int columnIndex)
          sets the key column for the table.
 void setValueAt(AbstractDataType aValue, int rowIndex, int columnIndex)
          sets the value at rowIndex and columnIndex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dataVector

protected Vector dataVector

columns

protected Vector columns

visibleColumns

protected Vector visibleColumns

keyColumn

protected IndexedLinkedList keyColumn
Constructor Detail

DefaultTableViewModel

public DefaultTableViewModel()
constructs a empty table data model


DefaultTableViewModel

public DefaultTableViewModel(Vector columnNames)
constructs a DefaultTableViewModel without table data, only columnNames

Parameters:
columnNames - the vector which contains the columnNames

DefaultTableViewModel

public DefaultTableViewModel(Vector data,
                             Vector columnNames)
constructs a table data model with the data vector and the column names

Parameters:
data - the vector which contains the data
columnNames - the vector which contains the columnNames

DefaultTableViewModel

public DefaultTableViewModel(Vector data,
                             Vector columnNames,
                             boolean columnAutoCreated)
constructs a table model with the data as a Vector and columnnames as a Vector. with the third boolean parameter columnAutoCreated, you can determine if the visible columns (for display) should be automatically created or not. If columnAutoCreated=true, all the available columns will be showed in the table. To hide a column, use the method @see #removeColumn(String columnKey). If the parameter columnAutoCreated = false, there will be no visible columns automatically created. To show a column, pls use the method @see #addColumn(String columnKey)

Parameters:
data - the vector which contains the data
columnNames - the vector which contains the columnNames
columnAutoCreated - a boolean variable which determins if the visible columns should be automatically created or not.

DefaultTableViewModel

public DefaultTableViewModel(Object[] columnNames)
constrcuts a DefaultTableViewModel without table data, only the table column names


DefaultTableViewModel

public DefaultTableViewModel(Object[][] data,
                             Object[] columnNames)
constructs a table data model with a data array and column names


DefaultTableViewModel

public DefaultTableViewModel(Object[][] data,
                             Object[] columnNames,
                             boolean columnAutoCreated)
constructs a table data model with a data array and column names

Method Detail

setDataVector

public void setDataVector(Object[][] data,
                          Object[] columnNames)
sets the data vector of the table model


setDataVector

public void setDataVector(Object[][] data,
                          Object[] columnNames,
                          boolean columnAutoCreated)
sets the data vector of the table model


getRowCount

public int getRowCount()
returns the number of rows in the model

Specified by:
getRowCount in interface TableViewModel
Returns:
the number of rows in the model
See Also:
TableViewModel.getColumnCount()

getColumnCount

public int getColumnCount()
returns the number of visible columns in the table

Specified by:
getColumnCount in interface TableViewModel
Returns:
the number of columns in the model
See Also:
TableViewModel.getRowCount()

getColumnName

public String getColumnName(int columnIndex)
returns the name of the column at columnIndex

Specified by:
getColumnName in interface TableViewModel
Parameters:
columnIndex - the index of the column
Returns:
the name of the column

setColumnName

public void setColumnName(String columnName,
                          int columnIndex)
sets the name of a column

Specified by:
setColumnName in interface TableViewModel

setColumnName

public void setColumnName(String columnName,
                          String columnKey)
sets the name of a column

Parameters:
columnName - the name which should be used for the specified column
columnKey - the key of the column which should be used to identify the column

getValueAt

public AbstractDataType getValueAt(int rowIndex,
                                   int columnIndex)
returns the value at rowIndex and columnIndex

Specified by:
getValueAt in interface TableViewModel
Parameters:
rowIndex - the row whose value is to be queried
columnIndex - the column whose value is to be queried
Returns:
the value Object at the specified cell

getValueAt

public AbstractDataType getValueAt(int rowIndex,
                                   String columnKey)
returns the value at rowIndex and column with the name columnName

Specified by:
getValueAt in interface TableViewModel
Parameters:
rowIndex - the row index
columnKey - the name of the column whose value is to be retrieved
Returns:
the value object at the specified cell

setValueAt

public void setValueAt(AbstractDataType aValue,
                       int rowIndex,
                       int columnIndex)
sets the value at rowIndex and columnIndex

Specified by:
setValueAt in interface TableViewModel
Parameters:
aValue - the value that the table cell at rowIndex and columNindex should have
rowIndex - the index of the row
columnIndex - the index of the column

getColumns

public Vector getColumns()
returns the columns

Specified by:
getColumns in interface TableViewModel
Returns:
visible columns of the table

getColumnAt

public TableColumn getColumnAt(int columnIndex)
returns the column at columnIndex

Specified by:
getColumnAt in interface TableViewModel
Parameters:
columnIndex - the index of the column
Returns:
the column at columnIndex
See Also:
TableColumn

getColumn

public TableColumn getColumn(String columnID)
returns the column with the specified name


setKeyColumn

public void setKeyColumn(int columnIndex)
sets the key column for the table.

Specified by:
setKeyColumn in interface TableViewModel
Parameters:
columnIndex - the index of the key column

addKeyColumn

public void addKeyColumn(int columnIndex)
adds a key column

Specified by:
addKeyColumn in interface TableViewModel
Parameters:
columnIndex - the index of the key column

addColumn

public TableColumn addColumn(String columnKey)
adds a column which should be rendered. The column will be added as an element in the vector columns in the table model

Specified by:
addColumn in interface TableViewModel
Parameters:
columnKey - the key of the column which should be used to identify a column

removeColumn

public void removeColumn(String columnKey)
removes a column from the model

Specified by:
removeColumn in interface TableViewModel
Parameters:
columnKey - the key of the column which should be used to identify a column

getKeyColumn

public IndexedLinkedList getKeyColumn()
returns the key column for the table

Specified by:
getKeyColumn in interface TableViewModel
Returns:
the key columns
See Also:
IndexedLinkedList


Copyright 2006 SAP AG Complete Copyright Notice