JComponentPack 1.5.0

com.zfqjava.swing.model
Class DataGridModelAdapter

java.lang.Object
  extended by com.zfqjava.swing.model.DataGridModelAdapter
All Implemented Interfaces:
CellSpanModel, DataGridModel, TableModel
Direct Known Subclasses:
ResultSetDataGridModelAdapter

public class DataGridModelAdapter
extends Object
implements DataGridModel

DataGridModelAdapter provides a DataGridModel adapter for any TableModel.

Since:
JDataGrid 1.8

Field Summary
protected  EventListenerList listenerList
          List of listeners
 
Constructor Summary
DataGridModelAdapter(TableModel tableModel)
           
 
Method Summary
 void addCellSpanListener(CellSpanListener l)
          Adds a listener to the list that is notified each time a change to the cell span model occurs.
 void addDataGridModelListener(DataGridModelListener l)
          Adds a listener to the list that is notified each time a change to the data model occurs.
 void addTableModelListener(TableModelListener l)
           
 void addUndoableEditListener(UndoableEditListener l)
          Registers the given observer to begin receiving notifications when undoable edits are made to the model.
protected  void fireCellChanged(DataGridModelEvent e)
          Notifies all listeners that cell have been changed.
 void fireTableChanged(TableModelEvent e)
          Forwards the given notification event to all TableModelListeners that registered themselves as listeners for this table model.
protected  void fireUndoableEditHappened(UndoableEdit edit)
          Notifies all listeners that have registered interest for notification on this event type.
 AttributeSet getCellAttributes(int rowIndex, int columnIndex)
          Returns the cell attributes.
 Class getCellClass(int rowIndex, int columnIndex)
          Returns the cell class.
 Cell getCellSpans(int rowIndex, int columnIndex)
          Returns the cell that spans the specified cell at rowIndex and columnIndex.
 Cell[] getCellSpans(int firstRow, int lastRow, int firstColumn, int lastColumn)
          Returns the cells that spans the specified cell area.
 Class getColumnClass(int columnIndex)
           
 int getColumnCount()
           
 String getColumnName(int columnIndex)
           
 DataGridModelListener[] getDataGridModelListeners()
          Returns an array of all the data grid model listeners registered on this model.
 EventListener[] getListeners(Class listenerType)
          Returns an array of all the objects currently registered as FooListeners upon this AbstractTableModel.
 int getRowCount()
           
 Cell[] getSpannedCells()
          Returns all spanned cells.
 TableModel getTableModel()
           
 TableModelListener[] getTableModelListeners()
          Returns an array of all the table model listeners registered on this model.
 UndoableEditListener[] getUndoableEditListeners()
          Returns an array of all the undoable edit listeners registered on this model.
 Object getValueAt(int rowIndex, int columnIndex)
           
 boolean hasCellSpans(int rowIndex, int columnIndex)
          Returns true if has cell spans the specified cell at rowIndex and columnIndex.
 boolean hasCellSpans(int firstRow, int lastRow, int firstColumn, int lastColumn)
          Returns true if has some cells spans the specified cell area.
 boolean isCellEditable(int rowIndex, int columnIndex)
           
 boolean isSpannedCell(Cell c)
          Determines whether the cell is spanned cell.
 boolean merge(Cell c)
          Merges the cell.
 void removeCellSpanListener(CellSpanListener l)
          Removes a listener from the list that is notified each time a change to the cell span model occurs.
 void removeDataGridModelListener(DataGridModelListener l)
          Removes a listener from the list that is notified each time a change to the data model occurs.
 void removeTableModelListener(TableModelListener l)
           
 void removeUndoableEditListener(UndoableEditListener l)
          Unregisters the given observer from the notification list so it will no longer receive updates.
 void setCellAttributes(AttributeSet attributes, int rowIndex, int columnIndex)
          Sets the cell attributes.
 void setCellClass(Class c, int rowIndex, int columnIndex)
          Sets the cell class.
 void setCellEditable(boolean editable, int rowIndex, int columnIndex)
          Sets the editable value for the specified cell at rowIndex and columnIndex.
 void setColumnClass(Class c, int columnIndex)
          Sets the column class for the specified columnIndex.
 void setColumnCount(int columnCount)
          Sets the number of columns in the model.
 void setColumnName(String name, int columnIndex)
          Sets the column name for the specified columnIndex.
 void setRowCount(int rowCount)
          Sets the number of rows in the model.
 void setValueAt(Object aValue, int rowIndex, int columnIndex)
           
 boolean split(Cell c)
          Splits the cell.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listenerList

