Class CellFactory<T,C extends VFXCell<T>>
- All Implemented Interfaces:
javafx.beans.Observable
,javafx.beans.property.Property<Function<T,
,C>> javafx.beans.property.ReadOnlyProperty<Function<T,
,C>> javafx.beans.value.ObservableValue<Function<T,
,C>> javafx.beans.value.WritableValue<Function<T,
C>>
Encapsulates a cell generation function (create(Object)
) along with a reference to the associated VFXContainer
,
allowing each created cell to access the container instance upon creation. In other words, this wrapper is an easy
way to provide all cells the container they belong to without radical API changes.
Basically provides a hook that invokes VFXCell.onCreated(VFXContainer)
on each newly generated cell,
passing the container instance to the cell. This is particularly useful when cells need contextual information from
the container, such as configuration, state, selection handling.
Note 1: nothing prevents you from creating cells using the function directly, however, keep in mind that to automatically make use of the new
VFXCell.onCreated(VFXContainer)
hook, you must use create(Object)
instead.
Note 2: for convenience this extends
Property
and delegates the implemented methods to the wrapped
cell factory property.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(javafx.beans.InvalidationListener listener) void
addListener
(javafx.beans.value.ChangeListener<? super Function<T, C>> listener) void
void
bindBidirectional
(javafx.beans.property.Property<Function<T, C>> other) boolean
Convenience method to check whether the cell generating function is notnull
.Creates a new cell for the given item, using the current cell factory function.getBean()
getName()
getOwner()
getValue()
boolean
isBound()
protected void
onInvalidated
(Function<T, C> newFactory) Hook method called when the cell factory function is invalidated.void
removeListener
(javafx.beans.InvalidationListener listener) void
removeListener
(javafx.beans.value.ChangeListener<? super Function<T, C>> listener) void
void
unbind()
void
unbindBidirectional
(javafx.beans.property.Property<Function<T, C>> other) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javafx.beans.Observable
subscribe
Methods inherited from interface javafx.beans.value.ObservableValue
flatMap, map, orElse, subscribe, subscribe, when
-
Constructor Details
-
CellFactory
-
-
Method Details
-
create
Creates a new cell for the given item, using the current cell factory function.If the factory function is set, it generates a cell, calls
VFXCell.onCreated(VFXContainer)
on it, and then returns it. Returnsnull
if no factory function is defined. -
onInvalidated
Hook method called when the cell factory function is invalidated. Subclasses may override this method to handle changes to the factory function. -
bind
- Specified by:
bind
in interfacejavafx.beans.property.Property<T>
-
unbind
public void unbind()- Specified by:
unbind
in interfacejavafx.beans.property.Property<T>
-
isBound
public boolean isBound()- Specified by:
isBound
in interfacejavafx.beans.property.Property<T>
-
bindBidirectional
- Specified by:
bindBidirectional
in interfacejavafx.beans.property.Property<T>
-
unbindBidirectional
- Specified by:
unbindBidirectional
in interfacejavafx.beans.property.Property<T>
-
getBean
- Specified by:
getBean
in interfacejavafx.beans.property.ReadOnlyProperty<T>
-
getName
- Specified by:
getName
in interfacejavafx.beans.property.ReadOnlyProperty<T>
-
addListener
- Specified by:
addListener
in interfacejavafx.beans.value.ObservableValue<T>
-
removeListener
- Specified by:
removeListener
in interfacejavafx.beans.value.ObservableValue<T>
-
getValue
-
addListener
public void addListener(javafx.beans.InvalidationListener listener) - Specified by:
addListener
in interfacejavafx.beans.Observable
-
removeListener
public void removeListener(javafx.beans.InvalidationListener listener) - Specified by:
removeListener
in interfacejavafx.beans.Observable
-
setValue
- Specified by:
setValue
in interfacejavafx.beans.value.WritableValue<T>
-
getOwner
- Returns:
- the container that owns this cell factory and inherently the cells created by it.
-
canCreate
public boolean canCreate()Convenience method to check whether the cell generating function is notnull
.
-