Class ColumnControlButton.ColumnVisibilityAction
java.lang.Object
javax.swing.AbstractAction
org.jdesktop.swingx.action.AbstractActionExt
org.jdesktop.swingx.table.ColumnControlButton.ColumnVisibilityAction
- All Implemented Interfaces:
ActionListener, ItemListener, Serializable, Cloneable, EventListener, Action
- Enclosing class:
ColumnControlButton
A specialized
Action which takes care of keeping in synch with
TableColumn state.
NOTE: client must call releaseColumn if this action is no longer needed!- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate TableColumnprivate PropertyChangeListenerprivate booleanflag to distinguish selection changes triggered by column's property change from those triggered by user interaction.Fields inherited from class AbstractActionExt
GROUP, IS_STATE, LARGE_ICONFields inherited from class AbstractAction
changeSupport, enabledFields inherited from interface Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON -
Constructor Summary
ConstructorsConstructorDescriptionColumnVisibilityAction(TableColumn column) Creates a action synched to the table column. -
Method Summary
Modifier and TypeMethodDescriptionvoidDoes nothing.protected booleanReturns flag to indicate if column's visibility can be controlled.protected PropertyChangeListenerCreates and returns the listener to column's property changes.protected PropertyChangeListenerReturns the listener to column's property changes.private voidinstallColumn(TableColumn column) booleanReturns true if the action is enabled.voidCallback method asItemListener.voidReleases all references to the synchedTableColumn.private voidreselect()Enforces selected totrue.voidsetSelected(boolean newValue) Changes the state of the action.private voidupdateFromColumnHeader(Object value) Synchs name property to value.protected voidupdateFromColumnHideable(boolean hideable) private voidupdateFromColumnVisible(boolean visible) Synchs selected property to visible.Methods inherited from class AbstractActionExt
dispose, getAccelerator, getActionCommand, getGroup, getLargeIcon, getLongDescription, getMnemonic, getName, getShortDescription, getSmallIcon, isSelected, isStateAction, setAccelerator, setActionCommand, setGroup, setLargeIcon, setLongDescription, setMnemonic, setMnemonic, setName, setShortDescription, setSmallIcon, setStateAction, setStateAction, toStringMethods inherited from class AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, putValue, removePropertyChangeListener, setEnabled
-
Field Details
-
column
-
columnListener
-
fromColumn
private boolean fromColumnflag to distinguish selection changes triggered by column's property change from those triggered by user interaction. Hack around #212-swingx.
-
-
Constructor Details
-
ColumnVisibilityAction
Creates a action synched to the table column.- Parameters:
column- theTableColumnto keep synched to.
-
-
Method Details
-
releaseColumn
public void releaseColumn()Releases all references to the synchedTableColumn. Client code must call this method if the action is no longer needed. After calling this action must not be used any longer. -
isEnabled
public boolean isEnabled()Returns true if the action is enabled. Returns true only if the action is enabled and the table column can be controlled.- Specified by:
isEnabledin interfaceAction- Overrides:
isEnabledin classAbstractAction- Returns:
- true if the action is enabled, false otherwise
- See Also:
-
canControlColumn
protected boolean canControlColumn()Returns flag to indicate if column's visibility can be controlled. Minimal requirement is that column is of typeTableColumnExt.- Returns:
- boolean to indicate if columns's visibility can be controlled.
-
itemStateChanged
Description copied from class:AbstractActionExtCallback method asItemListener. Updates internal state based on the given ItemEvent.Here: synchs selected property if isStateAction(), does nothing otherwise.
- Specified by:
itemStateChangedin interfaceItemListener- Overrides:
itemStateChangedin classAbstractActionExt- Parameters:
e- the ItemEvent fired by a ItemSelectable on changing the selected state.
-
setSelected
public void setSelected(boolean newValue) Description copied from class:AbstractActionExtChanges the state of the action. This is a convenience method for updating the Action via the value map.- Overrides:
setSelectedin classAbstractActionExt- Parameters:
newValue- true to set the action as selected of the action.- See Also:
-
actionPerformed
Does nothing. Synch from action state to TableColumn state is done in itemStateChanged. -
updateFromColumnVisible
private void updateFromColumnVisible(boolean visible) Synchs selected property to visible. This is called on change of tablecolumn'svisibleproperty.- Parameters:
visible- column visible state to synch to.
-
updateFromColumnHideable
protected void updateFromColumnHideable(boolean hideable) -
updateFromColumnHeader
Synchs name property to value. This is called on change of tableColumn'sheaderValueproperty.- Parameters:
value-
-
reselect
private void reselect()Enforces selected totrue. Called if user interaction tried to de-select the last single visible column. -
installColumn
-
getColumnListener
Returns the listener to column's property changes. The listener is created lazily if necessary.- Returns:
- the
PropertyChangeListenerlistening toTableColumn's property changes, guaranteed to be notnull.
-
createPropertyChangeListener
Creates and returns the listener to column's property changes. Subclasses are free to roll their own.Implementation note: this listener reacts to column's
visibleandheaderValueproperties and calls the respectiveupdateFromXXmethodes.- Returns:
- the
PropertyChangeListenerto use with the column
-