csheets.ui.sheet
Class SpreadsheetTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by csheets.ui.sheet.SpreadsheetTableModel
All Implemented Interfaces:
Serializable, TableModel

public class SpreadsheetTableModel
extends AbstractTableModel

An table model that provides a table with data from a spreadsheet.

Author:
Einar Pehrson
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
SpreadsheetTableModel(Spreadsheet spreadsheet, UIController uiController)
          Creates a spreadsheet table model.
 
Method Summary
 Class<?> getColumnClass(int column)
          Returns Cell.class for all columns.
 int getColumnCount()
           
 int getRowCount()
           
 Spreadsheet getSpreadsheet()
          Returns the spreadsheet that provides the data.
 Object getValueAt(int row, int column)
          Returns the cell at the given row and column in the spreadsheet.
 boolean isCellEditable(int row, int column)
          Overridden to allow editing of the table.
 void setValueAt(Object value, int row, int column)
          Implemented as a no-op, since the table's CellEditor instance updates the content of cells.
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnName, getListeners, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpreadsheetTableModel

public SpreadsheetTableModel(Spreadsheet spreadsheet,
                             UIController uiController)
Creates a spreadsheet table model.

Parameters:
spreadsheet - the spreadsheet that provides the data
uiController - the user interface controller
Method Detail

getColumnClass

public Class<?> getColumnClass(int column)
Returns Cell.class for all columns.

Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class AbstractTableModel
Parameters:
column - the column whose data type is requested
Returns:
Cell.class

getRowCount

public int getRowCount()

getColumnCount

public int getColumnCount()

getSpreadsheet

public Spreadsheet getSpreadsheet()
Returns the spreadsheet that provides the data.

Returns:
the spreadsheet that provides the data

getValueAt

public Object getValueAt(int row,
                         int column)
Returns the cell at the given row and column in the spreadsheet.

Parameters:
row - the row index of the cell being requested
column - the column index of the cell being requested
Returns:
the cell at the given address
See Also:
Spreadsheet.getCell(Address)

setValueAt

public void setValueAt(Object value,
                       int row,
                       int column)
Implemented as a no-op, since the table's CellEditor instance updates the content of cells.

Specified by:
setValueAt in interface TableModel
Overrides:
setValueAt in class AbstractTableModel
Parameters:
value - the value to set
row - the row index of the cell to change
column - the column index of the cell to change
See Also:
Cell.setContent(String)

isCellEditable

public boolean isCellEditable(int row,
                              int column)
Overridden to allow editing of the table.

Specified by:
isCellEditable in interface TableModel
Overrides:
isCellEditable in class AbstractTableModel
Parameters:
row - the row whose value is to be queried
column - the column whose value is to be queried
Returns:
true if the cell at the given row and column is editable