dsto.dfc.swing.table
Class DefaultDfcTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by dsto.dfc.swing.table.AbstractDfcTableModel
          extended by dsto.dfc.swing.table.DefaultDfcTableModel
All Implemented Interfaces:
DfcTableModel, Copyable, Serializable, Cloneable, TableModel

public class DefaultDfcTableModel
extends AbstractDfcTableModel
implements DfcTableModel, Copyable, Serializable

Fully dynamic implementation of DfcTableModel backed by ArrayList's.

Version:
$Revision$
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
DefaultDfcTableModel()
           
DefaultDfcTableModel(TableModel model, int startRow, int endRow, int startColumn, int endColumn)
          Create a new table model from a rectangular section of an existing table.
 
Method Summary
 boolean canCopyCells(int startRow, int endRow, int startColumn, int endColumn)
          Test if a copyCells () operation is permitted.
 boolean canCopyRows(int startRow, int endRow)
           
 boolean canDeleteCells(int startRow, int endRow, int startColumn, int endColumn)
          Test if a deleteCells () operation is permitted.
 boolean canDeleteColumns(int startColumn, int endColumn)
          Test if a deleteColumns () operation is supported.
 boolean canDeleteRows(int startRow, int endRow)
          Test if a deleteRows () operation is supported.
 boolean canInsertColumn(int columnIndex, String columnName, Class columnClass)
          Test if an insertColumn () operation is supported.
 boolean canInsertRows(int startRow, int rowCount)
          Test if an insertRows () operation is supported.
 boolean canMoveRows(int startRow, int endRow, int newStartRow)
           
 boolean canPasteRows(Transferable transferable, int startRow)
          Should return true if rows may be pasted from a given Transferable at the given row.
 Object clone()
          Create a completely separate copy of this object and any mutable objects owned by the object.
 Transferable copyCells(int startRow, int endRow, int startColumn, int endColumn)
          Copy a rectangular block of cells into an AWT Transferable.
 Transferable copyRows(int startRow, int endRow)
           
 void deleteCells(int startRow, int endRow, int startColumn, int endColumn)
          Delete a rectangular block of cells.
 void deleteColumns(int startColumn, int endColumn)
          Delete columns.
 void deleteRows(int startRow, int endRow)
          Delete rows.
 Class getColumnClass(int columnIndex)
           
 int getColumnCount()
           
 String getColumnName(int columnIndex)
           
 int getRowCount()
           
 Object getValueAt(int rowIndex, int columnIndex)
           
 void insertColumn(int columnIndex, String columnName, Class columnClass)
          Insert a new column containing blank values.
 void insertRows(int startRow, int rowCount)
          Insert empty rows.
 boolean isCellEditable(int rowIndex, int columnIndex)
           
 boolean moveRows(int startRow, int endRow, int newStartRow)
           
 void pasteRows(Transferable transferable, int startRow)
           
 void setValueAt(Object value, int rowIndex, int columnIndex)
           
 
Methods inherited from class dsto.dfc.swing.table.AbstractDfcTableModel
canPasteCells, pasteCells
 
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
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface dsto.dfc.swing.table.DfcTableModel
canPasteCells, pasteCells
 
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, removeTableModelListener
 

Constructor Detail

DefaultDfcTableModel

public DefaultDfcTableModel()

DefaultDfcTableModel

public DefaultDfcTableModel(TableModel model,
                            int startRow,
                            int endRow,
                            int startColumn,
                            int endColumn)
                     throws CloneNotSupportedException
Create a new table model from a rectangular section of an existing table.

Throws:
CloneNotSupportedException
Method Detail

getRowCount

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

getColumnCount

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

getColumnName

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

getColumnClass

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

isCellEditable

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

getValueAt

public Object getValueAt(int rowIndex,
                         int columnIndex)
Specified by:
getValueAt in interface TableModel

setValueAt

public void setValueAt(Object value,
                       int rowIndex,
                       int columnIndex)
Specified by:
setValueAt in interface TableModel
Overrides:
setValueAt in class AbstractTableModel

insertRows

public void insertRows(int startRow,
                       int rowCount)
Description copied from interface: DfcTableModel
Insert empty rows.

