Diamond Control Suite 3.0

diamondedge.swing.grid
Class DelegateGridModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by diamondedge.swing.grid.DelegateGridModel
All Implemented Interfaces:
GridModel, Serializable, EventListener, TableModelListener, TableModel

public class DelegateGridModel
extends AbstractTableModel
implements TableModelListener, GridModel

DelegateGridModel provides sorting and cell formatting for any TableModel. This is used internally to DsGrid.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Fields inherited from interface diamondedge.swing.grid.GridModel
DELETE_CELL
 
Constructor Summary
DelegateGridModel()
           
DelegateGridModel(TableModel model)
           
 
Method Summary
 void addColumn(Object columnName)
          Adds a column to the model.
 int convertRowIndexToModel(int row)
          Maps the index of the row in the view to the index of the row in the embedded table model.
 Class getColumnClass(int column)
           
 int getColumnCount()
           
 String getColumnName(int column)
           
 TableModel getModel()
           
 int getRowCount()
           
 Object getValueAt(int row, int column)
          Returns an attribute value for the cell at row and column.
 void insertRow(int row, Vector rowData)
          Inserts a row at row in the model.
 boolean isCellEditable(int row, int column)
           
 void removeRow(int row)
          Removes the row at row from the model.
 void setColumnCount(int val)
          Sets the number of columns in the model.
 void setModel(TableModel model)
           
 void setRowCount(int rowCount)
          Sets the number of rows in the model.
 void setValueAt(Object value, int row, int col)
          Sets the object value for the cell at column and row.
 void sort(int column, int sortOrder)
          Sorts the model by comparing values in the given column
 void tableChanged(TableModelEvent e)
           
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, removeTableModelListener
 

Constructor Detail

DelegateGridModel

public DelegateGridModel()

DelegateGridModel

public DelegateGridModel(TableModel model)
Method Detail

getModel

public TableModel getModel()

setModel

public void setModel(TableModel model)

convertRowIndexToModel

public int convertRowIndexToModel(int row)
Maps the index of the row in the view to the index of the row in the embedded table model.


tableChanged

public void tableChanged(TableModelEvent e)
Specified by:
tableChanged in interface TableModelListener

getColumnClass

public Class getColumnClass(int column)
Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class AbstractTableModel

getColumnCount

public int getColumnCount()
Specified by:
getColumnCount in interface TableModel

getColumnName

public String getColumnName(int column)
Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class AbstractTableModel

getRowCount

public int getRowCount()
Specified by:
getRowCount in interface TableModel

getValueAt

public Object getValueAt(int row,
                         int column)
Returns an attribute value for the cell at row and column. This call is not thread safe.

Specified by:
getValueAt in interface TableModel

setValueAt

public void setValueAt(Object value,
                       int row,
                       int col)
Sets the object value for the cell at column and row. This method will generate a tableChanged notification. This call is not thread safe.

Specified by:
setValueAt in interface TableModel
Overrides:
setValueAt in class AbstractTableModel

isCellEditable

public boolean isCellEditable(int row,
                              int column)
Specified by:
isCellEditable in interface TableModel
Overrides:
isCellEditable in class AbstractTableModel

setRowCount

public void setRowCount(int rowCount)
Description copied from interface: GridModel
Sets the number of rows in the model. If the new size is greater than the current size, new rows are added to the end of the model If the new size is less than the current size, all rows at index rowCount and greater are discarded.

Specified by:
setRowCount in interface GridModel

insertRow

public void insertRow(int row,
                      Vector rowData)
Description copied from interface: GridModel
Inserts a row at row in the model. The new row will contain null values unless rowData is specified. Notification of the row being added will be generated.

Specified by:
insertRow in interface GridModel
Parameters:
row - the row index of the row to be inserted
rowData - optional data of the row being added

removeRow

public void removeRow(int row)
Description copied from interface: GridModel
Removes the row at row from the model. Notification of the row being removed will be sent to all the listeners.

Specified by:
removeRow in interface GridModel
Parameters:
row - the row index of the row to be removed

setColumnCount

public void setColumnCount(int val)
Description copied from interface: GridModel
Sets the number of columns in the model. If the new size is greater than the current size, new columns are added to the end of the model with null cell values. If the new size is less than the current size, all columns at index columnCount and greater are discarded.

Specified by:
setColumnCount in interface GridModel
Parameters:
val - the new number of columns in the model
See Also:
GridModel.setColumnCount(int)

addColumn

public void addColumn(Object columnName)
Description copied from interface: GridModel
Adds a column to the model. The new column will have the identifier columnName, which may be null. This method will send a tableChanged notification message to all the listeners. This method is a cover for addColumn(Object, Vector) which uses null as the data vector.

Specified by:
addColumn in interface GridModel
Parameters:
columnName - the identifier of the column being added

sort

public void sort(int column,
                 int sortOrder)
Sorts the model by comparing values in the given column

Specified by:
sort in interface GridModel
Parameters:
column - column to be sorted
sortOrder - One of: DsGrid.ASCENDING, DsGrid.DESCENDING, DsGrid.ASCENDING_CASE, DsGrid.DESCENDING_CASE

Diamond Control Suite 3.0

Diamond Edge and Diamond Control Suite are trademarks or registered trademarks of Diamond Edge, Inc. Copyright 1999-2005 Diamond Edge, Inc. All Rights Reserved.