protected transient EventListenerList listenerList
List of listeners

Constructor Detail

DataGridModelAdapter

public DataGridModelAdapter(TableModel tableModel)
Method Detail

getTableModel

public TableModel getTableModel()

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 columnIndex)
Specified by:
getColumnName in interface TableModel

getColumnClass

public Class getColumnClass(int columnIndex)
Specified by:
getColumnClass in interface TableModel

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
Specified by:
isCellEditable in interface TableModel

getValueAt

public Object getValueAt(int rowIndex,
                         int columnIndex)
Specified by:
getValueAt in interface TableModel

setValueAt

public void setValueAt(Object aValue,
                       int rowIndex,
                       int columnIndex)
Specified by:
setValueAt in interface TableModel

addTableModelListener

public void addTableModelListener(TableModelListener l)
Specified by:
addTableModelListener in interface TableModel

removeTableModelListener

public void removeTableModelListener(TableModelListener l)
Specified by:
removeTableModelListener in interface TableModel

getTableModelListeners

public TableModelListener[] getTableModelListeners()
Returns an array of all the table model listeners registered on this model.

Returns:
all of this model's TableModelListeners or an empty array if no table model listeners are currently registered
See Also:
addTableModelListener(javax.swing.event.TableModelListener), removeTableModelListener(javax.swing.event.TableModelListener)

fireTableChanged

public void fireTableChanged(TableModelEvent e)
Forwards the given notification event to all TableModelListeners that registered themselves as listeners for this table model.

Parameters:
e - the event to be forwarded
See Also:
addTableModelListener(javax.swing.event.TableModelListener), TableModelEvent, EventListenerList

setRowCount

public void setRowCount(int rowCount)
Description copied from interface: DataGridModel
Sets the number of rows in the model.

Specified by:
setRowCount in interface DataGridModel
Parameters:
rowCount - the number of rows in the model
See Also:
TableModel.getRowCount(), DataGridModel.setColumnCount(int), TableModel.getColumnCount()

setColumnCount

public void setColumnCount(int columnCount)
Description copied from interface: DataGridModel
Sets the number of columns in the model.

Specified by:
setColumnCount in interface DataGridModel
Parameters:
columnCount - the number of columns in the model
See Also:
TableModel.getRowCount(), DataGridModel.setRowCount(int), TableModel.getColumnCount()

setColumnName

public void setColumnName(String name,
                          int columnIndex)
Description copied from interface: DataGridModel
Sets the column name for the specified columnIndex.

Specified by:
setColumnName in interface DataGridModel
Parameters:
name - the column name
columnIndex - the specified columnIndex
See Also:
TableModel.getColumnName(int)

setColumnClass

public void setColumnClass(Class c,
                           int columnIndex)
Description copied from interface: DataGridModel
Sets the column class for the specified columnIndex.

Specified by:
setColumnClass in interface DataGridModel
Parameters:
c - the column class
columnIndex - the specified columnIndex
See Also:
TableModel.getColumnClass(int)

setCellEditable

public void setCellEditable(boolean editable,
                            int rowIndex,
                            int columnIndex)
Description copied from interface: DataGridModel
Sets the editable value for the specified cell at rowIndex and columnIndex.

Specified by:
setCellEditable in interface DataGridModel
Parameters:
editable - the cell editable value
rowIndex - the row whose value to be queried
columnIndex - the column whose value to be queried
See Also:
TableModel.setValueAt(java.lang.Object, int, int), TableModel.isCellEditable(int,int)

hasCellSpans

public boolean hasCellSpans(int rowIndex,
                            int columnIndex)
Description copied from interface: DataGridModel
Returns true if has cell spans the specified cell at rowIndex and columnIndex.

Specified by:
hasCellSpans in interface CellSpanModel
Specified by:
hasCellSpans in interface DataGridModel
Parameters:
rowIndex - the row index of the specified cell
columnIndex - the column index of the specified cell
See Also:
DataGridModel.getCellSpans(int,int)

getCellSpans

public Cell getCellSpans(int rowIndex,
                         int columnIndex)
Description copied from interface: DataGridModel
Returns the cell that spans the specified cell at rowIndex and columnIndex.

