CubeTwister 2.0alpha142 2012-02-11

ch.randelshofer.cubetwister.doc
Class CubeColorsTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by ch.randelshofer.gui.table.TreeNodeTableModel
          extended by ch.randelshofer.cubetwister.doc.CubeColorsTableModel
All Implemented Interfaces:
MutableTableModel, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, javax.swing.event.TreeModelListener, javax.swing.table.TableModel

public class CubeColorsTableModel
extends TreeNodeTableModel
implements java.beans.PropertyChangeListener

Wraps a CubeColorsModel into the swing TableModel interface.

Version:
2.0 2006-06-03 Reworked.
1.0 2001-07-19
Author:
Werner Randelshofer
See Also:
Serialized Form

Field Summary
 
Fields inherited from class ch.randelshofer.gui.table.TreeNodeTableModel
treeModel, treeNode
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
CubeColorsTableModel()
          Creates a new CubeColorsTableModel which wraps a default CubeModel.
CubeColorsTableModel(CubeModel n)
          Creates a new CubeColorsTableModel which wraps the provided CubeModel.
 
Method Summary
 void createRow(int row, java.lang.Object type)
          Invoke this to insert a new row into the table.
 void duplicateRow(int row)
          Invoke this to duplicate a row of the table.
 java.lang.Class getColumnClass(int column)
          Returns the most specific superclass for all the cell values in the column.
 int getColumnCount()
          Returns the number of columns in the model.
 java.lang.String getColumnName(int columnIndex)
          Returns the name of the column at columnIndex.
 java.lang.Object getCreatableRowType(int row)
          Returns the default type of elements that can be created at the specified index of the list.
 java.lang.Object[] getCreatableRowTypes(int row)
          Returns the types of children that may be created at this row.
 javax.swing.Action[] getRowActions(int[] rows)
          Gets actions for the indicated rows.
 CubeColorModel getRowObject(int row)
           
 java.lang.Object getValueAt(int row, int column)
          Returns the value for the cell at columnIndex and rowIndex.
 void insertRow(int row)
          Invoke this to insert a new row into the table.
 boolean isRowRemovable(int row)
          Returns wether the specified node may be removed.
 void propertyChange(java.beans.PropertyChangeEvent evt)
          This method gets called when a bound property is changed.
 void setModel(CubeModel value)
           
 void setValueAt(java.lang.Object aValue, int rowIndex, int columnIndex)
          Sets the value in the cell at columnIndex and rowIndex to aValue is the new value.
 void treeNodesInserted(javax.swing.event.TreeModelEvent evt)
          Invoked after nodes have been inserted into the tree.
 void treeNodesRemoved(javax.swing.event.TreeModelEvent evt)
          Invoked after nodes have been removed from the tree.
 
Methods inherited from class ch.randelshofer.gui.table.TreeNodeTableModel
exportRowTransferable, getRow, getRowCount, importRowTransferable, isCellEditable, isRowAddable, isRowImportable, removeRow, setModel, treeNodesChanged, treeStructureChanged
 
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, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, removeTableModelListener
 

Constructor Detail

CubeColorsTableModel

public CubeColorsTableModel()
Creates a new CubeColorsTableModel which wraps a default CubeModel. XXX Broken


CubeColorsTableModel

public CubeColorsTableModel(CubeModel n)
Creates a new CubeColorsTableModel which wraps the provided CubeModel.

Method Detail

setModel

public void setModel(CubeModel value)

getRowObject

public CubeColorModel getRowObject(int row)

getValueAt

public java.lang.Object getValueAt(int row,
                                   int column)
Returns the value for the cell at columnIndex and rowIndex.

Specified by:
getValueAt in interface javax.swing.table.TableModel
Overrides:
getValueAt in class TreeNodeTableModel
Parameters:
row - the row whose value is to be looked up
column - the column whose value is to be looked up
Returns:
the value Object at the specified cell

getColumnName

public java.lang.String getColumnName(int columnIndex)
Returns the name of the column at columnIndex. This is used to initialize the table's column header name. Note: this name does not need to be unique; two columns in a table can have the same name.

Specified by:
getColumnName in interface javax.swing.table.TableModel
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel
Parameters:
columnIndex - the index of column
Returns:
the name of the column

insertRow

public void insertRow(int row)
Invoke this to insert a new row into the table.

Parameters:
row - index of the new row.
Throws:
java.lang.IllegalStateException - if the row may not be inserted.

duplicateRow

public void duplicateRow(int row)
Invoke this to duplicate a row of the table.

Parameters:
row - index of the row.
Throws:
java.lang.IllegalStateException - if the row may not be duplicated.

setValueAt

public void setValueAt(java.lang.Object aValue,
                       int rowIndex,
                       int columnIndex)
Sets the value in the cell at columnIndex and rowIndex to aValue is the new value.

Specified by:
setValueAt in interface javax.swing.table.TableModel
Overrides:
setValueAt in class javax.swing.table.AbstractTableModel
Parameters:
aValue - the new value
rowIndex - the row whose value is to be changed
columnIndex - the column whose value is to be changed
See Also:
getValueAt(int, int), TreeNodeTableModel.isCellEditable(int, int)

getColumnClass

public java.lang.Class getColumnClass(int column)
Returns the most specific superclass for all the cell values in the column. This is used by the JTable to set up a default renderer and editor for the column.

Specified by:
getColumnClass in interface javax.swing.table.TableModel
Overrides:
getColumnClass in class javax.swing.table.AbstractTableModel
Returns:
the common ancestor class of the object values in the model.

isRowRemovable

public boolean isRowRemovable(int row)
Returns wether the specified node may be removed.

Specified by:
isRowRemovable in interface MutableTableModel
Overrides:
isRowRemovable in class TreeNodeTableModel
Parameters:
row - index of the row.
See Also:
MutableTableModel.removeRow(int)

getColumnCount

public int getColumnCount()
Returns the number of columns in the model. A JTable uses this method to determine how many columns it should create and display by default.

Specified by:
getColumnCount in interface javax.swing.table.TableModel
Overrides:
getColumnCount in class TreeNodeTableModel
Returns:
the number or columns in the model
See Also:
TreeNodeTableModel.getRowCount()

getRowActions

public javax.swing.Action[] getRowActions(int[] rows)
Gets actions for the indicated rows.

Specified by:
getRowActions in interface MutableTableModel
Overrides:
getRowActions in class TreeNodeTableModel
Parameters:
rows - indices of the rows.

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
This method gets called when a bound property is changed.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
evt - A PropertyChangeEvent object describing the event source and the property that has changed.

treeNodesInserted

public void treeNodesInserted(javax.swing.event.TreeModelEvent evt)

Invoked after nodes have been inserted into the tree.

e.path() returns the parent of the new nodes

e.childIndices() returns the indices of the new nodes in ascending order.

Specified by:
treeNodesInserted in interface javax.swing.event.TreeModelListener
Overrides:
treeNodesInserted in class TreeNodeTableModel

treeNodesRemoved

public void treeNodesRemoved(javax.swing.event.TreeModelEvent evt)

Invoked after nodes have been removed from the tree. Note that if a subtree is removed from the tree, this method may only be invoked once for the root of the removed subtree, not once for each individual set of siblings removed.

e.path() returns the former parent of the deleted nodes.

e.childIndices() returns the indices the nodes had before they were deleted in ascending order.

Specified by:
treeNodesRemoved in interface javax.swing.event.TreeModelListener
Overrides:
treeNodesRemoved in class TreeNodeTableModel

getCreatableRowTypes

public java.lang.Object[] getCreatableRowTypes(int row)
Description copied from class: TreeNodeTableModel
Returns the types of children that may be created at this row.

Specified by:
getCreatableRowTypes in interface MutableTableModel
Overrides:
getCreatableRowTypes in class TreeNodeTableModel
Parameters:
row - a row.
Returns:
an array of objects that specify a child type that may be added at this row.

getCreatableRowType

public java.lang.Object getCreatableRowType(int row)
Description copied from interface: MutableTableModel
Returns the default type of elements that can be created at the specified index of the list.

Specified by:
getCreatableRowType in interface MutableTableModel
Overrides:
getCreatableRowType in class TreeNodeTableModel
Parameters:
row - The insertion point. 0 <= index <= getRowCount()
Returns:
an Object that specifies the default element type that can be inserted at the insertion point. Returns null if no elements can be inserted here. The value must be one of the types returned by operation getCreatableTypes.

createRow

public void createRow(int row,
                      java.lang.Object type)
Invoke this to insert a new row into the table.

Specified by:
createRow in interface MutableTableModel
Overrides:
createRow in class TreeNodeTableModel
Parameters:
row - index of the new row.
type - element type to be inserted.
Throws:
java.lang.IllegalStateException - if the row may not be inserted.

(c) Werner Randelshofer.
All rights reserved.