Package adams.gui.core
Class AbstractMoveableTableModel
- java.lang.Object
-
- javax.swing.table.AbstractTableModel
-
- adams.gui.core.AbstractBaseTableModel
-
- adams.gui.core.AbstractMoveableTableModel
-
- All Implemented Interfaces:
LoggingLevelHandler
,LoggingSupporter
,SpreadSheetSupporter
,MoveableTableModel
,Serializable
,TableModel
- Direct Known Subclasses:
DataTableModel
,FlowSetupTableModel
public abstract class AbstractMoveableTableModel extends AbstractBaseTableModel implements MoveableTableModel
Abstract table model that allows rows to be moved around.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
MoveableTableModel
, Serialized Form
-
-
Field Summary
-
Fields inherited from class adams.gui.core.AbstractBaseTableModel
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
-
-
Constructor Summary
Constructors Constructor Description AbstractMoveableTableModel()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
canMoveDown(int[] indices)
checks whether the selected items can be moved down.boolean
canMoveUp(int[] indices)
checks whether the selected items can be moved up.int[]
moveBottom(int[] indices)
moves the selected items to the end.int[]
moveDown(int[] indices)
moves the selected items down by 1.protected int[]
moveItems(int[] indices, int moveby, boolean up)
moves the selected items by a certain amount of items in a given direction.int[]
moveTop(int[] indices)
moves the selected items to the top.int[]
moveUp(int[] indices)
moves the selected items up by 1.protected abstract void
swap(int firstIndex, int secondIndex)
Swaps the two rows.-
Methods inherited from class adams.gui.core.AbstractBaseTableModel
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, setLoggingLevel, toSpreadSheet, toString
-
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getColumnName, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, getColumnClass, getColumnCount, getColumnName, getRowCount, getValueAt, isCellEditable, removeTableModelListener, setValueAt
-
-
-
-
Method Detail
-
swap
protected abstract void swap(int firstIndex, int secondIndex)
Swaps the two rows.- Parameters:
firstIndex
- the index of the first rowsecondIndex
- the index of the second row
-
moveItems
protected int[] moveItems(int[] indices, int moveby, boolean up)
moves the selected items by a certain amount of items in a given direction.- Parameters:
indices
- the indices to movemoveby
- the number of items to move byup
- if true then items are moved up, otherwise down- Returns:
- the updated selected indices
-
moveUp
public int[] moveUp(int[] indices)
moves the selected items up by 1.- Specified by:
moveUp
in interfaceMoveableTableModel
- Parameters:
indices
- the indices of the rows to move- Returns:
- the updated indices of the selected rows
-
moveDown
public int[] moveDown(int[] indices)
moves the selected items down by 1.- Specified by:
moveDown
in interfaceMoveableTableModel
- Parameters:
indices
- the indices of the rows to move- Returns:
- the updated indices of the selected rows
-
moveTop
public int[] moveTop(int[] indices)
moves the selected items to the top.- Specified by:
moveTop
in interfaceMoveableTableModel
- Parameters:
indices
- the indices of the rows to move- Returns:
- the updated indices of the selected rows
-
moveBottom
public int[] moveBottom(int[] indices)
moves the selected items to the end.- Specified by:
moveBottom
in interfaceMoveableTableModel
- Parameters:
indices
- the indices of the rows to move- Returns:
- the updated indices of the selected rows
-
canMoveUp
public boolean canMoveUp(int[] indices)
checks whether the selected items can be moved up.- Specified by:
canMoveUp
in interfaceMoveableTableModel
- Parameters:
indices
- the indices of the rows to move- Returns:
- true if the selected items can be moved
-
canMoveDown
public boolean canMoveDown(int[] indices)
checks whether the selected items can be moved down.- Specified by:
canMoveDown
in interfaceMoveableTableModel
- Parameters:
indices
- the indices of the rows to move- Returns:
- true if the selected items can be moved
-
-