Specified by:
getCellSpans in interface CellSpanModel
Specified by:
getCellSpans in interface DataGridModel
Parameters:
rowIndex - the row index of the specified cell
columnIndex - the column index of the specified cell
Returns:
the cell that spans the specified cell
See Also:
DataGridModel.hasCellSpans(int,int)

hasCellSpans

public boolean hasCellSpans(int firstRow,
                            int lastRow,
                            int firstColumn,
                            int lastColumn)
Description copied from interface: DataGridModel
Returns true if has some cells spans the specified cell area.

Note:Some cell spans the area can have row and column index out of the area index.

Specified by:
hasCellSpans in interface CellSpanModel
Specified by:
hasCellSpans in interface DataGridModel
Parameters:
firstRow - the first row index of the specified cell area
lastRow - the last row index of the specified cell area
firstColumn - the first column index of the specified cell area
lastColumn - the last column index of the specified cell area
Returns:
true if has some cells spans the specified cell area
See Also:
DataGridModel.getCellSpans(int,int,int,int)

getCellSpans

public Cell[] getCellSpans(int firstRow,
                           int lastRow,
                           int firstColumn,
                           int lastColumn)
Description copied from interface: DataGridModel
Returns the cells that spans the specified cell area. Returns 0 length array if no such cells.

Note:Some cell spans the area can have row and column index out of the area index.

Specified by:
getCellSpans in interface CellSpanModel
Specified by:
getCellSpans in interface DataGridModel
Parameters:
firstRow - the first row index of the specified cell area
lastRow - the last row index of the specified cell area
firstColumn - the first column index of the specified cell area
lastColumn - the last column index of the specified cell area
Returns:
the cells that spans the specified cell area
See Also:
DataGridModel.hasCellSpans(int,int,int,int)

isSpannedCell

public boolean isSpannedCell(Cell c)
Description copied from interface: DataGridModel
Determines whether the cell is spanned cell.

Specified by:
isSpannedCell in interface CellSpanModel
Specified by:
isSpannedCell in interface DataGridModel
Parameters:
c - the cell
Returns:
true if the cell has merged use the DataGridModel.merge(com.zfqjava.swing.cell.Cell).

getSpannedCells

public Cell[] getSpannedCells()
Description copied from interface: DataGridModel
Returns all spanned cells.

Specified by:
getSpannedCells in interface CellSpanModel
Specified by:
getSpannedCells in interface DataGridModel
Returns:
all spannned cells that merged use the DataGridModel.merge(com.zfqjava.swing.cell.Cell).

merge

public boolean merge(Cell c)
Description copied from interface: DataGridModel
Merges the cell. Returns true if this model changes as a result of the call. (Returns false if this model already contains such spanned cell c or does not permit such operation.)

Specified by:
merge in interface CellSpanModel
Specified by:
merge in interface DataGridModel
Parameters:
c - the cell
Returns:
true if this model changed as a result of the call
See Also:
DataGridModel.split(com.zfqjava.swing.cell.Cell)

split

public boolean split(Cell c)
Description copied from interface: DataGridModel
Splits the cell. Returns true if this model changes as a result of the call. (Returns false if this model have not such spanned cell or does not permit such operation.)

Specified by:
split in interface CellSpanModel
Specified by:
split in interface DataGridModel
Parameters:
c - the cell
Returns:
true if this model changed as a result of the call
See Also:
DataGridModel.merge(com.zfqjava.swing.cell.Cell)

getCellAttributes

public AttributeSet getCellAttributes(int rowIndex,
                                      int columnIndex)
Description copied from interface: DataGridModel
Returns the cell attributes.

Specified by:
getCellAttributes in interface DataGridModel
Parameters:
rowIndex - the index of the row
columnIndex - the index of the column
Returns:
the attributes for the specified cell
See Also:
DataGridModel.setCellAttributes(javax.swing.text.AttributeSet, int, int)

setCellAttributes

public void setCellAttributes(AttributeSet attributes,
                              int rowIndex,
                              int columnIndex)
Description copied from interface: DataGridModel
Sets the cell attributes.

Specified by:
setCellAttributes in interface DataGridModel
Parameters:
attributes - the cell attributes
rowIndex - the index of the row
columnIndex - the index of the column
See Also:
DataGridModel.getCellAttributes(int, int)

getCellClass

public Class getCellClass(int rowIndex,
                          int columnIndex)
Description copied from interface: DataGridModel
Returns the cell class.

