JIDE 3.5.15

com.jidesoft.grid
Class AbstractSpanTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by com.jidesoft.grid.AbstractSpanTableModel
All Implemented Interfaces:
SpanModel, SpanTableModel, Serializable, TableModel

public abstract class AbstractSpanTableModel
extends AbstractTableModel
implements SpanTableModel

AbstractSpanTableModel adds SpanModel support to AbstractTableModel. You can use it as replacement for AbstractTableModel. It implements both methods in SpanModel by returning false in SpanModel.isCellSpanOn() and returning null in SpanModel.getCellSpanAt(int,int). Subclass can override the default implementation.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
protected AbstractSpanTableModel()
           
 
Method Summary
 void addSpanModelListener(SpanModelListener l)
          Adds a listener to the list that's notified each time a change to the span model occurs.
 void fireTableSpanAdded(CellSpan cellSpan)
          Notifies all listeners that a cell span is added at cell (row, column).
 void fireTableSpanChanged()
          Notifies all listeners that all span values in the table's rows may have changed.
 void fireTableSpanChanged(SpanModelEvent e)
          Forwards the given notification event to all SpanModelListeners that registered themselves as listeners for this table model.
 void fireTableSpanRemoved(CellSpan cellSpan)
          Notifies all listeners that a cell span is removed at cell (row, column).
 CellSpan getCellSpanAt(int rowIndex, int columnIndex)
          Gets the cell span at the specified row and column.
 SpanModelListener[] getSpanModelListeners()
          Returns an array of all the table model listeners registered on this model.
 boolean isCellSpanOn()
          Checks if the span is on.
 void removeSpanModelListener(SpanModelListener l)
          Removes a listener from the list that's notified each time a change to the data model occurs.
 
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, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, getColumnClass, getColumnCount, getColumnName, getRowCount, getValueAt, isCellEditable, removeTableModelListener, setValueAt
 

Constructor Detail

AbstractSpanTableModel

protected AbstractSpanTableModel()
Method Detail

getCellSpanAt

public CellSpan getCellSpanAt(int rowIndex,
                              int columnIndex)
Description copied from interface: SpanModel
Gets the cell span at the specified row and column. To avoid creating many instances of CellSpan, you can return the same instance by changing its values only. For example, the code below is a good example.

 private final CellSpan span = new CellSpan(0,0,1,1);
 public CellSpan getCellSpanAt(int row, int col) {
     span.setRow(...);
     span.setColumn(...);
     span.setRowSpan(...);
     span.setColumnSpan(...);
     return span;
 }
 
For performance consideration, if the cell span has 1 row span and 1 column span, it is better to return null instead of new CellSpan(row, column, 1, 1).

Specified by:
getCellSpanAt in interface SpanModel
Parameters:
rowIndex - the row index.
columnIndex - the column index.
Returns:
CellSpan object.

isCellSpanOn

public boolean isCellSpanOn()
Description copied from interface: SpanModel
Checks if the span is on. The CellSpanTable will ignore all the CellSpans defined in this model if this method returns false.

Since 3.5.12, please fire table data changed event if the returned value of this method is changed. Otherwise the CellSpanTable might still use the cached value to improve performance.

Specified by:
isCellSpanOn in interface SpanModel
Returns:
true if span is on. Otherwise false.

addSpanModelListener

public void addSpanModelListener(SpanModelListener l)
Adds a listener to the list that's notified each time a change to the span model occurs.

Parameters:
l - the SpanModelListener

removeSpanModelListener

public void removeSpanModelListener(SpanModelListener l)
Removes a listener from the list that's notified each time a change to the data model occurs.

Parameters:
l - the SpanModelListener

getSpanModelListeners

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

Returns:
all of this model's SpanModelListeners or an empty array if no table model listeners are currently registered
Since:
1.4
See Also:
addSpanModelListener(com.jidesoft.grid.SpanModelListener), removeSpanModelListener(com.jidesoft.grid.SpanModelListener)

fireTableSpanChanged

public void fireTableSpanChanged()
Notifies all listeners that all span values in the table's rows may have changed. The number of rows may also have changed and the JTable should redraw the table from scratch. The structure of the table (as in the order of the columns) is assumed to be the same.

See Also:
SpanModelEvent, EventListenerList

fireTableSpanAdded

public void fireTableSpanAdded(CellSpan cellSpan)
Notifies all listeners that a cell span is added at cell (row, column).

Parameters:
cellSpan -
See Also:
SpanModelEvent

fireTableSpanRemoved

public void fireTableSpanRemoved(CellSpan cellSpan)
Notifies all listeners that a cell span is removed at cell (row, column).

Parameters:
cellSpan -
See Also:
SpanModelEvent

fireTableSpanChanged

public void fireTableSpanChanged(SpanModelEvent e)
Forwards the given notification event to all SpanModelListeners that registered themselves as listeners for this table model.

Parameters:
e - the event to be forwarded
See Also:
addSpanModelListener(com.jidesoft.grid.SpanModelListener), SpanModelEvent, EventListenerList

JIDE 3.5.15