Diamond Control Suite 3.0

diamondedge.swing.grid
Class DefaultGridModel

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

public class DefaultGridModel
extends DefaultTableModel
implements GridModel

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.table.DefaultTableModel
columnIdentifiers, dataVector
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Fields inherited from interface diamondedge.swing.grid.GridModel
DELETE_CELL
 
Constructor Summary
DefaultGridModel()
          Constructs a default DefaultGridModel which is a table of zero columns and zero rows.
DefaultGridModel(int rowCount, int columnCount)
          Constructs a DefaultGridModel with rowCount and columnCount of null object values.
DefaultGridModel(Object[][] data, Object[] columnNames)
          Constructs a DefaultGridModel and initializes the table by passing data and columnNames to the setDataVector method.
DefaultGridModel(Object[] columnNames, int rowCount)
          Constructs a DefaultGridModel with as many columns as there are elements in columnNames and rowCount of null object values.
DefaultGridModel(Vector columnNames, int rowCount)
          Constructs a DefaultGridModel with as many columns as there are elements in columnNames and rowCount of null object values.
DefaultGridModel(Vector data, Vector columnNames)
          Constructs a DefaultGridModel and initializes the table by passing data and columnNames to the setDataVector method.
 
Method Summary
 String getColumnName(int column)
          Overriden to always return null.
 Object getValueAt(int row, int column)
          Returns an attribute value for the cell at row and column.
 boolean isCellEditable(int row, int column)
          Returns whether the cell can be edited by the user at run-time.
 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
 
Methods inherited from class javax.swing.table.DefaultTableModel
addColumn, addColumn, addColumn, addRow, addRow, convertToVector, convertToVector, getColumnCount, getDataVector, getRowCount, insertRow, insertRow, moveRow, newDataAvailable, newRowsAdded, removeRow, rowsRemoved, setColumnCount, setColumnIdentifiers, setColumnIdentifiers, setDataVector, setDataVector, setNumRows, setRowCount
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, 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 diamondedge.swing.grid.GridModel
addColumn, insertRow, removeRow, setColumnCount, setRowCount
 
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, getColumnClass, getColumnCount, getRowCount, removeTableModelListener
 

Constructor Detail

DefaultGridModel

public DefaultGridModel()
Constructs a default DefaultGridModel which is a table of zero columns and zero rows.


DefaultGridModel

public DefaultGridModel(int rowCount,
                        int columnCount)
Constructs a DefaultGridModel with rowCount and columnCount of null object values.

Parameters:
rowCount - the number of rows the table holds
columnCount - the number of columns the table holds
See Also:
setValueAt(java.lang.Object, int, int)

DefaultGridModel

public DefaultGridModel(Vector columnNames,
                        int rowCount)
Constructs a DefaultGridModel with as many columns as there are elements in columnNames and rowCount of null object values. Each column's name will be taken from the columnNames vector.

Parameters:
columnNames - vector containing the names of the new columns; if this is null then the model has no columns
rowCount - the number of rows the table holds

DefaultGridModel

public DefaultGridModel(Object[] columnNames,
                        int rowCount)
Constructs a DefaultGridModel with as many columns as there are elements in columnNames and rowCount of null object values. Each column's name will be taken from the columnNames array.

Parameters:
columnNames - array containing the names of the new columns; if this is null then the model has no columns
rowCount - the number of rows the table holds

DefaultGridModel

public DefaultGridModel(Vector data,
                        Vector columnNames)
Constructs a DefaultGridModel and initializes the table by passing data and columnNames to the setDataVector method.

Parameters:
data - the data of the table
columnNames - vector containing the names of the new columns

DefaultGridModel

public DefaultGridModel(Object[][] data,
                        Object[] columnNames)
Constructs a DefaultGridModel and initializes the table by passing data and columnNames to the setDataVector method. The first index in the Object[][] array is the row index and the second is the column index.

Parameters:
data - the data of the table
columnNames - the names of the columns
Method Detail

getColumnName

public String getColumnName(int column)
Overriden to always return null. This forces all column names to come from the column model which can be set by the user.

Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class DefaultTableModel

isCellEditable

public boolean isCellEditable(int row,
                              int column)
Returns whether the cell can be edited by the user at run-time.

Specified by:
isCellEditable in interface TableModel
Overrides:
isCellEditable in class DefaultTableModel
Parameters:
row - the row whose value is to be queried
column - the column whose value is to be queried
Returns:
true
See Also:
setValueAt(java.lang.Object, int, int)

getValueAt

public Object getValueAt(int row,
                         int column)
Returns an attribute value for the cell at row and column.

Specified by:
getValueAt in interface TableModel
Overrides:
getValueAt in class DefaultTableModel

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.

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

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.