T
- the bean typepublic class HierarchicalDataCommunicator<T> extends DataCommunicator<T>
HierarchicalDataProvider
and sending it to client side.Constructor and Description |
---|
HierarchicalDataCommunicator(CompositeDataGenerator<T> dataGenerator,
HierarchicalArrayUpdater arrayUpdater,
SerializableConsumer<elemental.json.JsonArray> dataUpdater,
StateNode stateNode,
SerializableSupplier<ValueProvider<T,String>> uniqueKeyProviderSupplier)
Construct a new hierarchical data communicator backed by a
TreeDataProvider . |
Modifier and Type | Method and Description |
---|---|
Collection<T> |
collapse(Collection<T> items)
Collapses the given items and removes its sub-hierarchy.
|
void |
collapse(T item)
Collapses the given item and removes its sub-hierarchy.
|
protected void |
collapse(T item,
boolean syncClient)
Collapses the given item and removes its sub-hierarchy.
|
void |
confirmUpdate(int id,
String parentKey) |
protected <F> HierarchyMapper<T,F> |
createHierarchyMapper(HierarchicalDataProvider<T,F> dataProvider)
Create new
HierarchyMapper for the given data provider. |
Collection<T> |
expand(Collection<T> items)
Expands the given items.
|
void |
expand(T item)
Expands the given item.
|
protected void |
expand(T item,
boolean syncClient)
Expands the given item.
|
Stream<T> |
fetchFromProvider(int offset,
int limit)
Fetches a list of items from the DataProvider.
|
HierarchicalDataProvider<T,?> |
getDataProvider()
Gets the current data provider from this DataCommunicator.
|
int |
getDataProviderSize()
Getter method for finding the size of DataProvider.
|
int |
getDepth(T item)
Returns depth of item in the tree starting from zero representing a root.
|
protected HierarchyMapper<T,?> |
getHierarchyMapper()
Returns the
HierarchyMapper used by this data communicator. |
Integer |
getIndex(T item)
Returns index for the row or
null . |
Integer |
getParentIndex(T item)
Returns parent index for the row or
null . |
T |
getParentItem(T item)
Returns parent item for the row or
null . |
protected Set<String> |
getPassivatedKeys(Set<String> oldActive) |
protected void |
handleDataRefreshEvent(DataChangeEvent.DataRefreshEvent<T> event) |
boolean |
hasChildren(T item)
Returns whether given item has children.
|
boolean |
hasExpandedItems()
Returns true if there is any expanded items.
|
boolean |
isExpanded(T item)
Returns whether given item is expanded.
|
void |
reset()
Resets all the data.
|
void |
setBackEndSorting(List<QuerySortOrder> sortOrder)
Sets the
QuerySortOrder s to use with backend sorting. |
<F> SerializableConsumer<F> |
setDataProvider(DataProvider<T,F> dataProvider,
F initialFilter)
Set the current hierarchical data provider for this communicator.
|
<F> SerializableConsumer<F> |
setDataProvider(HierarchicalDataProvider<T,F> dataProvider,
F initialFilter)
Set the current hierarchical data provider for this communicator.
|
protected <F> void |
setFilter(F filter) |
void |
setInMemorySorting(SerializableComparator<T> comparator)
Sets the
Comparator to use with in-memory sorting. |
void |
setParentRequestedRange(int start,
int length,
T parentItem) |
confirmUpdate, enablePushUpdates, getBackEndSorting, getFilter, getInMemorySorting, getKeyMapper, refresh, setKeyMapper, setRequestedRange
public HierarchicalDataCommunicator(CompositeDataGenerator<T> dataGenerator, HierarchicalArrayUpdater arrayUpdater, SerializableConsumer<elemental.json.JsonArray> dataUpdater, StateNode stateNode, SerializableSupplier<ValueProvider<T,String>> uniqueKeyProviderSupplier)
TreeDataProvider
.dataGenerator
- the data generator functionarrayUpdater
- array updater strategydataUpdater
- data updater strategystateNode
- the state node used to communicate foruniqueKeyProviderSupplier
- Unique key provider for a row. If null, then using Grid's
default key generator.public void reset()
It effectively resends all available data.
reset
in class DataCommunicator<T>
protected void handleDataRefreshEvent(DataChangeEvent.DataRefreshEvent<T> event)
handleDataRefreshEvent
in class DataCommunicator<T>
public Stream<T> fetchFromProvider(int offset, int limit)
DataCommunicator
fetchFromProvider
in class DataCommunicator<T>
offset
- the starting index of the rangelimit
- the max number of resultspublic void setParentRequestedRange(int start, int length, T parentItem)
public HierarchicalDataProvider<T,?> getDataProvider()
DataCommunicator
getDataProvider
in class DataCommunicator<T>
public <F> SerializableConsumer<F> setDataProvider(HierarchicalDataProvider<T,F> dataProvider, F initialFilter)
F
- the filter typedataProvider
- the data provider to set, not null
initialFilter
- the initial filter value to use, or null
to not
use any initial filter valueprotected <F> HierarchyMapper<T,F> createHierarchyMapper(HierarchicalDataProvider<T,F> dataProvider)
HierarchyMapper
for the given data provider. May be
overridden in subclasses.F
- Query typedataProvider
- the data providerHierarchyMapper
public <F> SerializableConsumer<F> setDataProvider(DataProvider<T,F> dataProvider, F initialFilter)
setDataProvider
in class DataCommunicator<T>
F
- the filter typedataProvider
- the data provider to set, must extend
HierarchicalDataProvider
, not null
initialFilter
- the initial filter value to use, or null
to not
use any initial filter valuepublic void confirmUpdate(int id, String parentKey)
public void collapse(T item)
Changes are synchronized to the client.
item
- the item to collapseprotected void collapse(T item, boolean syncClient)
syncClient
indicates whether the changes should be synchronized
to the client.item
- the item to collapsesyncClient
- true
if the changes should be synchronized to the
client, false
otherwise.public Collection<T> collapse(Collection<T> items)
Changes are synchronized to the client.
items
- the items to collapsepublic void expand(T item)
Changes are synchronized to the client.
item
- the item to expandpublic Collection<T> expand(Collection<T> items)
Changes are synchronized to the client.
items
- the items to expandprotected void expand(T item, boolean syncClient)
syncClient
indicates whether the changes should be synchronized to the client.item
- the item to expandsyncClient
- true
if the changes should be synchronized to the
client, false
otherwise.public boolean hasChildren(T item)
item
- the item to testtrue
if item has children; false
if notpublic boolean isExpanded(T item)
item
- the item to testtrue
if item is expanded; false
if notpublic Integer getParentIndex(T item)
null
.item
- the item to find the parent ofnull
for top-level itemspublic Integer getIndex(T item)
null
.item
- the target itemnull
for top-level and non-existing itemspublic T getParentItem(T item)
null
.item
- the item to find the parent ofnull
for top-level itemspublic int getDepth(T item)
item
- Target itempublic int getDataProviderSize()
DataCommunicator
getDataProviderSize
in class DataCommunicator<T>
public void setBackEndSorting(List<QuerySortOrder> sortOrder)
DataCommunicator
QuerySortOrder
s to use with backend sorting.setBackEndSorting
in class DataCommunicator<T>
sortOrder
- list of sort order information to pass to a querypublic void setInMemorySorting(SerializableComparator<T> comparator)
DataCommunicator
Comparator
to use with in-memory sorting.setInMemorySorting
in class DataCommunicator<T>
comparator
- comparator used to sort dataprotected <F> void setFilter(F filter)
public boolean hasExpandedItems()
true
if there is any expanded items.protected HierarchyMapper<T,?> getHierarchyMapper()
HierarchyMapper
used by this data communicator.protected Set<String> getPassivatedKeys(Set<String> oldActive)
getPassivatedKeys
in class DataCommunicator<T>
Copyright © 2023. All rights reserved.