Class DefaultTableColumnModelExt
- java.lang.Object
-
- javax.swing.table.DefaultTableColumnModel
-
- org.jdesktop.swingx.table.DefaultTableColumnModelExt
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener,java.io.Serializable,java.util.EventListener,javax.swing.event.ListSelectionListener,javax.swing.table.TableColumnModel,TableColumnModelExt
public class DefaultTableColumnModelExt extends javax.swing.table.DefaultTableColumnModel implements TableColumnModelExt
A default implementation ofTableColumnModelExt.TODO: explain sub-optimal notification on showing/hiding columns. (hot fixed issues #156, #157. To really do it need enhanced TableColumnModelEvent and -Listeners that are aware of the event.)
- Author:
- Richard Bair, Jeanette Winzenburg
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DefaultTableColumnModelExt()Creates a an empty DefaultTableColumnModelExt.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddColumn(javax.swing.table.TableColumn aColumn)voidaddColumnModelListener(javax.swing.event.TableColumnModelListener x)Adds a listener for table column model events.protected voidfireColumnPropertyChange(java.beans.PropertyChangeEvent evt)NotifiesTableColumnModelExtListeners about property changes of contained columns.intgetColumnCount(boolean includeHidden)Returns the number of contained columns.TableColumnExtgetColumnExt(int columnIndex)Returns theTableColumnExtat view positioncolumnIndex.TableColumnExtgetColumnExt(java.lang.Object identifier)Returns the firstTableColumnExtwith the givenidentifier.java.util.List<javax.swing.table.TableColumn>getColumns(boolean includeHidden)Returns aListof containedTableColumns.protected javax.swing.event.EventListenerListgetEventListenerList()Exposed for testing only - don't use! Will be removed again!TableColumnModelExtListener[]getTableColumnModelExtListeners()booleanisAddedFromInvisibleEvent(int newIndex)hot fix for #157: listeners that are aware of the possible existence of invisible columns should check if the received columnAdded originated from moving a column from invisible to visible.booleanisRemovedToInvisibleEvent(int oldIndex)hot fix for #157: listeners that are aware of the possible existence of invisible columns should check if the received columnRemoved originated from moving a column from visible to invisible.voidmoveColumn(int columnIndex, int newIndex)protected voidmoveToInvisible(TableColumnExt col)Update internal state after the visibility of the column was changed to invisible.protected voidmoveToVisible(TableColumnExt col)Update internal state after the visibility of the column was changed to visible.voidpropertyChange(java.beans.PropertyChangeEvent evt)voidremoveColumn(javax.swing.table.TableColumn column)voidremoveColumnModelListener(javax.swing.event.TableColumnModelListener x)-
Methods inherited from class javax.swing.table.DefaultTableColumnModel
createSelectionModel, fireColumnAdded, fireColumnMarginChanged, fireColumnMoved, fireColumnRemoved, fireColumnSelectionChanged, getColumn, getColumnCount, getColumnIndex, getColumnIndexAtX, getColumnMargin, getColumnModelListeners, getColumns, getColumnSelectionAllowed, getListeners, getSelectedColumnCount, getSelectedColumns, getSelectionModel, getTotalColumnWidth, recalcWidthCache, setColumnMargin, setColumnSelectionAllowed, setSelectionModel, valueChanged
-
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.TableColumnModel
getColumn, getColumnCount, getColumnIndex, getColumnIndexAtX, getColumnMargin, getColumns, getColumnSelectionAllowed, getSelectedColumnCount, getSelectedColumns, getSelectionModel, getTotalColumnWidth, setColumnMargin, setColumnSelectionAllowed, setSelectionModel
-
-
-
-
Method Detail
-
getColumns
public java.util.List<javax.swing.table.TableColumn> getColumns(boolean includeHidden)
Returns aListof containedTableColumns. Includes or excludes invisible columns, depending on whether theincludeHiddenis true or false, respectively. If false, anIteratorover the List is equivalent to theEnumerationreturned bygetColumns().NOTE: the order of columns in the List depends on whether or not the invisible columns are included, in the former case it's the insertion order in the latter it's the current order of the visible columns.
- Specified by:
getColumnsin interfaceTableColumnModelExt- Parameters:
includeHidden- a boolean to indicate whether invisible columns should be included- Returns:
- a
Listof contained columns.
-
getColumnCount
public int getColumnCount(boolean includeHidden)
Returns the number of contained columns. The count includes or excludes invisible columns, depending on whether theincludeHiddenis true or false, respectively. If false, this method returns the same count asgetColumnCount().- Specified by:
getColumnCountin interfaceTableColumnModelExt- Parameters:
includeHidden- a boolean to indicate whether invisible columns should be included- Returns:
- the number of contained columns, including or excluding the invisible as specified.
-
getColumnExt
public TableColumnExt getColumnExt(java.lang.Object identifier)
Returns the firstTableColumnExtwith the givenidentifier. The return value is null if there is no contained column with identifier or if the column withidentifieris not of typeTableColumnExt. The returned column may be visible or hidden.- Specified by:
getColumnExtin interfaceTableColumnModelExt- Parameters:
identifier- the object used as column identifier- Returns:
- first
TableColumnExtwith the given identifier or null if none is found
-
getColumnExt
public TableColumnExt getColumnExt(int columnIndex)
Returns theTableColumnExtat view positioncolumnIndex. The return value is null, if the column at positioncolumnIndexis not of typeTableColumnExt. The returned column is visible.- Specified by:
getColumnExtin interfaceTableColumnModelExt- Parameters:
columnIndex- the index of the column desired- Returns:
- the
TableColumnExtobject that matches the column index
-
isRemovedToInvisibleEvent
public boolean isRemovedToInvisibleEvent(int oldIndex)
hot fix for #157: listeners that are aware of the possible existence of invisible columns should check if the received columnRemoved originated from moving a column from visible to invisible.- Parameters:
oldIndex- the fromIndex of the columnEvent- Returns:
- true if the column was moved to invisible
-
isAddedFromInvisibleEvent
public boolean isAddedFromInvisibleEvent(int newIndex)
hot fix for #157: listeners that are aware of the possible existence of invisible columns should check if the received columnAdded originated from moving a column from invisible to visible.- Parameters:
newIndex- the toIndex of the columnEvent- Returns:
- true if the column was moved to visible
-
removeColumn
public void removeColumn(javax.swing.table.TableColumn column)
Overridden to update internals related to column visibility.
- Specified by:
removeColumnin interfacejavax.swing.table.TableColumnModel- Overrides:
removeColumnin classjavax.swing.table.DefaultTableColumnModel
-
addColumn
public void addColumn(javax.swing.table.TableColumn aColumn)
Overridden to update internals related to column visibility.
- Specified by:
addColumnin interfacejavax.swing.table.TableColumnModel- Overrides:
addColumnin classjavax.swing.table.DefaultTableColumnModel
-
moveColumn
public void moveColumn(int columnIndex, int newIndex)Overridden to update internals related to column visibility.
- Specified by:
moveColumnin interfacejavax.swing.table.TableColumnModel- Overrides:
moveColumnin classjavax.swing.table.DefaultTableColumnModel
-
moveToInvisible
protected void moveToInvisible(TableColumnExt col)
Update internal state after the visibility of the column was changed to invisible. The given column is assumed to be contained in this model.- Parameters:
col- the column which was hidden.
-
moveToVisible
protected void moveToVisible(TableColumnExt col)
Update internal state after the visibility of the column was changed to visible. The given column is assumed to be contained in this model.- Parameters:
col- the column which was made visible.
-
getEventListenerList
protected javax.swing.event.EventListenerList getEventListenerList()
Exposed for testing only - don't use! Will be removed again!- Returns:
- super's listener list
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent evt)
- Specified by:
propertyChangein interfacejava.beans.PropertyChangeListener- Overrides:
propertyChangein classjavax.swing.table.DefaultTableColumnModel
-
fireColumnPropertyChange
protected void fireColumnPropertyChange(java.beans.PropertyChangeEvent evt)
NotifiesTableColumnModelExtListeners about property changes of contained columns. The event instance is the original as fired by theTableColumn.- Parameters:
evt- the event received- See Also:
EventListenerList
-
addColumnModelListener
public void addColumnModelListener(javax.swing.event.TableColumnModelListener x)
Adds a listener for table column model events. This enhances super's behaviour in that it guarantees to notify listeners of type TableColumnModelListenerExt about property changes of contained columns.Overridden to install enhanced notification of listeners of type. TableColumnModelListenerExt about property changes of contained columns.
- Specified by:
addColumnModelListenerin interfacejavax.swing.table.TableColumnModel- Specified by:
addColumnModelListenerin interfaceTableColumnModelExt- Overrides:
addColumnModelListenerin classjavax.swing.table.DefaultTableColumnModel- Parameters:
x- aTableColumnModelListenerobject
-
removeColumnModelListener
public void removeColumnModelListener(javax.swing.event.TableColumnModelListener x)
Overridden to uninstall enhanced notification of listeners of type. TableColumnModelListenerExt about property changes of contained columns.
- Specified by:
removeColumnModelListenerin interfacejavax.swing.table.TableColumnModel- Overrides:
removeColumnModelListenerin classjavax.swing.table.DefaultTableColumnModel
-
getTableColumnModelExtListeners
public TableColumnModelExtListener[] getTableColumnModelExtListeners()
- Returns:
- array of all registered listeners
-
-