T - the type of data this ListDataProvider will deliverpublic class ListDataProvider<T> extends java.lang.Object implements DataProvider<javafx.collections.ObservableList<T>>, WriteBackProvider<T>, WriteBackListProvider<T>
DataProvider that allows
the retrieval and parsing of a list of data entities.
In case a single entity is expected to be retrieved, an ObjectDataProvider
should be used. Instances of this class are typically used to populate ObservableList
instances.
This class requires a DataReader that either can be passed
with the constructor or using the setDataReader(io.datafx.io.DataReader)
method.
No external data will be retrieved until the retrieve() method is called.
Developers that prefer the builder approach can choose to use the
ListDataProviderBuilder class to create an
instance of ListDataProvider.
JsonConverter jsonConverter = new JsonConverter("data", MyEntity.class);
RestSourceBuilder restSourceBuilder = createRestSourceBuilder()
.converter(jsonConverter)
.path("part1").path("part2")
RestSource restSource = restSourceBuilder.build();
ListDataProvider<MyEntity> lodp = new ListDataProvider(restSource);
lodp.setResultObservableList(model.allMyEntities());
| Constructor and Description |
|---|
ListDataProvider() |
ListDataProvider(DataReader<T> reader) |
ListDataProvider(DataReader<T> reader,
java.util.concurrent.Executor executor,
javafx.collections.ObservableList<T> existingList)
Create a ListDataProvider with a given Executor and an existing
ListProperty
|
| Modifier and Type | Method and Description |
|---|---|
protected io.datafx.core.concurrent.PublishingTask<T> |
createPublishingReceiverTask(javafx.collections.ObservableList myResult) |
protected javafx.concurrent.Task<javafx.collections.ObservableList<T>> |
createReceiverTask(javafx.collections.ObservableList myResult) |
protected javafx.concurrent.Service<javafx.collections.ObservableList<T>> |
createService(javafx.collections.ObservableList<T> value) |
javafx.beans.property.ListProperty<T> |
getData()
returns the data obtained by this provider.
|
DataReader<T> |
getDataReader() |
java.util.concurrent.Executor |
getExecutor() |
javafx.concurrent.Worker<javafx.collections.ObservableList<T>> |
retrieve()
Starts to retrieve the data in a background thread and returns the Worker for
monitoring.
|
void |
setAddEntryHandler(WriteBackHandler<T> handler)
Set the
WriteBackHandler for this provider to the specified
handler. |
void |
setDataReader(DataReader<T> reader) |
void |
setResultObservableList(javafx.collections.ObservableList<T> ol)
This is a convenience method, allowing ObservableList instances (no
ListProperties) to be synchronized with the result of the
ListDataProvider.
|
void |
setResultProperty(javafx.beans.property.Property<javafx.collections.ObservableList<T>> result)
Provide an
Property that wraps the to-be-retrieved
data. |
void |
setWriteBackHandler(WriteBackHandler<T> handler)
Set the
WriteBackHandler for this provider to the specified
handler. |
public ListDataProvider()
public ListDataProvider(DataReader<T> reader)
public ListDataProvider(DataReader<T> reader, java.util.concurrent.Executor executor, javafx.collections.ObservableList<T> existingList)
reader - the DataReader that will obtain the real dataexecutor - an Executor that will make the (asynchronous) call.existingList - the ListProperty that will be populated with the
retrieved data. Note that in the past, we had to use a ListProperty
rather than an ObservableList since we override the getData() method,
which should return ObservableValue<T>public void setResultObservableList(javafx.collections.ObservableList<T> ol)
ol - The ObservableList instance that should be synchronized with
the data retrieved by this ListDataProvider. Note that this
ObservableList will be cleared when calling this method -- as there is no
data retrieved yet.public void setDataReader(DataReader<T> reader)
public DataReader<T> getDataReader()
public javafx.concurrent.Worker<javafx.collections.ObservableList<T>> retrieve()
DataProviderWorker.valueProperty() propertyretrieve in interface DataProvider<javafx.collections.ObservableList<T>>protected javafx.concurrent.Service<javafx.collections.ObservableList<T>> createService(javafx.collections.ObservableList<T> value)
protected io.datafx.core.concurrent.PublishingTask<T> createPublishingReceiverTask(javafx.collections.ObservableList myResult)
protected final javafx.concurrent.Task<javafx.collections.ObservableList<T>> createReceiverTask(javafx.collections.ObservableList myResult)
public java.util.concurrent.Executor getExecutor()
public javafx.beans.property.ListProperty<T> getData()
getData in interface DataProvider<javafx.collections.ObservableList<T>>public void setAddEntryHandler(WriteBackHandler<T> handler)
WriteBackListProviderWriteBackHandler for this provider to the specified
handler. When the provider decides to add data back to the original
datasource (that is, when data has been added locally), the
WriteBackHandler.createDataSource(java.lang.Object) method will
be called. This method returns a WritableDataReader
that will be used to send the data to the origin, by calling the
WritableDataReader.writeBack() method.setAddEntryHandler in interface WriteBackListProvider<T>handler - the handler that will be used when the provider decides to
write data back to the original source.public void setWriteBackHandler(WriteBackHandler<T> handler)
WriteBackProviderWriteBackHandler for this provider to the specified
handler. When the provider decides to write data back to the original
datasource (that is, when data has been changed locally), the
WriteBackHandler.createDataSource(java.lang.Object) method will
be called. This method returns a WritableDataReader
that will be used to send the data to the origin, by calling the
WritableDataReader.writeBack() method.setWriteBackHandler in interface WriteBackProvider<T>handler - the handler that will be used when the provider decides to
write data back to the original source.public void setResultProperty(javafx.beans.property.Property<javafx.collections.ObservableList<T>> result)
DataProviderProperty that wraps the to-be-retrieved
data.setResultProperty in interface DataProvider<javafx.collections.ObservableList<T>>result - a javafx.beans.property that already exists in the
application, and that will be used by this DataProvider to store the retrieved
data.