dsto.dfc.swing.table
Class ProxyTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by dsto.dfc.swing.table.AbstractDfcTableModel
          extended by dsto.dfc.swing.table.ProxyTableModel
All Implemented Interfaces:
DfcTableModel, Serializable, EventListener, TableModelListener, TableModel
Direct Known Subclasses:
SortedTableModel

public class ProxyTableModel
extends AbstractDfcTableModel
implements DfcTableModel, TableModelListener

Generic base class for a table model that act as a proxy for another table model. All calls are by default forwarded to the enclosed table model, events are forwarded out (but with the source changed to the proxy).

Version:
$Revision$
Author:
Matthew Phillips
See Also:
Serialized Form

Field Summary
protected  DfcTableModel model
           
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
ProxyTableModel(DfcTableModel model)
           
 
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 columnStart, int columnEnd)
          Test if a deleteColumns () operation is supported.
 boolean canDeleteRows(int rowStart, int rowEnd)
          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 rowStart, int rowEnd)
          Test if an insertRows () operation is supported.
 boolean canMoveRows(int startRow, int endRow, int newStartRow)
           
 boolean canPasteCells(Transferable transferable, int startRow, int endRow, int startColumn, int endColumn)
          Should return true if rows may be pasted from a given Transferable into a block of cells.
 boolean canPasteRows(Transferable transferable, int rowStart)
          Should return true if rows may be pasted from a given Transferable at the given row.
 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 columnStart, int columnEnd)
          Delete columns.
 void deleteRows(int rowStart, int rowEnd)
          Delete rows.
 int getColumnCount()
           
 String getColumnName(int column)
           
 int getRowCount()
           
 DfcTableModel getSubModel()
           
 Object getValueAt(int row, int col)
           
 void insertColumn(int columnIndex, String columnName, Class columnClass)
          Insert a new column containing blank values.
 void insertRows(int rowStart, int rowEnd)
          Insert empty rows.
 boolean isCellEditable(int rowIndex, int columnIndex)
           
 boolean moveRows(int startRow, int endRow, int newStartRow)
           
 void pasteCells(Transferable transferable, int startRow, int endRow, int startColumn, int endColumn)
           
 void pasteRows(Transferable transferable, int rowStart)
           
 void setValueAt(Object aValue, int rowIndex, int columnIndex)
           
 void tableChanged(TableModelEvent e)
           
 
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 javax.swing.table.TableModel
addTableModelListener, getColumnClass, removeTableModelListener
 

Field Detail

model

protected DfcTableModel model
Constructor Detail

ProxyTableModel

public ProxyTableModel(DfcTableModel model)
Method Detail

getSubModel

public DfcTableModel getSubModel()

getColumnCount

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

getValueAt

public Object getValueAt(int row,
                         int col)
Specified by:
getValueAt in interface TableModel

getRowCount

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

getColumnName

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

canMoveRows

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

canPasteRows

public boolean canPasteRows(Transferable transferable,
                            int rowStart)
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.
rowStart - The row to insert the transferable at.
Returns:
True if the transferable can be pasted at startRow.

deleteRows

public void deleteRows(int rowStart,
                       int rowEnd)
                throws UnsupportedOperationException
Description copied from interface: DfcTableModel
Delete rows.

Specified by:
deleteRows in interface DfcTableModel
Overrides:
deleteRows in class AbstractDfcTableModel
Parameters:
rowStart - The row to begin inserting.
rowEnd - The last row to delete.
Throws:
UnsupportedOperationException - if this is not supported.
See Also:
DfcTableModel.canDeleteRows(int, int)

deleteColumns

public void deleteColumns(int columnStart,
                          int columnEnd)
                   throws UnsupportedOperationException
Description copied from interface: DfcTableModel
Delete columns.

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

canCopyRows

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

canInsertRows

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

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

isCellEditable

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

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.

pasteCells

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

canDeleteRows

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

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

copyRows

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

copyCells

public Transferable copyCells(int startRow,
                              int endRow,
                              int startColumn,
                              int endColumn)
                       throws CloneNotSupportedException,
                              UnsupportedOperationException
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.
UnsupportedOperationException
See Also:
DfcTableModel.canCopyRows(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.

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

canDeleteColumns

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

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

canPasteCells

public boolean canPasteCells(Transferable transferable,
                             int startRow,
                             int endRow,
                             int startColumn,
                             int endColumn)
Description copied from interface: DfcTableModel
Should return true if rows may be pasted from a given Transferable into a block of cells. 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 in this case.

Specified by:
canPasteCells in interface DfcTableModel
Overrides:
canPasteCells 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.

setValueAt

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

pasteRows

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

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.

insertRows

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

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

deleteCells

public void deleteCells(int startRow,
                        int endRow,
                        int startColumn,
                        int endColumn)
                 throws UnsupportedOperationException
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.
Throws:
UnsupportedOperationException
See Also:
DfcTableModel.canDeleteCells(int, int, int, int)

insertColumn

public void insertColumn(int columnIndex,
                         String columnName,
                         Class columnClass)
                  throws UnsupportedOperationException
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.
Throws:
UnsupportedOperationException
See Also:
DfcTableModel.canInsertColumn(int, java.lang.String, java.lang.Class)

tableChanged

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


Copyright © 2008 Commonwealth of Australia