Class HierarchicalDataCommunicator<T>
java.lang.Object
com.vaadin.flow.data.provider.DataCommunicator<T>
com.vaadin.flow.data.provider.hierarchy.HierarchicalDataCommunicator<T>
- Type Parameters:
T- the bean type
- All Implemented Interfaces:
Serializable
Data communicator that handles requesting hierarchical data from
HierarchicalDataProvider and sending it to client side.- Since:
- 1.2
- Author:
- Vaadin Ltd
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.flow.data.provider.DataCommunicator
DataCommunicator.EmptyDataProvider<T1>, DataCommunicator.Filter<F> -
Field Summary
Fields inherited from class com.vaadin.flow.data.provider.DataCommunicator
DEFAULT_PAGE_INCREASE_COUNT, passivatedByUpdate -
Constructor Summary
ConstructorsConstructorDescriptionHierarchicalDataCommunicator(CompositeDataGenerator<T> dataGenerator, HierarchicalArrayUpdater arrayUpdater, SerializableConsumer<elemental.json.JsonArray> dataUpdater, StateNode stateNode, SerializableSupplier<ValueProvider<T, String>> uniqueKeyProviderSupplier) Deprecated.since 24.9. -
Method Summary
Modifier and TypeMethodDescriptioncollapse(Collection<T> items) Collapses the given items and removes its sub-hierarchy.voidCollapses the given item and removes its sub-hierarchy.protected voidDeprecated, for removal: This API element is subject to removal in a future version.since 24.9 and will be removed in Vaadin 25.voidconfirmUpdate(int id, String parentKey) Deprecated, for removal: This API element is subject to removal in a future version.since 24.9 and will be removed in Vaadin 25 where HierarchicalDataCommunicator will be refactored to handle hierarchy management entirely on the server side andDataCommunicator.confirmUpdate(int)will be the only method called for confirming updates.protected <F> HierarchyMapper<T,F> createHierarchyMapper(HierarchicalDataProvider<T, F> dataProvider) Deprecated, for removal: This API element is subject to removal in a future version.since 24.9 and will be removed in Vaadin 25 where HierarchicalDataCommunicator will be refactored to handle hierarchy management entirely on the server side, requiring data to be stored in a different cache structure.protected voiddoUnregister(Integer updateId) Deprecated, for removal: This API element is subject to removal in a future version.since 24.9 and will no longer be called in Vaadin 25 where HierarchicalDataCommunicator will be refactored to handle hierarchy management entirely on the server side.expand(Collection<T> items) Expands the given items.voidExpands the given item.protected voidDeprecated, for removal: This API element is subject to removal in a future version.since 24.9 and will be removed in Vaadin 25.fetchFromProvider(int offset, int limit) Fetches a list of items from the DataProvider.Gets the current data provider from this DataCommunicator.intGetter method for determining the item count of the data.intReturns depth of item in the tree starting from zero representing a root.protected HierarchyMapper<T,?> Deprecated, for removal: This API element is subject to removal in a future version.since 24.9 and will be removed in Vaadin 25 where HierarchicalDataCommunicator will be refactored to handle hierarchy management entirely on the server side, requiring data to be stored in a different cache structure.Deprecated, for removal: This API element is subject to removal in a future version.since 24.9 and will be removed in Vaadin 25.intEstimates are not supported in HierarchicalDataCommunicatorintEstimates are not supported in HierarchicalDataCommunicatorgetParentIndex(T item) Deprecated, for removal: This API element is subject to removal in a future version.since 24.9 and will be removed in Vaadin 25.getParentItem(T item) Deprecated, for removal: This API element is subject to removal in a future version.since 24.9 and will be removed in Vaadin 25.getPassivatedKeys(Set<String> oldActive) Deprecated, for removal: This API element is subject to removal in a future version.since 24.9 and will no longer be called in Vaadin 25 where HierarchicalDataCommunicator will be refactored to handle hierarchy management entirely on the server side.protected voidbooleanhasChildren(T item) Returns whether given item has children.booleanReturns true if there is any expanded items.booleanEstimates are not supported in HierarchicalDataCommunicator.booleanisExpanded(T item) Returns whether given item is expanded.voidreset()Resets all the data.voidsetBackEndSorting(List<QuerySortOrder> sortOrder) Sets theQuerySortOrders 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.voidsetDefinedSize(boolean definedSize) Estimates are not supported in HierarchicalDataCommunicatorprotected <F> voidsetFilter(F filter) Deprecated, for removal: This API element is subject to removal in a future version.since 24.9 and will be removed in Vaadin 25.voidsetInMemorySorting(SerializableComparator<T> comparator) Sets theComparatorto use with in-memory sorting.voidsetItemCountEstimate(int itemCountEstimate) Estimates are not supported in HierarchicalDataCommunicatorvoidsetItemCountEstimateIncrease(int itemCountEstimateIncrease) Estimates are not supported in HierarchicalDataCommunicatorvoidsetParentRequestedRange(int start, int length, T parentItem) Deprecated, for removal: This API element is subject to removal in a future version.since 24.9 and will be removed in Vaadin 25 where HierarchicalDataCommunicator will be refactored to handle hierarchy management entirely on the server side andDataCommunicator.setViewportRange(int, int)will be the method responsible for managing the entire viewport range.Methods inherited from class com.vaadin.flow.data.provider.DataCommunicator
buildQuery, computeRequestedRange, computeViewportRange, confirmUpdate, enablePushUpdates, getBackEndSorting, getFilter, getInMemorySorting, getItem, getItemCount, getKeyMapper, getPageSize, isFetchEnabled, isItemActive, isPagingEnabled, refresh, setCountCallback, setDataProvider, setFetchEnabled, setKeyMapper, setPageSize, setPagingEnabled, setRequestedRange, setViewportRange
-
Constructor Details
-
HierarchicalDataCommunicator
@Deprecated(since="24.9") public HierarchicalDataCommunicator(CompositeDataGenerator<T> dataGenerator, HierarchicalArrayUpdater arrayUpdater, SerializableConsumer<elemental.json.JsonArray> dataUpdater, StateNode stateNode, SerializableSupplier<ValueProvider<T, String>> uniqueKeyProviderSupplier) Deprecated.since 24.9. In Vaadin 25, the type ofarrayUpdaterwill change toArrayUpdaterand thedataUpdaterparameter will be removed. Instead, the communicator will useArrayUpdater.Update.set(int, List)to re-render refreshed items.Construct a new hierarchical data communicator backed by aTreeDataProvider.- Parameters:
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.
-
-
Method Details
-
reset
public void reset()Resets all the data.It effectively resends all available data.
- Overrides:
resetin classDataCommunicator<T>
-
handleDataRefreshEvent
- Overrides:
handleDataRefreshEventin classDataCommunicator<T>
-
fetchFromProvider
Description copied from class:DataCommunicatorFetches a list of items from the DataProvider.NOTE: the
limitparameter shows how many items the client wants to fetch, but the actual number of results may be greater, and vary from0 to pages * pageSize.- Overrides:
fetchFromProviderin classDataCommunicator<T>- Parameters:
offset- the starting index of the rangelimit- the desired number of results- Returns:
- the list of items in given range
-
setParentRequestedRange
@Deprecated(since="24.9", forRemoval=true) public void setParentRequestedRange(int start, int length, T parentItem) Deprecated, for removal: This API element is subject to removal in a future version.since 24.9 and will be removed in Vaadin 25 where HierarchicalDataCommunicator will be refactored to handle hierarchy management entirely on the server side andDataCommunicator.setViewportRange(int, int)will be the method responsible for managing the entire viewport range. -
getDataProvider
Description copied from class:DataCommunicatorGets the current data provider from this DataCommunicator.- Overrides:
getDataProviderin classDataCommunicator<T>- Returns:
- the data provider
-
setDataProvider
public <F> SerializableConsumer<F> setDataProvider(HierarchicalDataProvider<T, F> dataProvider, F initialFilter) Set the current hierarchical data provider for this communicator.- Type Parameters:
F- the filter type- Parameters:
dataProvider- the data provider to set, notnullinitialFilter- the initial filter value to use, ornullto not use any initial filter value- Returns:
- a consumer that accepts a new filter value to use
-
createHierarchyMapper
@Deprecated(since="24.9", forRemoval=true) protected <F> HierarchyMapper<T,F> createHierarchyMapper(HierarchicalDataProvider<T, F> dataProvider) Deprecated, for removal: This API element is subject to removal in a future version.since 24.9 and will be removed in Vaadin 25 where HierarchicalDataCommunicator will be refactored to handle hierarchy management entirely on the server side, requiring data to be stored in a different cache structure.Create newHierarchyMapperfor the given data provider. May be overridden in subclasses.- Type Parameters:
F- Query type- Parameters:
dataProvider- the data provider- Returns:
- new
HierarchyMapper
-
setDataProvider
Set the current hierarchical data provider for this communicator.- Overrides:
setDataProviderin classDataCommunicator<T>- Type Parameters:
F- the filter type- Parameters:
dataProvider- the data provider to set, must extendHierarchicalDataProvider, notnullinitialFilter- the initial filter value to use, ornullto not use any initial filter value- Returns:
- a consumer that accepts a new filter value to use
-
confirmUpdate
Deprecated, for removal: This API element is subject to removal in a future version.since 24.9 and will be removed in Vaadin 25 where HierarchicalDataCommunicator will be refactored to handle hierarchy management entirely on the server side andDataCommunicator.confirmUpdate(int)will be the only method called for confirming updates. -
collapse
Collapses the given item and removes its sub-hierarchy. Calling this method will have no effect if the row is already collapsed.Changes are synchronized to the client.
- Parameters:
item- the item to collapse
-
collapse
Deprecated, for removal: This API element is subject to removal in a future version.since 24.9 and will be removed in Vaadin 25. Usecollapse(T)instead.Collapses the given item and removes its sub-hierarchy. Calling this method will have no effect if the row is already collapsed.syncClientindicates whether the changes should be synchronized to the client.- Parameters:
item- the item to collapsesyncClient-trueif the changes should be synchronized to the client,falseotherwise.
-
collapse
Collapses the given items and removes its sub-hierarchy. Calling this method will have no effect if the row is already collapsed.Changes are synchronized to the client.
- Parameters:
items- the items to collapse- Returns:
- the collapsed items
-
expand
Expands the given item. Calling this method will have no effect if the item is already expanded or if it has no children.Changes are synchronized to the client.
- Parameters:
item- the item to expand
-
expand
Expands the given items. Calling this method will have no effect if the item is already expanded or if it has no children.Changes are synchronized to the client.
- Parameters:
items- the items to expand- Returns:
- the expanded items
-
expand
Deprecated, for removal: This API element is subject to removal in a future version.since 24.9 and will be removed in Vaadin 25. Useexpand(T)instead.Expands the given item. Calling this method will have no effect if the item is already expanded or if it has no children.syncClientindicates whether the changes should be synchronized to the client.- Parameters:
item- the item to expandsyncClient-trueif the changes should be synchronized to the client,falseotherwise.
-
hasChildren
Returns whether given item has children.- Parameters:
item- the item to test- Returns:
trueif item has children;falseif not
-
isExpanded
Returns whether given item is expanded.- Parameters:
item- the item to test- Returns:
trueif item is expanded;falseif not
-
getParentIndex
Deprecated, for removal: This API element is subject to removal in a future version.since 24.9 and will be removed in Vaadin 25. Use direct queries to the data source instead.Returns parent index for the row ornull.- Parameters:
item- the item to find the parent of- Returns:
- the parent index or
nullfor top-level items
-
getIndex
Deprecated, for removal: This API element is subject to removal in a future version.since 24.9 and will be removed in Vaadin 25. Use direct queries to the data source instead.Returns index for the row ornull.- Parameters:
item- the target item- Returns:
- the index or
nullfor top-level and non-existing items
-
getParentItem
Deprecated, for removal: This API element is subject to removal in a future version.since 24.9 and will be removed in Vaadin 25. Use direct queries to the data source instead.Returns parent item for the row ornull.- Parameters:
item- the item to find the parent of- Returns:
- the parent item or
nullfor top-level items
-
getDepth
Returns depth of item in the tree starting from zero representing a root.- Parameters:
item- Target item- Returns:
- depth of item in the tree or -1 if item is null
-
getDataProviderSize
public int getDataProviderSize()Description copied from class:DataCommunicatorGetter method for determining the item count of the data.This method should be used only with defined size, i.e. when
DataCommunicator.isDefinedSize()returnstrue.Can be overridden by a subclass that uses a specific type of DataProvider and/or query.
- Overrides:
getDataProviderSizein classDataCommunicator<T>- Returns:
- the size of data provider with current filter
-
setBackEndSorting
Description copied from class:DataCommunicatorSets theQuerySortOrders to use with backend sorting.- Overrides:
setBackEndSortingin classDataCommunicator<T>- Parameters:
sortOrder- list of sort order information to pass to a query
-
setInMemorySorting
Description copied from class:DataCommunicatorSets theComparatorto use with in-memory sorting.- Overrides:
setInMemorySortingin classDataCommunicator<T>- Parameters:
comparator- comparator used to sort data
-
setFilter
Deprecated, for removal: This API element is subject to removal in a future version.since 24.9 and will be removed in Vaadin 25. To control the filter fromHierarchicalDataCommunicator, overridesetDataProvider(HierarchicalDataProvider, Object)and store the returned filter consumer. -
hasExpandedItems
public boolean hasExpandedItems()Returns true if there is any expanded items.- Returns:
trueif there is any expanded items.
-
getHierarchyMapper
Deprecated, for removal: This API element is subject to removal in a future version.since 24.9 and will be removed in Vaadin 25 where HierarchicalDataCommunicator will be refactored to handle hierarchy management entirely on the server side, requiring data to be stored in a different cache structure.Returns theHierarchyMapperused by this data communicator.- Returns:
- the hierarchy mapper used by this data communicator
-
getPassivatedKeys
@Deprecated(since="24.9", forRemoval=true) protected Set<String> getPassivatedKeys(Set<String> oldActive) Deprecated, for removal: This API element is subject to removal in a future version.since 24.9 and will no longer be called in Vaadin 25 where HierarchicalDataCommunicator will be refactored to handle hierarchy management entirely on the server side.- Overrides:
getPassivatedKeysin classDataCommunicator<T>
-
doUnregister
Deprecated, for removal: This API element is subject to removal in a future version.since 24.9 and will no longer be called in Vaadin 25 where HierarchicalDataCommunicator will be refactored to handle hierarchy management entirely on the server side.- Overrides:
doUnregisterin classDataCommunicator<T>
-
setItemCountEstimate
public void setItemCountEstimate(int itemCountEstimate) Estimates are not supported in HierarchicalDataCommunicator- Overrides:
setItemCountEstimatein classDataCommunicator<T>- Parameters:
itemCountEstimate- the item count estimate to be used
-
getItemCountEstimate
public int getItemCountEstimate()Estimates are not supported in HierarchicalDataCommunicator- Overrides:
getItemCountEstimatein classDataCommunicator<T>- Returns:
- the item count estimate used
-
setItemCountEstimateIncrease
public void setItemCountEstimateIncrease(int itemCountEstimateIncrease) Estimates are not supported in HierarchicalDataCommunicator- Overrides:
setItemCountEstimateIncreasein classDataCommunicator<T>- Parameters:
itemCountEstimateIncrease- the item count estimate step to use
-
getItemCountEstimateIncrease
public int getItemCountEstimateIncrease()Estimates are not supported in HierarchicalDataCommunicator- Overrides:
getItemCountEstimateIncreasein classDataCommunicator<T>- Returns:
- the item count estimate increase
-
setDefinedSize
public void setDefinedSize(boolean definedSize) Estimates are not supported in HierarchicalDataCommunicator- Overrides:
setDefinedSizein classDataCommunicator<T>- Parameters:
definedSize-truefor defined size,falsefor undefined size
-
isDefinedSize
public boolean isDefinedSize()Estimates are not supported in HierarchicalDataCommunicator. Therefore this method will always return true- Overrides:
isDefinedSizein classDataCommunicator<T>- Returns:
truefor defined size,falsefor undefined size
-