T - the data typeF - the filter typepublic class HierarchyMapper<T,F> extends Object implements DataGenerator<T>
Keeps track of the expanded nodes, and size of of the subtrees for each expanded node.
This class is framework internal implementation details, and can be changed / moved at any point. This means that you should not directly use this for anything.
| Constructor and Description |
|---|
HierarchyMapper(HierarchicalDataProvider<T,F> provider)
Constructs a new HierarchyMapper.
|
| Modifier and Type | Method and Description |
|---|---|
Range |
collapse(T item,
Integer position)
Collapses the given item.
|
void |
destroyAllData()
Informs the
DataGenerator that all data has been dropped. |
Range |
doCollapse(T item,
Optional<Integer> position)
Deprecated.
Use
collapse(Object, Integer) instead. |
Range |
doExpand(T item,
Optional<Integer> position)
Deprecated.
Use
expand(Object, Integer) instead. |
Range |
expand(T item,
Integer position)
Expands the given item.
|
Stream<T> |
fetchItems(Range range)
Gets a stream of items in the form of a flattened hierarchy from the
back-end and filter the wanted results from the list.
|
Stream<T> |
fetchItems(T parent,
Range range)
Gets a stream of children for the given item in the form of a flattened
hierarchy from the back-end and filter the wanted results from the list.
|
void |
generateData(T item,
JsonObject jsonObject)
Adds custom data for the given item to its serialized
JsonObject
representation. |
List<QuerySortOrder> |
getBackEndSorting()
Gets the current back-end sorting.
|
HierarchicalDataProvider<T,F> |
getDataProvider()
Gets the
HierarchicalDataProvider for this
HierarchyMapper. |
F |
getFilter()
Gets the current filter.
|
Optional<Integer> |
getIndexOf(T target)
Finds the current index of given object.
|
Comparator<T> |
getInMemorySorting()
Gets the current in-memory sorting.
|
ItemCollapseAllowedProvider<T> |
getItemCollapseAllowedProvider()
Gets the current item collapse allowed provider.
|
Integer |
getParentIndex(T item)
Finds the index of the parent of the item in given target index.
|
protected T |
getParentOfItem(T item)
Find parent for the given item among open folders.
|
int |
getTreeSize()
Returns the size of the currently expanded hierarchy.
|
boolean |
hasChildren(T item)
Returns whether given item has children.
|
boolean |
isExpanded(T item)
Returns whether the given item is expanded.
|
protected void |
registerChildren(T parent,
List<T> childList)
Register parent and children items into inner structures.
|
protected void |
removeChildren(Object id)
Removes all children of an item identified by a given id.
|
void |
setBackEndSorting(List<QuerySortOrder> backEndSorting)
Sets the current back-end sorting.
|
void |
setFilter(Object filter)
Sets the current filter.
|
void |
setInMemorySorting(Comparator<T> inMemorySorting)
Sets the current in-memory sorting.
|
void |
setItemCollapseAllowedProvider(ItemCollapseAllowedProvider<T> itemCollapseAllowedProvider)
Sets the current item collapse allowed provider.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdestroyData, refreshDatapublic HierarchyMapper(HierarchicalDataProvider<T,F> provider)
provider - the hierarchical data provider for this mapperpublic int getTreeSize()
public Integer getParentIndex(T item)
item - the item to get the parent ofpublic boolean isExpanded(T item)
item - the item to testtrue if item is expanded; false if notpublic Range expand(T item, Integer position)
item - the item to expandposition - the index of the item@Deprecated public Range doExpand(T item, Optional<Integer> position)
expand(Object, Integer) instead.item - the item to expandposition - the index of itempublic Range collapse(T item, Integer position)
item - the item to collapseposition - the index of the item@Deprecated public Range doCollapse(T item, Optional<Integer> position)
collapse(Object, Integer) instead.item - the item to collapseposition - the index of itempublic void generateData(T item, JsonObject jsonObject)
DataGeneratorJsonObject
representation. This JSON object will be sent to client-side
DataProvider.generateData in interface DataGenerator<T>item - the data item being serializedjsonObject - the JSON object being sent to the clientpublic ItemCollapseAllowedProvider<T> getItemCollapseAllowedProvider()
public void setItemCollapseAllowedProvider(ItemCollapseAllowedProvider<T> itemCollapseAllowedProvider)
itemCollapseAllowedProvider - the item collapse allowed providerpublic Comparator<T> getInMemorySorting()
public void setInMemorySorting(Comparator<T> inMemorySorting)
inMemorySorting - the in-memory sortingpublic List<QuerySortOrder> getBackEndSorting()
public void setBackEndSorting(List<QuerySortOrder> backEndSorting)
backEndSorting - the back-end sortingpublic F getFilter()
public void setFilter(Object filter)
filter - the filterpublic HierarchicalDataProvider<T,F> getDataProvider()
HierarchicalDataProvider for this
HierarchyMapper.public boolean hasChildren(T item)
item - the node to testtrue if node has children; false if notpublic Stream<T> fetchItems(Range range)
range - the requested item rangepublic Stream<T> fetchItems(T parent, Range range)
parent - the parent item for the fetchrange - the requested item rangeprotected T getParentOfItem(T item)
item - the itemnull for root items or if the parent is
closedprotected void removeChildren(Object id)
id - the item idpublic Optional<Integer> getIndexOf(T target)
target - the target object to findprotected void registerChildren(T parent, List<T> childList)
parent - the parent itemchildList - list of parents children to be registered.public void destroyAllData()
DataGeneratorDataGenerator that all data has been dropped. This
method should clean up any unneeded information stored for items.destroyAllData in interface DataGenerator<T>Copyright © 2019 Vaadin Ltd. All rights reserved.