Specified by:
getCellClass in interface DataGridModel
Parameters:
rowIndex - the index of the row
columnIndex - the index of the column
Returns:
the class for the specified cell
See Also:
DataGridModel.setCellClass(java.lang.Class, int, int)

setCellClass

public void setCellClass(Class c,
                         int rowIndex,
                         int columnIndex)
Description copied from interface: DataGridModel
Sets the cell class.

Specified by:
setCellClass in interface DataGridModel
Parameters:
c - the class for the specified cell
rowIndex - the index of the row
columnIndex - the index of the column
See Also:
DataGridModel.getCellClass(int, int)

addDataGridModelListener

public void addDataGridModelListener(DataGridModelListener l)
Description copied from interface: DataGridModel
Adds a listener to the list that is notified each time a change to the data model occurs.

Specified by:
addDataGridModelListener in interface DataGridModel
Parameters:
l - the DataGridModelListener

removeDataGridModelListener

public void removeDataGridModelListener(DataGridModelListener l)
Description copied from interface: DataGridModel
Removes a listener from the list that is notified each time a change to the data model occurs.

Specified by:
removeDataGridModelListener in interface DataGridModel
Parameters:
l - the DataGridModelListener

getDataGridModelListeners

public DataGridModelListener[] getDataGridModelListeners()
Returns an array of all the data grid model listeners registered on this model.

Returns:
all of this model's DataGridModelListeners or an empty array if no data grid model listeners are currently registered
See Also:
addDataGridModelListener(com.zfqjava.swing.event.DataGridModelListener), removeDataGridModelListener(com.zfqjava.swing.event.DataGridModelListener)

fireCellChanged

protected void fireCellChanged(DataGridModelEvent e)
Notifies all listeners that cell have been changed.


addUndoableEditListener

public void addUndoableEditListener(UndoableEditListener l)
Description copied from interface: DataGridModel
Registers the given observer to begin receiving notifications when undoable edits are made to the model.

Specified by:
addUndoableEditListener in interface DataGridModel
Parameters:
l - the observer to register
See Also:
UndoableEditEvent

removeUndoableEditListener

public void removeUndoableEditListener(UndoableEditListener l)
Description copied from interface: DataGridModel
Unregisters the given observer from the notification list so it will no longer receive updates.

Specified by:
removeUndoableEditListener in interface DataGridModel
Parameters:
l - the observer to register
See Also:
UndoableEditEvent

getUndoableEditListeners

public UndoableEditListener[] getUndoableEditListeners()
Returns an array of all the undoable edit listeners registered on this model.

Returns:
all of this model's UndoableEditListeners or an empty array if no undoable edit listeners are currently registered
See Also:
addUndoableEditListener(javax.swing.event.UndoableEditListener), removeUndoableEditListener(javax.swing.event.UndoableEditListener)

fireUndoableEditHappened

protected void fireUndoableEditHappened(UndoableEdit edit)
Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.

See Also:
EventListenerList

getListeners

public EventListener[] getListeners(Class listenerType)
Returns an array of all the objects currently registered as FooListeners upon this AbstractTableModel. FooListeners are registered using the addFooListener method.

You can specify the listenerType argument with a class literal, such as FooListener.class. For example, you can query a model m for its table model listeners with the following code:

TableModelListener[] tmls = (TableModelListener[])(m.getListeners(TableModelListener.class));
If no such listeners exist, this method returns an empty array.

Parameters:
listenerType - the type of listeners requested; this parameter should specify an interface that descends from java.util.EventListener
Returns:
an array of all objects registered as FooListeners on this component, or an empty array if no such listeners have been added
Throws:
ClassCastException - if listenerType doesn't specify a class or interface that implements java.util.EventListener
See Also:
getTableModelListeners()

addCellSpanListener

public void addCellSpanListener(CellSpanListener l)
Description copied from interface: CellSpanModel
Adds a listener to the list that is notified each time a change to the cell span model occurs.

Specified by:
addCellSpanListener in interface CellSpanModel
Parameters:
l - the CellSpanListener

removeCellSpanListener

public void removeCellSpanListener(CellSpanListener l)
Description copied from interface: CellSpanModel
Removes a listener from the list that is notified each time a change to the cell span model occurs.

Specified by:
removeCellSpanListener in interface CellSpanModel
Parameters:
l - the CellSpanListener

JComponentPack 1.5.0

Send your Feedback
JComponentPack 1.5.0
Copyright © 2001-2007 Extreme Component, Inc. All rights reserved.