public class TreeItemPropertyValueFactory<S,T> extends Object implements Callback<TreeTableColumn.CellDataFeatures<S,T>,ObservableValue<T>>
TreeTableColumn
cell value factory
. An example
of how to use this class is:
TreeTableColumn<Person,String> firstNameCol = new TreeTableColumn<Person,String>("First Name");
firstNameCol.setCellValueFactory(new TreeItemPropertyValueFactory<Person,String>("firstName"));
In this example, the "firstName" string is used as a reference to an assumed
firstNameProperty()
method in the Person
class type
(which is the class type of the TreeTableView). Additionally, this method must
return a Property
instance. If a method meeting these requirements
is found, then the TreeTableCell
is populated with this ObservableValueIf no method matching this pattern exists, there is fall-through support
for attempting to call get<property>() or is<property>() (that is,
getFirstName()
or isFirstName()
in the example
above). If a method matching this pattern exists, the value returned from this method
is wrapped in a ReadOnlyObjectWrapper
and returned to the TreeTableCell.
However, in this situation, this means that the TreeTableCell will not be able
to observe the ObservableValue for changes (as is the case in the first
approach above).
For reference (and as noted in the TreeTableColumn
cell value factory
documentation), the
long form of the code above would be the following:
TreeTableColumn<Person,String> firstNameCol = new TreeTableColumn<Person,String>("First Name");
firstNameCol.setCellValueFactory(new Callback<CellDataFeatures<Person, String>, ObservableValue<String>>() {
public ObservableValue<String> call(CellDataFeatures<Person, String> p) {
// p.getValue() returns the TreeItem instance for a particular
// TreeTableView row, and the second getValue() call returns the
// Person instance contained within the TreeItem.
return p.getValue().getValue().firstNameProperty();
}
});
}
TreeTableColumn
,
TreeTableView
,
TreeTableCell
,
PropertyValueFactory
,
MapValueFactory
Constructor and Description |
---|
TreeItemPropertyValueFactory(String property)
Creates a default PropertyValueFactory to extract the value from a given
TableView row item reflectively, using the given property name.
|
Modifier and Type | Method and Description |
---|---|
ObservableValue<T> |
call(TreeTableColumn.CellDataFeatures<S,T> param)
The
call method is called when required, and is given a
single argument of type P, with a requirement that an object of type R
is returned. |
String |
getProperty()
Returns the property name provided in the constructor.
|
public TreeItemPropertyValueFactory(String property)
property
- The name of the property with which to attempt to
reflectively extract a corresponding value for in a given object.public ObservableValue<T> call(TreeTableColumn.CellDataFeatures<S,T> param)
call
method is called when required, and is given a
single argument of type P, with a requirement that an object of type R
is returned.call
in interface Callback<TreeTableColumn.CellDataFeatures<S,T>,ObservableValue<T>>
param
- The single argument upon which the returned value should be
determined.public final String getProperty()
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2008, 2017, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.