Package org.jdesktop.swingx.table
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
Fields inherited from class org.jdesktop.swingx.action.AbstractActionExt
GROUP, IS_STATE, LARGE_ICON
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.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 TypeMethodDescriptionvoid
Does nothing.protected boolean
Returns flag to indicate if column's visibility can be controlled.protected PropertyChangeListener
Creates and returns the listener to column's property changes.protected PropertyChangeListener
Returns the listener to column's property changes.boolean
Returns true if the action is enabled.void
Callback method asItemListener
.void
Releases all references to the synchedTableColumn
.void
setSelected
(boolean newValue) Changes the state of the actionMethods inherited from class org.jdesktop.swingx.action.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, toString
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, putValue, removePropertyChangeListener, setEnabled
-
Constructor Details
-
ColumnVisibilityAction
Creates a action synched to the table column.- Parameters:
column
- theTableColumn
to 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:
isEnabled
in interfaceAction
- Overrides:
isEnabled
in 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:AbstractActionExt
Callback method asItemListener
. Updates internal state based on the given ItemEvent.Here: synchs selected property if isStateAction(), does nothing otherwise.
- Specified by:
itemStateChanged
in interfaceItemListener
- Overrides:
itemStateChanged
in classAbstractActionExt
- Parameters:
e
- the ItemEvent fired by a ItemSelectable on changing the selected state.
-
setSelected
public void setSelected(boolean newValue) Description copied from class:AbstractActionExt
Changes the state of the action- Overrides:
setSelected
in classAbstractActionExt
- Parameters:
newValue
- true to set the action as selected of the action.
-
actionPerformed
Does nothing. Synch from action state to TableColumn state is done in itemStateChanged. -
getColumnListener
Returns the listener to column's property changes. The listener is created lazily if necessary.- Returns:
- the
PropertyChangeListener
listening 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
visible
andheaderValue
properties and calls the respectiveupdateFromXX
methodes.- Returns:
- the
PropertyChangeListener
to use with the column
-