|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.swing.table.TableColumn
org.jdesktop.swingx.table.TableColumnExt
public class TableColumnExt
TableColumn extension for enhanced view column configuration.
The general drift is to strengthen the TableColumn abstraction as the
place to configure and dynamically update view column properties, covering a
broad range of customization requirements. Using collaborators are expected
to listen to property changes and update themselves accordingly.
A functionality enhancement is the notion of column visibility:
TableColumnModelExt manages sets of visible/hidden
TableColumnExts controlled by the columns'
visible property. Typically, users can toggle column
visibility at runtime, f.i. through a dedicated control in the upper trailing
corner of a JScrollPane.
A prominent group of properties allows fine-grained, per-column control of corresponding Table/-Header features.
sortable controls whether this column
should be sortable by user's sort gestures; Comparator can
hold a column specific type.
editable controls whether cells of this
column should be accessible to in-table editing.
toolTipText holds the column tooltip
which is shown when hovering over the column's header.
highlighters holds the column
highlighters; these are applied to the renderer after the table highlighters.
Any modification of the list of contained Highlighters
(setting them, adding one or removing one) will result in a
PropertyChangeEvent being fired for "highlighters". State changes on
contained Highlighters will result in a PropertyChangeEvent
for "highlighterStateChanged".
JComponent, this class supports per-instance
"client" properties. They are meant as a small-scale extension mechanism.
They are similar to regular bean properties in that registered
PropertyChangeListeners are notified about changes. TODO:
example?
A TableColumnExt implements UIDependent, that is it takes over
responsibility to update LAF dependent properties of contained elements when
messaged with updateUI. This implementation updates its Highlighters,
Cell-/HeaderRenderer and CellEditor.
TODO: explain prototype (sizing, collaborator-used-by ColumnFactory (?))
TableColumnModelExt,
ColumnFactory,
UIDependent,
JComponent.putClientProperty(java.lang.Object, java.lang.Object),
Serialized Form| Field Summary | |
|---|---|
protected java.util.Hashtable<java.lang.Object,java.lang.Object> |
clientProperties
storage for client properties. |
protected java.util.Comparator<?> |
comparator
per-column comparator |
protected CompoundHighlighter |
compoundHighlighter
The compound highlighter for the column. |
protected boolean |
editable
per-column editable property. |
protected java.lang.Object |
prototypeValue
prototype property. |
protected boolean |
sortable
per-column sortable property. |
protected boolean |
visible
visible property. |
| Fields inherited from class javax.swing.table.TableColumn |
|---|
CELL_RENDERER_PROPERTY, cellEditor, cellRenderer, COLUMN_WIDTH_PROPERTY, HEADER_RENDERER_PROPERTY, HEADER_VALUE_PROPERTY, headerRenderer, headerValue, identifier, isResizable, maxWidth, minWidth, modelIndex, resizedPostingDisableCount, width |
| Constructor Summary | |
|---|---|
TableColumnExt()
Creates new table view column with a model index = 0. |
|
TableColumnExt(int modelIndex)
Creates new table view column with the specified model index. |
|
TableColumnExt(int modelIndex,
int width)
Creates new table view column with the specified model index and column width. |
|
TableColumnExt(int modelIndex,
int width,
javax.swing.table.TableCellRenderer cellRenderer,
javax.swing.table.TableCellEditor cellEditor)
Creates new table view column with the specified model index, column width, cell renderer and cell editor. |
|
TableColumnExt(TableColumnExt columnExt)
Instantiates a new table view column with all properties copied from the given original. |
|
| Method Summary | |
|---|---|
void |
addHighlighter(Highlighter highlighter)
Appends a Highlighter to the end of the list of used
Highlighters. |
protected void |
copyClientPropertiesFrom(TableColumnExt original)
Copies all clientProperties of this TableColumnExt
to the target column. |
protected void |
copyFrom(TableColumnExt original)
Copies properties from original. |
protected javax.swing.event.ChangeListener |
createHighlighterChangeListener()
Creates and returns the ChangeListener observing Highlighters. |
protected void |
firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
Notifies registered PropertyChangeListeners
about property changes. |
java.lang.Object |
getClientProperty(java.lang.Object key)
Returns the value of the property with the specified key. |
java.util.Comparator<?> |
getComparator()
Returns the comparator to use for the column. |
protected CompoundHighlighter |
getCompoundHighlighter()
Returns the CompoundHighlighter assigned to the table, null if none. |
protected javax.swing.event.ChangeListener |
getHighlighterChangeListener()
Returns the ChangeListener to use with highlighters. |
Highlighter[] |
getHighlighters()
Returns the Highlighters used by this table. |
java.lang.Object |
getPrototypeValue()
Returns the prototypeValue property. |
boolean |
getResizable()
Returns true if the user can resize the TableColumn's width, false otherwise. |
java.lang.String |
getTitle()
Convenience method which returns the headerValue property after converting it to a string. |
java.lang.String |
getToolTipText()
Returns the text of to display in the column's tool tip. |
boolean |
isEditable()
Returns the per-column editable property. |
boolean |
isSortable()
Returns the sortable property. |
boolean |
isVisible()
Returns the visible property. |
void |
putClientProperty(java.lang.Object key,
java.lang.Object value)
Sets the client property "key" to value. |
void |
removeHighlighter(Highlighter highlighter)
Removes the given Highlighter. |
void |
setComparator(java.util.Comparator<?> comparator)
Sets the comparator to use for this column. |
void |
setEditable(boolean editable)
Sets the editable property. |
void |
setHighlighters(Highlighter... highlighters)
Sets the Highlighters to the table, replacing any old settings. |
void |
setPrototypeValue(java.lang.Object value)
Sets the prototypeValue property. |
void |
setSortable(boolean sortable)
Sets the sortable property. |
void |
setTitle(java.lang.String title)
Sets the title of this view column. |
void |
setToolTipText(java.lang.String toolTipText)
Registers the text to display in the column's tool tip. |
void |
setVisible(boolean visible)
Sets the visible property. |
void |
updateUI()
Update ui of owned ui-dependent parts. |
| Methods inherited from class javax.swing.table.TableColumn |
|---|
addPropertyChangeListener, createDefaultHeaderRenderer, disableResizedPosting, enableResizedPosting, getCellEditor, getCellRenderer, getHeaderRenderer, getHeaderValue, getIdentifier, getMaxWidth, getMinWidth, getModelIndex, getPreferredWidth, getPropertyChangeListeners, getWidth, removePropertyChangeListener, setCellEditor, setCellRenderer, setHeaderRenderer, setHeaderValue, setIdentifier, setMaxWidth, setMinWidth, setModelIndex, setPreferredWidth, setResizable, setWidth, sizeWidthToFit |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected boolean visible
true.
protected java.lang.Object prototypeValue
protected java.util.Comparator<?> comparator
protected boolean sortable
true.
protected boolean editable
true.
protected java.util.Hashtable<java.lang.Object,java.lang.Object> clientProperties
protected CompoundHighlighter compoundHighlighter
| Constructor Detail |
|---|
public TableColumnExt()
public TableColumnExt(int modelIndex)
modelIndex - index of table model column to which this view column
is bound.
public TableColumnExt(int modelIndex,
int width)
modelIndex - index of table model column to which this view column
is bound.width - pixel width of view column
public TableColumnExt(int modelIndex,
int width,
javax.swing.table.TableCellRenderer cellRenderer,
javax.swing.table.TableCellEditor cellEditor)
modelIndex - index of table model column to which this view column
is bound.width - pixel width of view columncellRenderer - the cell renderer which will render all cells in this
view columncellEditor - the cell editor which will edit cells in this view columnpublic TableColumnExt(TableColumnExt columnExt)
columnExt - the column to copy properties fromcopyFrom(TableColumnExt)| Method Detail |
|---|
public void setHighlighters(Highlighter... highlighters)
Highlighters to the table, replacing any old settings.
None of the given Highlighters must be null.This is a bound property.
Note: as of version #1.257 the null constraint is enforced strictly. To remove all highlighters use this method without param.
highlighters - zero or more not null highlighters to use for renderer decoration.
java.lang.NullPointerException - if array is null or array contains null values.getHighlighters(),
addHighlighter(Highlighter),
removeHighlighter(Highlighter)public Highlighter[] getHighlighters()
Highlighters used by this table.
Maybe empty, but guarantees to be never null.
setHighlighters(Highlighter[])public void addHighlighter(Highlighter highlighter)
Highlighter to the end of the list of used
Highlighters. The argument must not be null.
highlighter - the Highlighter to add, must not be null.
java.lang.NullPointerException - if Highlighter is null.removeHighlighter(Highlighter),
setHighlighters(Highlighter[])public void removeHighlighter(Highlighter highlighter)
Does nothing if the Highlighter is not contained.
highlighter - the Highlighter to remove.addHighlighter(Highlighter),
setHighlighters(Highlighter...)protected CompoundHighlighter getCompoundHighlighter()
protected javax.swing.event.ChangeListener getHighlighterChangeListener()
ChangeListener to use with highlighters. Lazily
creates the listener.
not-nullprotected javax.swing.event.ChangeListener createHighlighterChangeListener()
Here: repaints the table on receiving a stateChanged.
public boolean getResizable()
getResizable in class javax.swing.table.TableColumnpublic void setEditable(boolean editable)
TableModel.isCellEditable. If the cell is
read-only in the model layer, this property will have no effect.
editable - boolean indicating whether or not the user may edit cell
values in this view columnisEditable(),
JXTable.isCellEditable(int, int),
TableModel.isCellEditable(int, int)public boolean isEditable()
true.
setEditable(boolean)public void setPrototypeValue(java.lang.Object value)
value - Object containing the value of the prototype to be used
to calculate the initial preferred width of the columngetPrototypeValue(),
JXTable.getPreferredScrollableViewportSize()public java.lang.Object getPrototypeValue()
null.
setPrototypeValue(java.lang.Object)public void setComparator(java.util.Comparator<?> comparator)
JXTable sorting api respects this property by passing it on
to the SortController.
comparator - a custom comparator to use in interactive
sorting.getComparator(),
SortController,
org.jdesktop.swingx.decorator.SortKeypublic java.util.Comparator<?> getComparator()
null.
Comparator to use for this columnsetComparator(java.util.Comparator>)public void setSortable(boolean sortable)
JXTable sorting api respects this
property by disabling interactive sorting on this column if false.
sortable - boolean indicating whether or not this column can
be sorted in the tableisSortable()public boolean isSortable()
true.
setSortable(boolean)public void setToolTipText(java.lang.String toolTipText)
JXTableHeader to
display when the mouse cursor lingers over the column's
header cell.
toolTipText - text to show.setToolTipText(String)public java.lang.String getToolTipText()
null.
setToolTipText(String)public void setTitle(java.lang.String title)
setHeaderValue.
title - String containing the title of this view columnpublic java.lang.String getTitle()
public void setVisible(boolean visible)
visible - boolean indicating whether or not this view column is
visible in the tablesetVisible(boolean)public boolean isVisible()
true.
setVisible(boolean)
public void putClientProperty(java.lang.Object key,
java.lang.Object value)
value.
If value is null this method will remove the property.
Changes to
client properties are reported with PropertyChange events.
The name of the property (for the sake of PropertyChange events) is
key.toString().
The get/putClientProperty methods provide access to a
per-instance hashtable, which is intended for small scale extensions of
TableColumn.
key - Object which is used as key to retrieve valuevalue - Object containing value of client property
java.lang.IllegalArgumentException - if key is nullgetClientProperty(java.lang.Object),
JComponent.putClientProperty(java.lang.Object, java.lang.Object)public java.lang.Object getClientProperty(java.lang.Object key)
putClientProperty will return a non-null
value.
key - Object which is used as key to retrieve value
nullputClientProperty(java.lang.Object, java.lang.Object)protected void copyFrom(TableColumnExt original)
original - the tableColumn to copy fromTableColumnExt(TableColumnExt)protected void copyClientPropertiesFrom(TableColumnExt original)
TableColumnExt
to the target column.
original - the target column.
protected void firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
PropertyChangeListeners
about property changes. This method must be invoked internally
whe any of the enhanced properties changed.
Implementation note: needed to replicate super
functionality because super's field propertyChangeSupport
and method fireXX are both private.
propertyName - name of changed propertyoldValue - old value of changed propertynewValue - new value of changed propertypublic void updateUI()
updateUI in interface UIDependentJComponent.updateUI()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||