CubeTwister 2.0alpha142 2012-02-11

ch.randelshofer.cubetwister.doc
Class NotationMacrosTableModel

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

public class NotationMacrosTableModel
extends TreeNodeTableModel
implements java.beans.PropertyChangeListener

Wraps the macros provided by NotationModel to make them accessible by a MutableJTable.

Version:
1.2.1 2010-04-05 Removed dependencies to IBM Unicode normalizer.
1.2 2009-01-24 Normalize macro identifiers and macro scripts to Unicode NFKC.
1.1 2004-07-03 Revised.
1.0 2001-07-19 Created.
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
NotationMacrosTableModel()
           
 
Method Summary
 void createRow(int row, java.lang.Object type)
          Invoke this to insert a new row into the table.
 java.awt.datatransfer.Transferable exportRowTransferable(int[] rows)
          Creates a Transferable to use as the source for a data transfer of the specified elements.
 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.
 NotationModel getModel()
           
 java.lang.Object getValueAt(int row, int column)
          Returns the value for the cell at columnIndex and rowIndex.
 int importRowTransferable(java.awt.datatransfer.Transferable t, int action, int row, boolean asChild)
          Causes a transfer to the model from a clipboard or a DND drop operation.
 void insertRow(java.lang.Object type, int row)
          Invoke this to insert a new row into the table.
 boolean isCellEditable(int row, int column)
          Returns true if the cell at rowIndex and columnIndex is editable.
 boolean isRowImportable(java.awt.datatransfer.DataFlavor[] transferFlavors, int action, int row, boolean asChild)
          Indicates whether the model would accept an import of the given set of data flavors prior to actually attempting to import it.
 void propertyChange(java.beans.PropertyChangeEvent evt)
           
 void setModel(NotationModel m)
           
 void setValueAt(java.lang.Object aValue, int row, int column)
          Sets the value in the cell at columnIndex and rowIndex to aValue is the new value.
 
Methods inherited from class ch.randelshofer.gui.table.TreeNodeTableModel
getRow, getRowActions, getRowCount, isRowAddable, isRowRemovable, removeRow, setModel, treeNodesChanged, treeNodesInserted, treeNodesRemoved, treeStructureChanged
 
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
 

Constructor Detail

NotationMacrosTableModel

public NotationMacrosTableModel()
Method Detail

setModel

public void setModel(NotationModel m)

getModel

public NotationModel getModel()

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener

insertRow

public void insertRow(java.lang.Object type,
                      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.

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

isCellEditable

public boolean isCellEditable(int row,
                              int column)
Returns true if the cell at rowIndex and columnIndex is editable. Otherwise, setValueAt() on the cell will not change the value of that cell.

Specified by:
isCellEditable in interface MutableTableModel
Specified by:
isCellEditable in interface javax.swing.table.TableModel
Overrides:
isCellEditable 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:
true if the cell is editable.
See Also:
setValueAt(java.lang.Object, int, int)

setValueAt

public void setValueAt(java.lang.Object aValue,
                       int row,
                       int column)
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
row - the row whose value is to be changed
column - the column whose value is to be changed
See Also:
getValueAt(int, int), isCellEditable(int, 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()

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.

exportRowTransferable

public java.awt.datatransfer.Transferable exportRowTransferable(int[] rows)
Creates a Transferable to use as the source for a data transfer of the specified elements. Returns the representation of the rows to be transferred, or null if transfer is not possible.

Specified by:
exportRowTransferable in interface MutableTableModel
Overrides:
exportRowTransferable in class TreeNodeTableModel
Parameters:
rows - Row indices.

importRowTransferable

public int importRowTransferable(java.awt.datatransfer.Transferable t,
                                 int action,
                                 int row,
                                 boolean asChild)
                          throws java.awt.datatransfer.UnsupportedFlavorException,
                                 java.io.IOException
Causes a transfer to the model from a clipboard or a DND drop operation.

Specified by:
importRowTransferable in interface MutableTableModel
Overrides:
importRowTransferable in class TreeNodeTableModel
Parameters:
t - The transfer dataList.
action - The action DnDConstants.ACTION_COPY, .ACTION_MOVE or .ACTION_LINK.
row - The insertion point. 0 <= index <= getSize()
asChild - Indicates that the item is to be imported as a child of the list item rather than as an individual element of the list.
Returns:
The number of imported elements.
Throws:
java.awt.datatransfer.UnsupportedFlavorException
java.io.IOException

isRowImportable

public boolean isRowImportable(java.awt.datatransfer.DataFlavor[] transferFlavors,
                               int action,
                               int row,
                               boolean asChild)
Description copied from class: TreeNodeTableModel
Indicates whether the model would accept an import of the given set of data flavors prior to actually attempting to import it.

Specified by:
isRowImportable in interface MutableTableModel
Overrides:
isRowImportable in class TreeNodeTableModel
Parameters:
transferFlavors - the data formats available
action - The action DnDConstants.ACTION_COPY, .ACTION_MOVE or .ACTION_LINK.
row - The insertion point. 0 <= row <= getRowCount()
asChild - Indicates that the item is to be imported as a child of the list item rather than as an individual element / of the list.
Returns:
true if the data can be imported.
See Also:
DnDConstants

(c) Werner Randelshofer.
All rights reserved.