Holger's
Java API

com.antelmann.util.table
Class MovableTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by com.antelmann.util.table.MovableTableModel
All Implemented Interfaces:
Wrapped<TableModel>, Serializable, EventListener, TableModelListener, TableModel

public class MovableTableModel
extends AbstractTableModel
implements TableModelListener, Wrapped<TableModel>

a wrapper around a TableModel allowing to rearrange its rows. Note that this implementation is not synchronized.

Since:
6/2/06
Author:
Holger Antelmann
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
MovableTableModel(TableModel model)
          constructs a SortableTableModel with an embedded model
 
Method Summary
protected  void finalize()
          allows itself to be garbage collected by removing itself as a listener to the embedded model
 Class<?> getColumnClass(int column)
           
 int getColumnCount()
           
 String getColumnName(int column)
           
 TableModel getModel()
          returns the embedded model
 int getOriginalRow(int sortedRowPosition)
           
 int getRowCount()
           
 int getRowPosition(int originalRow)
           
 List<Integer> getSortingView()
          returns an unmodifiable view of the current sorting
 Object getValueAt(int row, int column)
           
 boolean isCellEditable(int row, int column)
           
 boolean moveDown(int row)
          moves the given row down by one.
 boolean moveUp(int row)
          moves the given row up by one.
 void resetOrder()
           
 void setValueAt(Object value, int row, int column)
           
 void tableChanged(TableModelEvent ev)
          public as an implementation side effect; resets the table to its updated embedded model
 TableModel unwrap()
          returns the embedded instance that this wrapper encloses
 
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
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MovableTableModel

public MovableTableModel(TableModel model)
constructs a SortableTableModel with an embedded model

Method Detail

finalize

protected void finalize()
allows itself to be garbage collected by removing itself as a listener to the embedded model

Overrides:
finalize in class Object

resetOrder

public void resetOrder()

moveDown

public boolean moveDown(int row)
moves the given row down by one. The call has no effect if the row is out of range or if the given row is the last.


moveUp

public boolean moveUp(int row)
moves the given row up by one. The call has no effect if the row is out of range or if the given row is the first.


tableChanged

public void tableChanged(TableModelEvent ev)
public as an implementation side effect; resets the table to its updated embedded model

Specified by:
tableChanged in interface TableModelListener

getModel

public TableModel getModel()
returns the embedded model


unwrap

public TableModel unwrap()
Description copied from interface: Wrapped
returns the embedded instance that this wrapper encloses

Specified by:
unwrap in interface Wrapped<TableModel>

getOriginalRow

public int getOriginalRow(int sortedRowPosition)

getRowPosition

public int getRowPosition(int originalRow)

getSortingView

public List<Integer> getSortingView()
returns an unmodifiable view of the current sorting


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 column)
Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class AbstractTableModel

getColumnClass

public Class<?> getColumnClass(int column)
Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class AbstractTableModel

isCellEditable

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

getValueAt

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

setValueAt

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


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads