|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.AbstractButton
javax.swing.JButton
org.jdesktop.swingx.table.ColumnControlButton
public class ColumnControlButton
A component to allow interactive customization of JXTable
's
columns.
It's main purpose is to allow toggling of table columns' visibility.
Additionally, arbitrary configuration actions can be exposed.
This component is installed in the JXTable
's
trailing corner, if enabled:
table.setColumnControlVisible(true);
From the perspective of a JXTable
, the component's behaviour is
opaque. Typically, the button's action is to popup a component for user
interaction.
This class is responsible for handling/providing/updating the lists of
actions and to keep all action's state in synch with Table-/Column state.
The visible behaviour of the popup is delegated to a
ColumnControlPopup
.
TableColumnExt
,
TableColumnModelExt
,
JXTable.setColumnControl(javax.swing.JComponent)
,
Serialized FormNested Class Summary | |
---|---|
class |
ColumnControlButton.ColumnVisibilityAction
A specialized Action which takes care of keeping in synch with
TableColumn state. |
class |
ColumnControlButton.DefaultColumnControlPopup
A default implementation of ColumnControlPopup. |
Nested classes/interfaces inherited from class javax.swing.JButton |
---|
JButton.AccessibleJButton |
Nested classes/interfaces inherited from class javax.swing.AbstractButton |
---|
AbstractButton.AccessibleAbstractButton, AbstractButton.ButtonChangeListener |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
static String |
COLUMN_CONTROL_BUTTON_ICON_KEY
the key for looking up the control's icon in the UIManager. |
static String |
COLUMN_CONTROL_BUTTON_MARGIN_KEY
the key for looking up the control's margin in the UIManager. |
static String |
COLUMN_CONTROL_MARKER
Marker to auto-recognize actions which should be added to the popup. |
protected ColumnControlPopup |
popup
exposed for testing. |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface javax.swing.SwingConstants |
---|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
ColumnControlButton(JXTable table)
Creates a column control button for the table. |
|
ColumnControlButton(JXTable table,
Icon icon)
Creates a column control button for the table. |
Method Summary | |
---|---|
protected void |
addAdditionalActionItems()
Adds additional actions to the popup. |
protected void |
addVisibilityActionItems()
Adds visibility actions into the popup view. |
void |
applyComponentOrientation(ComponentOrientation o)
Sets the ComponentOrientation property of this container
and all components contained within it. |
protected boolean |
canControl()
Method to check if we can control column visibility POST: if true we can be sure to have an extended TableColumnModel |
protected void |
clearAll()
removes all components from the popup, making sure to release all columnVisibility actions. |
protected void |
clearColumnVisibilityActions()
Releases actions and clears list of actions. |
protected ColumnControlPopup |
createColumnControlPopup()
Factory method to return a ColumnControlPopup . |
protected TableColumnModelListener |
createColumnModelListener()
Creates the listener to columnModel. |
protected ColumnControlButton.ColumnVisibilityAction |
createColumnVisibilityAction(TableColumn column)
Creates and returns a ColumnVisibilityAction for the given
TableColumn . |
protected PropertyChangeListener |
createTablePropertyChangeListener()
Creates the listener to table's property changes. |
protected void |
createVisibilityActions()
Creates and adds a ColumnVisiblityAction for every column that should be togglable via the column control. |
protected List<Action> |
getAdditionalActions()
creates and returns a list of additional Actions to add to the popup. |
protected List |
getColumnControlActionKeys()
Looks up and returns action keys to access actions in the table's actionMap which should be included into the popup. |
protected ColumnControlPopup |
getColumnControlPopup()
Returns to popup component for user interaction. |
protected TableColumnModelListener |
getColumnModelListener()
Returns the listener to table's column model. |
protected List<ColumnControlButton.ColumnVisibilityAction> |
getColumnVisibilityActions()
Lazyly creates and returns the List of visibility actions. |
protected PropertyChangeListener |
getTablePropertyChangeListener()
Returns the listener to table's property changes. |
protected boolean |
isColumnControlActionKey(Object actionKey)
Here: true if a String key starts with #COLUMN_CONTROL_MARKER. |
protected void |
populatePopup()
Populates the popup from scratch. |
void |
togglePopup()
Toggles the popup component's visibility. |
protected void |
updateActionUI()
Updates the action properties provided by the LAF. |
protected void |
updateButtonUI()
Updates this button's properties provided by the LAF. |
protected void |
updateFromColumnModelChange(TableColumnModel oldModel)
Adjusts internal state after table's column model property has changed. |
protected void |
updateFromTableEnabledChanged()
Synchs this button's enabled with table's enabled. |
void |
updateUI()
Resets the UI property to a value from the current look and feel. |
Methods inherited from class javax.swing.JButton |
---|
configurePropertiesFromAction, getAccessibleContext, getUIClassID, isDefaultButton, isDefaultCapable, paramString, removeNotify, setDefaultCapable |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String COLUMN_CONTROL_MARKER
public static final String COLUMN_CONTROL_BUTTON_ICON_KEY
public static final String COLUMN_CONTROL_BUTTON_MARGIN_KEY
protected ColumnControlPopup popup
Constructor Detail |
---|
public ColumnControlButton(JXTable table)
table
- the JXTable
controlled by this componentpublic ColumnControlButton(JXTable table, Icon icon)
table
- the JXTable
controlled by this componenticon
- the Icon
to showMethod Detail |
---|
public void updateUI()
javax.swing.JButton
updateUI
in class JButton
JComponent.updateUI()
protected void updateButtonUI()
protected void updateActionUI()
public void togglePopup()
Here: delegates to getControlPopup().
public void applyComponentOrientation(ComponentOrientation o)
java.awt.Container
ComponentOrientation
property of this container
and all components contained within it.
applyComponentOrientation
in class Container
o
- the new component orientation of this container and
the components contained within it.Component.setComponentOrientation(java.awt.ComponentOrientation)
,
Component.getComponentOrientation()
protected ColumnControlPopup getColumnControlPopup()
null
.createColumnControlPopup()
protected ColumnControlPopup createColumnControlPopup()
ColumnControlPopup
.
Subclasses can override to hook custom implementations.
ColumnControlPopup
used.protected void updateFromColumnModelChange(TableColumnModel oldModel)
oldModel
- the old TableColumnModel
we had been listening to.protected void updateFromTableEnabledChanged()
protected boolean canControl()
protected void populatePopup()
protected void clearAll()
protected void clearColumnVisibilityActions()
protected void addVisibilityActionItems()
PRE: columnVisibilityActions populated before calling this.
protected void addAdditionalActionItems()
protected void createVisibilityActions()
Here: all table columns contained in the TableColumnModel
-
visible and invisible columns - to createColumnVisibilityAction
and
adds all not null
return values.
PRE: canControl()
createColumnVisibilityAction(javax.swing.table.TableColumn)
protected ColumnControlButton.ColumnVisibilityAction createColumnVisibilityAction(TableColumn column)
ColumnVisibilityAction
for the given
TableColumn
. The return value might be null, f.i. if the
column should not be allowed to be toggled.
column
- the TableColumn
to use for the action
null
.protected List<ColumnControlButton.ColumnVisibilityAction> getColumnVisibilityActions()
protected List<Action> getAdditionalActions()
protected List getColumnControlActionKeys()
protected boolean isColumnControlActionKey(Object actionKey)
actionKey
- a key in the table's actionMap.
protected PropertyChangeListener getTablePropertyChangeListener()
PropertyChangeListener
for use with the
table, guaranteed to be not null
.protected PropertyChangeListener createTablePropertyChangeListener()
Implementation note: this listener reacts to table's enabled
and
columnModel
properties and calls the respective
updateFromXX
methodes.
PropertyChangeListener
for use with the table.protected TableColumnModelListener getColumnModelListener()
TableColumnModelListener
for use with the
table's column model, guaranteed to be not null
.protected TableColumnModelListener createColumnModelListener()
Implementation note: this listener reacts to "real" columnRemoved/-Added by populating the popups content from scratch.
TableColumnModelListener
for use with the
table's columnModel.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |