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

public class ColumnControlButton.ColumnVisibilityAction extends AbstractActionExt
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 Details

    • column

      private TableColumn column
    • columnListener

      private 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.
  • Constructor Details

    • ColumnVisibilityAction

      public ColumnVisibilityAction(TableColumn column)
      Creates a action synched to the table column.
      Parameters:
      column - the TableColumn to keep synched to.
  • Method Details

    • releaseColumn

      public void releaseColumn()
      Releases all references to the synched TableColumn. 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 interface Action
      Overrides:
      isEnabled in class AbstractAction
      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 type TableColumnExt.
      Returns:
      boolean to indicate if columns's visibility can be controlled.
    • itemStateChanged

      public void itemStateChanged(ItemEvent e)
      Description copied from class: AbstractActionExt
      Callback method as ItemListener. Updates internal state based on the given ItemEvent.

      Here: synchs selected property if isStateAction(), does nothing otherwise.

      Specified by:
      itemStateChanged in interface ItemListener
      Overrides:
      itemStateChanged in class AbstractActionExt
      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 class AbstractActionExt
      Parameters:
      newValue - true to set the action as selected of the action.
      See Also:
    • actionPerformed

      public void actionPerformed(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's visible property.
      Parameters:
      visible - column visible state to synch to.
    • updateFromColumnHideable

      protected void updateFromColumnHideable(boolean hideable)
    • updateFromColumnHeader

      private void updateFromColumnHeader(Object value)
      Synchs name property to value. This is called on change of tableColumn's headerValue property.
      Parameters:
      value -
    • reselect

      private void reselect()
      Enforces selected to true. Called if user interaction tried to de-select the last single visible column.
    • installColumn

      private void installColumn(TableColumn column)
    • getColumnListener

      protected PropertyChangeListener getColumnListener()
      Returns the listener to column's property changes. The listener is created lazily if necessary.
      Returns:
      the PropertyChangeListener listening to TableColumn's property changes, guaranteed to be not null.
    • createPropertyChangeListener

      protected 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 and headerValue properties and calls the respective updateFromXX methodes.

      Returns:
      the PropertyChangeListener to use with the column