Specified by:
insertRows in interface DfcTableModel
Overrides:
insertRows in class AbstractDfcTableModel
Parameters:
startRow - The row to begin inserting.
rowCount - The number of rows to insert.
See Also:
DfcTableModel.canInsertRows(int, int)

deleteRows

public void deleteRows(int startRow,
                       int endRow)
Description copied from interface: DfcTableModel
Delete rows.

Specified by:
deleteRows in interface DfcTableModel
Overrides:
deleteRows in class AbstractDfcTableModel
Parameters:
startRow - The row to begin inserting.
endRow - The last row to delete.
See Also:
DfcTableModel.canDeleteRows(int, int)

canInsertRows

public boolean canInsertRows(int startRow,
                             int rowCount)
Description copied from interface: DfcTableModel
Test if an insertRows () operation is supported.

Specified by:
canInsertRows in interface DfcTableModel
Overrides:
canInsertRows in class AbstractDfcTableModel
Parameters:
startRow - The row to begin inserting.
rowCount - The number of rows to insert.
Returns:
True if the insert is possible.

canDeleteRows

public boolean canDeleteRows(int startRow,
                             int endRow)
Description copied from interface: DfcTableModel
Test if a deleteRows () operation is supported.

Specified by:
canDeleteRows in interface DfcTableModel
Overrides:
canDeleteRows in class AbstractDfcTableModel
Parameters:
startRow - The row to begin inserting.
endRow - The last row to delete.
Returns:
True if the delete is possible.

canMoveRows

public boolean canMoveRows(int startRow,
                           int endRow,
                           int newStartRow)
Specified by:
canMoveRows in interface DfcTableModel
Overrides:
canMoveRows in class AbstractDfcTableModel

moveRows

public boolean moveRows(int startRow,
                        int endRow,
                        int newStartRow)
                 throws UnsupportedOperationException
Specified by:
moveRows in interface DfcTableModel
Overrides:
moveRows in class AbstractDfcTableModel
Throws:
UnsupportedOperationException

insertColumn

public void insertColumn(int columnIndex,
                         String columnName,
                         Class columnClass)
Description copied from interface: DfcTableModel
Insert a new column containing blank values.

Specified by:
insertColumn in interface DfcTableModel
Overrides:
insertColumn in class AbstractDfcTableModel
Parameters:
columnIndex - The index for the new column.
columnName - The name of the new column. May be null to indicate automatic name.
columnClass - The class of values in the column.
See Also:
DfcTableModel.canInsertColumn(int, java.lang.String, java.lang.Class)

deleteColumns

public void deleteColumns(int startColumn,
                          int endColumn)
Description copied from interface: DfcTableModel
Delete columns.

Specified by:
deleteColumns in interface DfcTableModel
Overrides:
deleteColumns in class AbstractDfcTableModel
Parameters:
startColumn - The index of the first column.
endColumn - The index of the last column.
See Also:
DfcTableModel.canDeleteColumns(int, int)

canInsertColumn

public boolean canInsertColumn(int columnIndex,
                               String columnName,
                               Class columnClass)
Description copied from interface: DfcTableModel
Test if an insertColumn () operation is supported.

Specified by:
canInsertColumn in interface DfcTableModel
Overrides:
canInsertColumn in class AbstractDfcTableModel
Parameters:
columnIndex - The index for the new column.
columnName - The name of the new column. May be null to indicate automatic name.
columnClass - The class of values in the column.
Returns:
True if the insert is possible.

canDeleteColumns

public boolean canDeleteColumns(int startColumn,
                                int endColumn)
Description copied from interface: DfcTableModel
Test if a deleteColumns () operation is supported.

Specified by:
canDeleteColumns in interface DfcTableModel
Overrides:
canDeleteColumns in class AbstractDfcTableModel
Parameters:
startColumn - The index of the first column.
endColumn - The index of the last column.
Returns:
True if the delete is possible.

canDeleteCells

public boolean canDeleteCells(int startRow,
                              int endRow,
                              int startColumn,
                              int endColumn)
Description copied from interface: DfcTableModel
Test if a deleteCells () operation is permitted.

