JIDE 3.5.15

com.jidesoft.grid
Class AbstractUndoableTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by com.jidesoft.grid.AbstractUndoableTableModel
All Implemented Interfaces:
TableUndoableSupport, UndoableSupport, Serializable, TableModel

public abstract class AbstractUndoableTableModel
extends AbstractTableModel
implements TableUndoableSupport

Abstract undoable table model that extends AbstractTableModel.

Since:
3.3.4
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
AbstractUndoableTableModel()
          The Constructor.
 
Method Summary
 void beginCompoundEdit(boolean isUndoRedo)
          Begins the edit of the model.
 void endCompoundEdit()
          Ends the edit of the model.
 void fireTableChanged(TableModelEvent e)
           
 UndoableEditSupport getUndoableEditSupport()
          Gets the UndoableEditSupport instance to add UndoableListener.
 UndoManager getUndoManager()
          Gets the UndoManager.
abstract  boolean insertRowImpl(int rowIndex, Vector<Object> rowData)
          Inserts a row in this table model.
 boolean isCellEditable(int rowIndex, int columnIndex)
          Returns true.
abstract  boolean removeRowImpl(int rowIndex)
          Removes a row in this table model.
 void setValueAt(Object aValue, int rowIndex, int columnIndex)
          To support undoable, this method is made final.
 void undoableInsertRow(int rowIndex, Vector<Object> rowData)
          Inserts a row at the designated row index.
 void undoableRemoveRow(int rowIndex)
          Removes a row at the designated row index.
 void undoableUpdateCell(int rowIndex, int columnIndex, Object value)
          Updates a cell at the designated cell with the new cell data .
 void undoableUpdateRow(int rowIndex, Vector<Object> newRowData)
          Updates a row at the designated row index with the new row data .
abstract  boolean updateCellImpl(Object value, int rowIndex, int columnIndex)
          Updates a cell in this table model.
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getColumnName, 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
getColumnCount, getRowCount, getValueAt
 

Constructor Detail

AbstractUndoableTableModel

public AbstractUndoableTableModel()
The Constructor.

Method Detail

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
Returns true. This is the default implementation for all cells since it's an undoable model.

Specified by:
isCellEditable in interface TableModel
Overrides:
isCellEditable in class AbstractTableModel
Parameters:
rowIndex - the row being queried
columnIndex - the column being queried
Returns:
true by default.

setValueAt

public final void setValueAt(Object aValue,
                             int rowIndex,
                             int columnIndex)
To support undoable, this method is made final. Please use updateCellImpl(Object, int, int) to change the cell value without firing an event.

Specified by:
setValueAt in interface TableModel
Overrides:
setValueAt in class AbstractTableModel
Parameters:
aValue - value to assign to cell
rowIndex - row of cell
columnIndex - column of cell

fireTableChanged

public void fireTableChanged(TableModelEvent e)
Overrides:
fireTableChanged in class AbstractTableModel

getUndoManager

public UndoManager getUndoManager()
Description copied from interface: UndoableSupport
Gets the UndoManager.

Specified by:
getUndoManager in interface UndoableSupport
Returns:
the UndoManager.

getUndoableEditSupport

public UndoableEditSupport getUndoableEditSupport()
Description copied from interface: UndoableSupport
Gets the UndoableEditSupport instance to add UndoableListener.

Specified by:
getUndoableEditSupport in interface UndoableSupport
Returns:
the UndoableEditSupport instance.

beginCompoundEdit

public void beginCompoundEdit(boolean isUndoRedo)
Description copied from interface: UndoableSupport
Begins the edit of the model.

Specified by:
beginCompoundEdit in interface UndoableSupport
Parameters:
isUndoRedo - the flag to indicate if this operation is triggered by undo/redo

endCompoundEdit

public void endCompoundEdit()
Description copied from interface: UndoableSupport
Ends the edit of the model.

Specified by:
endCompoundEdit in interface UndoableSupport

undoableInsertRow

public void undoableInsertRow(int rowIndex,
                              Vector<Object> rowData)
Description copied from interface: TableUndoableSupport
Inserts a row at the designated row index.

Invoking this method will be able to insert a row, then adds an UndoableEdit or fires an event if necessary.

Specified by:
undoableInsertRow in interface TableUndoableSupport
Parameters:
rowIndex - the row index
rowData - the row data

undoableRemoveRow

public void undoableRemoveRow(int rowIndex)
Description copied from interface: TableUndoableSupport
Removes a row at the designated row index.

Invoking this method will be able to remove a row, then adds an UndoableEdit or fires an event if necessary.

Specified by:
undoableRemoveRow in interface TableUndoableSupport
Parameters:
rowIndex - the row index

undoableUpdateRow

public void undoableUpdateRow(int rowIndex,
                              Vector<Object> newRowData)
Description copied from interface: TableUndoableSupport
Updates a row at the designated row index with the new row data .

Invoking this method will be able to update a row, then adds an UndoableEdit or fires an event if necessary.

Specified by:
undoableUpdateRow in interface TableUndoableSupport
Parameters:
rowIndex - the row index
newRowData - the row data

undoableUpdateCell

public void undoableUpdateCell(int rowIndex,
                               int columnIndex,
                               Object value)
Description copied from interface: TableUndoableSupport
Updates a cell at the designated cell with the new cell data .

Invoking this method will be able to update a cell, then adds an UndoableEdit or fires an event if necessary.

Specified by:
undoableUpdateCell in interface TableUndoableSupport
Parameters:
rowIndex - the row index
columnIndex - the row index
value - the cell value

insertRowImpl

public abstract boolean insertRowImpl(int rowIndex,
                                      Vector<Object> rowData)
Inserts a row in this table model. Data operation only without any event being fired or any UndoableEdit being added.

Parameters:
rowIndex - the row index
rowData - the row data
Returns:
true if the implementation succeeds. Otherwise false.

removeRowImpl

public abstract boolean removeRowImpl(int rowIndex)
Removes a row in this table model. Data operation only without any event being fired or any UndoableEdit being added.

Parameters:
rowIndex - the row index
Returns:
true if the implementation succeeds. Otherwise false.

updateCellImpl

public abstract boolean updateCellImpl(Object value,
                                       int rowIndex,
                                       int columnIndex)
Updates a cell in this table model. Data operation only without any event being fired or any UndoableEdit being added.

Parameters:
value - the cell value
rowIndex - the row index
columnIndex - the row index
Returns:
true if the implementation succeeds. Otherwise false.

JIDE 3.5.15