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:
java.awt.event.ActionListener
,java.awt.event.ItemListener
,java.io.Serializable
,java.lang.Cloneable
,java.util.EventListener
,javax.swing.Action
- Enclosing class:
- ColumnControlButton
public class ColumnControlButton.ColumnVisibilityAction extends AbstractActionExt
A specializedAction
which takes care of keeping in synch with TableColumn state. NOTE: client must call releaseColumn if this action is no longer needed!- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private javax.swing.table.TableColumn
column
private java.beans.PropertyChangeListener
columnListener
private boolean
fromColumn
flag to distinguish selection changes triggered by column's property change from those triggered by user interaction.-
Fields inherited from class org.jdesktop.swingx.action.AbstractActionExt
GROUP, IS_STATE, LARGE_ICON
-
-
Constructor Summary
Constructors Constructor Description ColumnVisibilityAction(javax.swing.table.TableColumn column)
Creates a action synched to the table column.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(java.awt.event.ActionEvent e)
Does nothing.protected boolean
canControlColumn()
Returns flag to indicate if column's visibility can be controlled.protected java.beans.PropertyChangeListener
createPropertyChangeListener()
Creates and returns the listener to column's property changes.protected java.beans.PropertyChangeListener
getColumnListener()
Returns the listener to column's property changes.private void
installColumn(javax.swing.table.TableColumn column)
boolean
isEnabled()
Returns true if the action is enabled.void
itemStateChanged(java.awt.event.ItemEvent e)
Callback method asItemListener
.void
releaseColumn()
Releases all references to the synchedTableColumn
.private void
reselect()
Enforces selected totrue
.void
setSelected(boolean newValue)
Changes the state of the action.private void
updateFromColumnHeader(java.lang.Object value)
Synchs name property to value.protected void
updateFromColumnHideable(boolean hideable)
private void
updateFromColumnVisible(boolean visible)
Synchs selected property to visible.-
Methods 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
-
-
-
-
Field Detail
-
column
private javax.swing.table.TableColumn column
-
columnListener
private java.beans.PropertyChangeListener columnListener
-
fromColumn
private boolean fromColumn
flag to distinguish selection changes triggered by column's property change from those triggered by user interaction. Hack around #212-swingx.
-
-
Method Detail
-
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 interfacejavax.swing.Action
- Overrides:
isEnabled
in classjavax.swing.AbstractAction
- Returns:
- true if the action is enabled, false otherwise
- See Also:
canControlColumn()
-
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
public void itemStateChanged(java.awt.event.ItemEvent e)
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 interfacejava.awt.event.ItemListener
- 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. This is a convenience method for updating the Action via the value map.- Overrides:
setSelected
in classAbstractActionExt
- Parameters:
newValue
- true to set the action as selected of the action.- See Also:
Action.SELECTED_KEY
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent e)
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'svisible
property.- Parameters:
visible
- column visible state to synch to.
-
updateFromColumnHideable
protected void updateFromColumnHideable(boolean hideable)
-
updateFromColumnHeader
private void updateFromColumnHeader(java.lang.Object value)
Synchs name property to value. This is called on change of tableColumn'sheaderValue
property.- Parameters:
value
-
-
reselect
private void reselect()
Enforces selected totrue
. Called if user interaction tried to de-select the last single visible column.
-
installColumn
private void installColumn(javax.swing.table.TableColumn column)
-
getColumnListener
protected java.beans.PropertyChangeListener 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
protected java.beans.PropertyChangeListener 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
-
-