Specified by:
canDeleteCells in interface DfcTableModel
Overrides:
canDeleteCells in class AbstractDfcTableModel
Parameters:
startRow - The first row to delete.
endRow - The last row to delete.
startColumn - The first column to delete.
endColumn - The last column to delete.
Returns:
True if the operation is permitted.

deleteCells

public void deleteCells(int startRow,
                        int endRow,
                        int startColumn,
                        int endColumn)
Description copied from interface: DfcTableModel
Delete a rectangular block of cells. The deleted cells should be reset to their default values.

Specified by:
deleteCells in interface DfcTableModel
Overrides:
deleteCells in class AbstractDfcTableModel
Parameters:
startRow - The first row to delete.
endRow - The last row to delete.
startColumn - The first column to delete.
endColumn - The last column to delete.
See Also:
DfcTableModel.canDeleteCells(int, int, int, int)

canCopyRows

public boolean canCopyRows(int startRow,
                           int endRow)
Specified by:
canCopyRows in interface DfcTableModel
Overrides:
canCopyRows in class AbstractDfcTableModel

copyRows

public Transferable copyRows(int startRow,
                             int endRow)
                      throws UnsupportedOperationException,
                             CloneNotSupportedException
Specified by:
copyRows in interface DfcTableModel
Overrides:
copyRows in class AbstractDfcTableModel
Throws:
UnsupportedOperationException
CloneNotSupportedException

canCopyCells

public boolean canCopyCells(int startRow,
                            int endRow,
                            int startColumn,
                            int endColumn)
Description copied from interface: DfcTableModel
Test if a copyCells () operation is permitted.

Specified by:
canCopyCells in interface DfcTableModel
Overrides:
canCopyCells in class AbstractDfcTableModel
Parameters:
startRow - The first row to copy.
endRow - The last row to copy.
startColumn - The first column to copy.
endColumn - The last column to copy.
Returns:
True if the operation is permitted.

copyCells

public Transferable copyCells(int startRow,
                              int endRow,
                              int startColumn,
                              int endColumn)
                       throws CloneNotSupportedException
Description copied from interface: DfcTableModel
Copy a rectangular block of cells into an AWT Transferable. The flavors supported by the transferable may include TableModelTransferable.TABLE_MODEL_FLAVOR but this is not required.

Specified by:
copyCells in interface DfcTableModel
Overrides:
copyCells in class AbstractDfcTableModel
Parameters:
startRow - The first row to copy.
endRow - The last row to copy.
startColumn - The first column to copy.
endColumn - The last column to copy.
Throws:
CloneNotSupportedException - if a data item could not be cloned.
See Also:
DfcTableModel.canCopyRows(int, int)

canPasteRows

public boolean canPasteRows(Transferable transferable,
                            int startRow)
Description copied from interface: DfcTableModel
Should return true if rows may be pasted from a given Transferable at the given row. Note that the data in the transferable may not be accessible at this time (eg during a drap and drop operation): calling getTransferData () will result in an IOException.

Specified by:
canPasteRows in interface DfcTableModel
Overrides:
canPasteRows in class AbstractDfcTableModel
Parameters:
transferable - The transferable.
startRow - The row to insert the transferable at.
Returns:
True if the transferable can be pasted at startRow.

pasteRows

public void pasteRows(Transferable transferable,
                      int startRow)
               throws UnsupportedOperationException,
                      UnsupportedFlavorException,
                      CloneNotSupportedException,
                      IOException
Specified by:
pasteRows in interface DfcTableModel
Overrides:
pasteRows in class AbstractDfcTableModel
Throws:
UnsupportedOperationException
UnsupportedFlavorException
CloneNotSupportedException
IOException

clone

public Object clone()
             throws CloneNotSupportedException
Description copied from interface: Copyable
Create a completely separate copy of this object and any mutable objects owned by the object.

NOTE: subclasses should not remove the CloneNotSupportedException throws clause if they themselves support subclassing: removing the CloneNotSupportedException declaration stops subclasses from indicating that a clone was not possible.

Specified by:
clone in interface Copyable
Overrides:
clone in class Object
Throws:
CloneNotSupportedException - if the clone failed or is not possible.


Copyright © 2008 Commonwealth of Australia