S
- The type of the UI control (e.g. the type of the 'row').T
- The type of the content in all cells in this table column.@IDProperty(value="id") public abstract class TableColumnBase<S,T> extends java.lang.Object implements EventTarget, Styleable
TableView
and TreeTableView
) are
made up of zero or more instances of a concrete TableColumnBase subclass
(TableColumn
and TreeTableColumn
, respectively). Each
table column in a table is responsible for displaying (and editing) the contents
of that column. As well as being responsible for displaying and editing data
for a single column, a table column also contains the necessary properties to:
minWidth
/prefWidth
/maxWidth
and width
properties)
visibility
toggled
header text
nested columns
it may contain
context menu
when the user
right-clicks the column header area
comparator
, sortable
and
sortType).
text
(what to show in the column header area), and the column
cell value factory
(which is used to populate individual cells in the
column). Refer to the class documentation for TableColumn
and
TreeTableColumn
for more information.TableColumn
,
TreeTableColumn
,
TablePositionBase
Modifier and Type | Field and Description |
---|---|
private ObjectProperty<java.util.Comparator<T>> |
comparator
Comparator function used when sorting this table column.
|
private ObjectProperty<ContextMenu> |
contextMenu
This menu will be shown whenever the user right clicks within the header
area of this TableColumnBase.
|
static java.util.Comparator |
DEFAULT_COMPARATOR
By default all columns will use this comparator to perform sorting.
|
(package private) static double |
DEFAULT_MAX_WIDTH |
(package private) static double |
DEFAULT_MIN_WIDTH |
(package private) static double |
DEFAULT_WIDTH
*
Static properties and methods *
*
|
private BooleanProperty |
editable
Specifies whether this table column allows editing.
|
(package private) EventHandlerManager |
eventHandlerManager
*
Instance Variables *
*
|
private BooleanProperty |
fixed |
private ObjectProperty<Node> |
graphic
The graphic to show in the table column to allow the user to
indicate graphically what is in the column.
|
private StringProperty |
id
The id of this TableColumnBase.
|
private DoubleProperty |
maxWidth |
private DoubleProperty |
minWidth
The minimum width the table column is permitted to be resized to.
|
private ReadOnlyObjectWrapper<TableColumnBase<S,?>> |
parentColumn
This read-only property will always refer to the parent of this column,
in the situation where nested columns are being used.
|
private DoubleProperty |
prefWidth |
private ObservableMap<java.lang.Object,java.lang.Object> |
properties |
private BooleanProperty |
reorderable |
private BooleanProperty |
resizable
Used to indicate whether the width of this column can change.
|
private BooleanProperty |
sortable
A boolean property to toggle on and off the 'sortability' of this column.
|
private ObjectProperty<Node> |
sortNode
The node to use as the "sort arrow", shown to the user in situations where
the table column is part of the sort order.
|
private StringProperty |
style
A string representation of the CSS style associated with this
TableColumnBase instance.
|
private ObservableList<java.lang.String> |
styleClass |
private StringProperty |
text
This is the text to show in the header for this column.
|
private static java.lang.Object |
USER_DATA_KEY |
private BooleanProperty |
visible
Toggling this will immediately toggle the visibility of this column,
and all children columns.
|
private ReadOnlyDoubleWrapper |
width |
Modifier | Constructor and Description |
---|---|
protected |
TableColumnBase()
Creates a default TableColumn with default cell factory, comparator, and
onEditCommit implementation.
|
protected |
TableColumnBase(java.lang.String text)
Creates a TableColumn with the text set to the provided string, with
default cell factory, comparator, and onEditCommit implementation.
|
Modifier and Type | Method and Description |
---|---|
<E extends Event> |
addEventHandler(EventType<E> eventType,
EventHandler<E> eventHandler)
Registers an event handler to this table column.
|
EventDispatchChain |
buildEventDispatchChain(EventDispatchChain tail)
Construct an event dispatch chain for this target.
|
ObjectProperty<java.util.Comparator<T>> |
comparatorProperty() |
ObjectProperty<ContextMenu> |
contextMenuProperty() |
BooleanProperty |
editableProperty() |
T |
getCellData(int index)
Returns the actual value for a cell at a given row index (and which
belongs to this table column).
|
T |
getCellData(S item)
Returns the actual value for a cell from the given item.
|
abstract ObservableValue<T> |
getCellObservableValue(int index)
Attempts to return an ObservableValue<T> for the item in the given
index (which is of type S).
|
abstract ObservableValue<T> |
getCellObservableValue(S item)
Attempts to return an ObservableValue<T> for the given item (which
is of type S).
|
abstract ObservableList<? extends TableColumnBase<S,?>> |
getColumns()
This enables support for nested columns, which can be useful to group
together related data.
|
java.util.Comparator<T> |
getComparator() |
ContextMenu |
getContextMenu() |
Node |
getGraphic() |
java.lang.String |
getId()
The id of this
Styleable . |
double |
getMaxWidth() |
double |
getMinWidth() |
TableColumnBase<S,?> |
getParentColumn() |
double |
getPrefWidth() |
ObservableMap<java.lang.Object,java.lang.Object> |
getProperties()
Returns an observable map of properties on this table column for use
primarily by application developers.
|
ObservableSet<PseudoClass> |
getPseudoClassStates()
Return the pseudo-class state of this Styleable.
|
Node |
getSortNode() |
java.lang.String |
getStyle()
A string representation of the CSS style associated with this
specific
Node . |
ObservableList<java.lang.String> |
getStyleClass()
A list of String identifiers which can be used to logically group
Nodes, specifically for an external style engine.
|
java.lang.String |
getText() |
java.lang.Object |
getUserData()
Returns a previously set Object property, or null if no such property
has been set using the
setUserData(java.lang.Object) method. |
double |
getWidth() |
ObjectProperty<Node> |
graphicProperty() |
boolean |
hasProperties()
Tests if this table column has properties.
|
StringProperty |
idProperty() |
BooleanProperty |
impl_fixedProperty()
Deprecated.
This is an internal API that is not intended for use and will be removed in the next version
|
boolean |
impl_isFixed()
Deprecated.
This is an internal API that is not intended for use and will be removed in the next version
|
boolean |
impl_isReorderable()
Deprecated.
This is an internal API that is not intended for use and will be removed in the next version
|
BooleanProperty |
impl_reorderableProperty()
Deprecated.
This is an internal API that is not intended for use and will be removed in the next version
|
void |
impl_setFixed(boolean value)
Deprecated.
This is an internal API that is not intended for use and will be removed in the next version
|
void |
impl_setReorderable(boolean value)
Deprecated.
This is an internal API that is not intended for use and will be removed in the next version
|
void |
impl_setWidth(double width)
Deprecated.
This is an internal API that is not intended for use and will be removed in the next version
|
boolean |
isEditable() |
boolean |
isResizable() |
boolean |
isSortable() |
boolean |
isVisible() |
DoubleProperty |
maxWidthProperty()
The maximum width the table column is permitted to be resized to.
|
DoubleProperty |
minWidthProperty() |
ReadOnlyObjectProperty<TableColumnBase<S,?>> |
parentColumnProperty() |
private ReadOnlyObjectWrapper<TableColumnBase<S,?>> |
parentColumnPropertyImpl() |
DoubleProperty |
prefWidthProperty()
The preferred width of the TableColumn.
|
<E extends Event> |
removeEventHandler(EventType<E> eventType,
EventHandler<E> eventHandler)
Unregisters a previously registered event handler from this table column.
|
BooleanProperty |
resizableProperty() |
void |
setComparator(java.util.Comparator<T> value) |
void |
setContextMenu(ContextMenu value) |
void |
setEditable(boolean value) |
void |
setGraphic(Node value) |
void |
setId(java.lang.String value) |
void |
setMaxWidth(double value) |
void |
setMinWidth(double value) |
(package private) void |
setParentColumn(TableColumnBase<S,?> value) |
void |
setPrefWidth(double value) |
void |
setResizable(boolean value) |
void |
setSortable(boolean value) |
void |
setSortNode(Node value) |
void |
setStyle(java.lang.String value) |
void |
setText(java.lang.String value) |
void |
setUserData(java.lang.Object value)
Convenience method for setting a single Object property that can be
retrieved at a later date.
|
void |
setVisible(boolean value) |
(package private) void |
setWidth(double value) |
BooleanProperty |
sortableProperty() |
ObjectProperty<Node> |
sortNodeProperty() |
StringProperty |
styleProperty() |
StringProperty |
textProperty() |
(package private) void |
updateColumnWidths() |
BooleanProperty |
visibleProperty() |
ReadOnlyDoubleProperty |
widthProperty()
The width of this column.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getCssMetaData, getStyleableParent, getTypeSelector
static final double DEFAULT_WIDTH
static final double DEFAULT_MIN_WIDTH
static final double DEFAULT_MAX_WIDTH
public static final java.util.Comparator DEFAULT_COMPARATOR
Comparable
. If it is, the Comparable.compareTo(java.lang.Object)
method is called, otherwise this method will defer to
Collator.compare(java.lang.String, java.lang.String)
.final EventHandlerManager eventHandlerManager
private StringProperty text
private BooleanProperty visible
private ReadOnlyObjectWrapper<TableColumnBase<S,?>> parentColumn
In the currently existing subclasses, to create a nested
column is simply a matter of placing the relevant TableColumnBase instances
inside the columns ObservableList (for example, see
TableColumn.getColumns()
and
TreeTableColumn.getColumns()
.
private ObjectProperty<ContextMenu> contextMenu
private StringProperty id
null
.private StringProperty style
Parsing this style might not be supported on some limited platforms. It is recommended to use a standalone CSS file instead.
private final ObservableList<java.lang.String> styleClass
private ObjectProperty<Node> graphic
The graphic to show in the table column to allow the user to indicate graphically what is in the column.
private ObjectProperty<Node> sortNode
The node to use as the "sort arrow", shown to the user in situations where
the table column is part of the sort order. It may be the only item in
the sort order, or it may be a secondary, tertiary, or latter sort item,
and the node should reflect this visually. This is only used in the case of
the table column being in the sort order (refer to, for example,
TableView.getSortOrder()
and TreeTableView.getSortOrder()
).
If not specified, the table column skin implementation is responsible for
providing a default sort node.
The sort node is commonly seen represented as a triangle that rotates on screen to indicate whether the table column is part of the sort order, and if so, whether the sort is ascending or descending, and what position in the sort order it is in.
private ReadOnlyDoubleWrapper width
private DoubleProperty minWidth
private final DoubleProperty prefWidth
private DoubleProperty maxWidth
private BooleanProperty resizable
private BooleanProperty sortable
A boolean property to toggle on and off the 'sortability' of this column.
When this property is true, this column can be included in sort
operations. If this property is false, it will not be included in sort
operations, even if it is contained within the sort order list of the
underlying UI control (e.g. TableView.getSortOrder()
or
TreeTableView.getSortOrder()
).
For example, iIf a TableColumn instance is contained within the TableView sortOrder ObservableList, and its sortable property toggles state, it will force the TableView to perform a sort, as it is likely the view will need updating.
private BooleanProperty reorderable
private BooleanProperty fixed
private ObjectProperty<java.util.Comparator<T>> comparator
private BooleanProperty editable
TableView.editableProperty()
and
TreeTableView.editableProperty()
, is true by default.private static final java.lang.Object USER_DATA_KEY
private ObservableMap<java.lang.Object,java.lang.Object> properties
protected TableColumnBase()
protected TableColumnBase(java.lang.String text)
text
- The string to show when the TableColumn is placed within the TableView.public final StringProperty textProperty()
public final void setText(java.lang.String value)
public final java.lang.String getText()
public final void setVisible(boolean value)
public final boolean isVisible()
public final BooleanProperty visibleProperty()
void setParentColumn(TableColumnBase<S,?> value)
public final TableColumnBase<S,?> getParentColumn()
public final ReadOnlyObjectProperty<TableColumnBase<S,?>> parentColumnProperty()
private ReadOnlyObjectWrapper<TableColumnBase<S,?>> parentColumnPropertyImpl()
public final void setContextMenu(ContextMenu value)
public final ContextMenu getContextMenu()
public final ObjectProperty<ContextMenu> contextMenuProperty()
public final void setId(java.lang.String value)
public final java.lang.String getId()
Styleable
Styleable
. This simple string identifier is useful for
finding a specific Node within the scene graph. While the id of a Node
should be unique within the scene graph, this uniqueness is not enforced.
This is analogous to the "id" attribute on an HTML element
(CSS ID Specification).
For example, if a Node is given the id of "myId", then the lookup method can
be used to find this node as follows: scene.lookup("#myId");
.
public final StringProperty idProperty()
public final void setStyle(java.lang.String value)
public final java.lang.String getStyle()
Styleable
Node
. This is analogous to the "style" attribute of an
HTML element. Note that, like the HTML style attribute, this
variable contains style properties and values and not the
selector portion of a style rule.public final StringProperty styleProperty()
public ObservableList<java.lang.String> getStyleClass()
getStyleClass
in interface Styleable
public final void setGraphic(Node value)
public final Node getGraphic()
public final ObjectProperty<Node> graphicProperty()
public final void setSortNode(Node value)
public final Node getSortNode()
public final ObjectProperty<Node> sortNodeProperty()
public final ReadOnlyDoubleProperty widthProperty()
public final double getWidth()
void setWidth(double value)
public final void setMinWidth(double value)
public final double getMinWidth()
public final DoubleProperty minWidthProperty()
public final DoubleProperty prefWidthProperty()
public final void setPrefWidth(double value)
public final double getPrefWidth()
public final DoubleProperty maxWidthProperty()
public final void setMaxWidth(double value)
public final double getMaxWidth()
public final BooleanProperty resizableProperty()
public final void setResizable(boolean value)
public final boolean isResizable()
public final BooleanProperty sortableProperty()
public final void setSortable(boolean value)
public final boolean isSortable()
@Deprecated public final BooleanProperty impl_reorderableProperty()
@Deprecated public final void impl_setReorderable(boolean value)
@Deprecated public final boolean impl_isReorderable()
@Deprecated public final BooleanProperty impl_fixedProperty()
@Deprecated public final void impl_setFixed(boolean value)
@Deprecated public final boolean impl_isFixed()
public final ObjectProperty<java.util.Comparator<T>> comparatorProperty()
public final void setComparator(java.util.Comparator<T> value)
public final java.util.Comparator<T> getComparator()
public final void setEditable(boolean value)
public final boolean isEditable()
public final BooleanProperty editableProperty()
public final ObservableMap<java.lang.Object,java.lang.Object> getProperties()
public boolean hasProperties()
public void setUserData(java.lang.Object value)
getUserData()
.value
- The value to be stored - this can later be retrieved by calling
getUserData()
.public java.lang.Object getUserData()
setUserData(java.lang.Object)
method.public abstract ObservableList<? extends TableColumnBase<S,?>> getColumns()
This has no impact on the table as such - all column indices point to the leaf columns only, and it isn't possible to sort using the parent column, just the leaf columns. In other words, this is purely a visual feature.
public final T getCellData(int index)
index
- The row index for which the data is required.public final T getCellData(S item)
item
- The item from which a value of type T should be extracted.public abstract ObservableValue<T> getCellObservableValue(int index)
This is achieved by calling the cell value factory
, and
returning whatever it returns when passed a CellDataFeatures
(see,
for example, the CellDataFeatures classes belonging to
TableColumn
and
TreeTableColumn
for more
information).
index
- The index of the item (of type S) for which an
ObservableValue<T> is sought.public abstract ObservableValue<T> getCellObservableValue(S item)
This is achieved by calling the cell value factory
, and
returning whatever it returns when passed a CellDataFeatures
(see,
for example, the CellDataFeatures classes belonging to
TableColumn
and
TreeTableColumn
for more
information).
item
- The item (of type S) for which an ObservableValue<T> is
sought.public EventDispatchChain buildEventDispatchChain(EventDispatchChain tail)
EventTarget
. This event target is
not automatically added to the chain, so if it wants to process events,
it needs to add an EventDispatcher
for itself to the chain.
In the case the event target is part of some hierarchy, the chain for it is usually built from event dispatchers collected from the root of the hierarchy to the event target.
The event dispatch chain is constructed by modifications to the provided initial event dispatch chain. The returned chain should have the initial chain at its end so the dispatchers should be prepended to the initial chain.
The caller shouldn't assume that the initial chain remains unchanged nor that the returned value will reference a different chain.
buildEventDispatchChain
in interface EventTarget
tail
- the initial chain to build frompublic <E extends Event> void addEventHandler(EventType<E> eventType, EventHandler<E> eventHandler)
eventType
- the type of the events to receive by the handlereventHandler
- the handler to registerjava.lang.NullPointerException
- if the event type or handler is nullpublic <E extends Event> void removeEventHandler(EventType<E> eventType, EventHandler<E> eventHandler)
eventType
- the event type from which to unregistereventHandler
- the handler to unregisterjava.lang.NullPointerException
- if the event type or handler is null@Deprecated public void impl_setWidth(double width)
void updateColumnWidths()
public final ObservableSet<PseudoClass> getPseudoClassStates()
getPseudoClassStates
in interface Styleable