Class DefaultTableColumnModelExt
- All Implemented Interfaces:
PropertyChangeListener, Serializable, EventListener, ListSelectionListener, TableColumnModel, TableColumnModelExt
TableColumnModelExt.
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.)
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classTODO JW: move into propertyChanged! No need for a dedicated listener. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate List<TableColumn> contains a list of all column, in the order they would appear if all were visible.private List<TableColumn> contains a list of all columns, in the order in which were added to the model.private booleanflag to distinguish a shown/hidden column from really added/removed columns during notification.Listener attached to TableColumnExt instances to listen for changes to their visibility status, and to hide/show the column as oppropriateFields inherited from class DefaultTableColumnModel
changeEvent, columnMargin, columnSelectionAllowed, listenerList, selectionModel, tableColumns, totalColumnWidth -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddColumn(TableColumn aColumn) voidAdds a listener for table column model events.protected voidNotifiesTableColumnModelExtListeners about property changes of contained columns.intgetColumnCount(boolean includeHidden) Returns the number of contained columns.getColumnExt(int columnIndex) Returns theTableColumnExtat view positioncolumnIndex.getColumnExt(Object identifier) Returns the firstTableColumnExtwith the givenidentifier.getColumns(boolean includeHidden) Returns aListof containedTableColumns.protected EventListenerListExposed for testing only - don't use! Will be removed again!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 voidUpdate internal state after the visibility of the column was changed to invisible.protected voidUpdate internal state after the visibility of the column was changed to visible.voidvoidremoveColumn(TableColumn column) voidprivate voidupdateCurrentColumns(int oldIndex, int newIndex) Adjusts the current column sequence when a visible column is moved.Methods inherited from class DefaultTableColumnModel
createSelectionModel, fireColumnAdded, fireColumnMarginChanged, fireColumnMoved, fireColumnRemoved, fireColumnSelectionChanged, getColumn, getColumnCount, getColumnIndex, getColumnIndexAtX, getColumnMargin, getColumnModelListeners, getColumns, getColumnSelectionAllowed, getListeners, getSelectedColumnCount, getSelectedColumns, getSelectionModel, getTotalColumnWidth, recalcWidthCache, setColumnMargin, setColumnSelectionAllowed, setSelectionModel, valueChangedMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface TableColumnModel
getColumn, getColumnCount, getColumnIndex, getColumnIndexAtX, getColumnMargin, getColumns, getColumnSelectionAllowed, getSelectedColumnCount, getSelectedColumns, getSelectionModel, getTotalColumnWidth, setColumnMargin, setColumnSelectionAllowed, setSelectionModel
-
Field Details
-
isVisibilityChange
private boolean isVisibilityChangeflag to distinguish a shown/hidden column from really added/removed columns during notification. This is brittle! -
initialColumns
contains a list of all columns, in the order in which were added to the model. -
currentColumns
contains a list of all column, in the order they would appear if all were visible. -
visibilityListener
Listener attached to TableColumnExt instances to listen for changes to their visibility status, and to hide/show the column as oppropriate
-
-
Constructor Details
-
DefaultTableColumnModelExt
public DefaultTableColumnModelExt()Creates a an empty DefaultTableColumnModelExt.
-
-
Method Details
-
getColumns
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
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
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
Overridden to update internals related to column visibility.
- Specified by:
removeColumnin interfaceTableColumnModel- Overrides:
removeColumnin classDefaultTableColumnModel
-
addColumn
Overridden to update internals related to column visibility.
- Specified by:
addColumnin interfaceTableColumnModel- Overrides:
addColumnin classDefaultTableColumnModel
-
moveColumn
public void moveColumn(int columnIndex, int newIndex) Overridden to update internals related to column visibility.
- Specified by:
moveColumnin interfaceTableColumnModel- Overrides:
moveColumnin classDefaultTableColumnModel
-
updateCurrentColumns
private void updateCurrentColumns(int oldIndex, int newIndex) Adjusts the current column sequence when a visible column is moved.- Parameters:
oldIndex- the old visible position.newIndex- the new visible position.
-
moveToInvisible
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
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
Exposed for testing only - don't use! Will be removed again!- Returns:
- super's listener list
-
propertyChange
- Specified by:
propertyChangein interfacePropertyChangeListener- Overrides:
propertyChangein classDefaultTableColumnModel
-
fireColumnPropertyChange
NotifiesTableColumnModelExtListeners about property changes of contained columns. The event instance is the original as fired by theTableColumn.- Parameters:
evt- the event received- See Also:
-
addColumnModelListener
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 interfaceTableColumnModel- Specified by:
addColumnModelListenerin interfaceTableColumnModelExt- Overrides:
addColumnModelListenerin classDefaultTableColumnModel- Parameters:
x- aTableColumnModelListenerobject
-
removeColumnModelListener
Overridden to uninstall enhanced notification of listeners of type. TableColumnModelListenerExt about property changes of contained columns.
- Specified by:
removeColumnModelListenerin interfaceTableColumnModel- Overrides:
removeColumnModelListenerin classDefaultTableColumnModel
-
getTableColumnModelExtListeners
- Returns:
- array of all registered listeners
-