T - the bean typepublic class HierarchicalDataCommunicator<T> extends DataCommunicator<T>
HierarchicalDataProvider and sending it to client side.DataCommunicator.ActiveDataHandler, DataCommunicator.SimpleDataRequestRpcClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListenerreset| Constructor and Description |
|---|
HierarchicalDataCommunicator()
Construct a new hierarchical data communicator backed by a
TreeDataProvider. |
| Modifier and Type | Method and Description |
|---|---|
void |
collapse(T item)
Collapses the given item and removes its sub-hierarchy.
|
void |
collapse(T item,
boolean syncAndRefresh)
Collapses the given item and removes its sub-hierarchy.
|
void |
collapse(T item,
Integer index)
Collapses the given item and removes its sub-hierarchy.
|
protected <F> HierarchyMapper<T,F> |
createHierarchyMapper(HierarchicalDataProvider<T,F> dataProvider)
Create new
HierarchyMapper for the given data provider. |
void |
doCollapse(T item,
Optional<Integer> index)
Deprecated.
Use
collapse(Object, Integer) instead. |
void |
doExpand(T item,
Optional<Integer> index)
Deprecated.
use
expand(Object, Integer) instead |
void |
expand(T item)
Expands the given item.
|
void |
expand(T item,
boolean syncAndRefresh)
Expands the given item.
|
void |
expand(T item,
Integer index)
Expands the given item at the given index.
|
List<T> |
fetchItemsWithRange(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.
|
protected HierarchyMapper<T,?> |
getHierarchyMapper()
Returns the
HierarchyMapper used by this data communicator. |
ItemCollapseAllowedProvider<T> |
getItemCollapseAllowedProvider()
Gets the item collapse allowed provider.
|
Integer |
getParentIndex(T item)
Returns parent index for the row or a negative value.
|
protected HierarchicalDataCommunicatorState |
getState()
Returns the shared state for this connector.
|
protected HierarchicalDataCommunicatorState |
getState(boolean markAsDirty)
Returns the shared state for this connector.
|
boolean |
hasChildren(T item)
Returns whether given item has children.
|
boolean |
isExpanded(T item)
Returns whether given item is expanded.
|
protected void |
onDropRows(elemental.json.JsonArray keys)
Triggered when rows have been dropped from the client side cache.
|
protected void |
sendDataToClient(boolean initial)
Send the needed data and updates to the client side.
|
void |
setBackEndSorting(List<QuerySortOrder> sortOrder)
Sets the
QuerySortOrders to use with backend sorting. |
void |
setBackEndSorting(List<QuerySortOrder> sortOrder,
boolean immediateReset)
Sets the
QuerySortOrders 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)
Sets the filter for this DataCommunicator.
|
void |
setInMemorySorting(Comparator<T> comparator)
Sets the
Comparator to use with in-memory sorting. |
void |
setInMemorySorting(Comparator<T> comparator,
boolean immediateReset)
Sets the
Comparator to use with in-memory sorting. |
void |
setItemCollapseAllowedProvider(ItemCollapseAllowedProvider<T> provider)
Sets the item collapse allowed provider for this
HierarchicalDataCommunicator.
|
addDataGenerator, attach, beforeClientResponse, createKeyMapper, createRpc, detach, dropAllData, getActiveDataHandler, getBackEndSorting, getClientRpc, getDataObject, getFilter, getInMemorySorting, getKeyMapper, getMaximumAllowedRows, getMinPushSize, getPushRows, getUpdatedData, onRequestRows, pushData, refresh, removeDataGenerator, reset, setDataProvider, setMaximumAllowedRows, setMinPushSize, setPushRowsextend, getParent, getSupportedParentType, remove, setParentaddAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isConnectorEnabled, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstateclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitaddAttachListener, addDetachListener, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, getUI, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandlergetConnectorIdpublic HierarchicalDataCommunicator()
TreeDataProvider.protected HierarchicalDataCommunicatorState getState()
AbstractClientConnector
As a side effect, marks the connector dirty so any changes done to the
state will be sent to the client. Use getState(false) to avoid
marking the connector as dirty.
getState in class DataCommunicator<T>protected HierarchicalDataCommunicatorState getState(boolean markAsDirty)
AbstractClientConnectorgetState in class DataCommunicator<T>markAsDirty - true if the connector should automatically be marked dirty,
false otherwiseAbstractClientConnector.getState()public List<T> fetchItemsWithRange(int offset, int limit)
DataCommunicatorfetchItemsWithRange in class DataCommunicator<T>offset - the starting index of the rangelimit - the max number of resultspublic HierarchicalDataProvider<T,?> getDataProvider()
DataCommunicatorgetDataProvider 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 nullinitialFilter - 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 providerHierarchyMapperpublic <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 nullinitialFilter - the initial filter value to use, or null to not
use any initial filter valueprotected void sendDataToClient(boolean initial)
DataCommunicatorsendDataToClient in class DataCommunicator<T>initial - true if initial data load, false if notpublic void collapse(T item)
item - the item to collapsepublic void collapse(T item, boolean syncAndRefresh)
syncAndRefresh indicates whether the changes should be
synchronised to the client and the data provider be notified.item - the item to collapsesyncAndRefresh - true if the changes should be synchronised to the
client and the data provider should be notified of the
changes, false otherwise.public void collapse(T item, Integer index)
item - the item to collapseindex - the index of the item@Deprecated public void doCollapse(T item, Optional<Integer> index)
collapse(Object, Integer) instead.item - the item to collapseindex - the index of the itemprotected void onDropRows(elemental.json.JsonArray keys)
DataCommunicatoronDropRows in class DataCommunicator<T>keys - the keys of the rows that have been droppedpublic void expand(T item)
item - the item to expandpublic void expand(T item, boolean syncAndRefresh)
syncAndRefresh
indicates whether the changes should be synchronised to the client and
the data provider be notified.item - the item to expandsyncAndRefresh - true if the changes should be synchronised to the
client and the data provider should be notified of the
changes, false otherwise.public void expand(T item, Integer index)
item - the item to expandindex - the index of the item@Deprecated public void doExpand(T item, Optional<Integer> index)
expand(Object, Integer) insteaditem - the item to expandindex - the index of the itemexpand(Object)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 void setItemCollapseAllowedProvider(ItemCollapseAllowedProvider<T> provider)
true for
any item that the user can collapse.
Note: This callback will be accessed often when sending data to the client. The callback should not do any costly operations.
provider - the item collapse allowed provider, not nullpublic Integer getParentIndex(T item)
item - the item to find the parent ofpublic ItemCollapseAllowedProvider<T> getItemCollapseAllowedProvider()
public int getDataProviderSize()
DataCommunicatorgetDataProviderSize in class DataCommunicator<T>public void setBackEndSorting(List<QuerySortOrder> sortOrder, boolean immediateReset)
DataCommunicatorQuerySortOrders to use with backend sorting.setBackEndSorting in class DataCommunicator<T>sortOrder - list of sort order information to pass to a queryimmediateReset - true if an internal reset should be performed
immediately after updating the comparator (unless full reset
is already pending), false if you are going to trigger
reset separately laterpublic void setBackEndSorting(List<QuerySortOrder> sortOrder)
DataCommunicatorQuerySortOrders to use with backend sorting.setBackEndSorting in class DataCommunicator<T>sortOrder - list of sort order information to pass to a querypublic void setInMemorySorting(Comparator<T> comparator, boolean immediateReset)
DataCommunicatorComparator to use with in-memory sorting.setInMemorySorting in class DataCommunicator<T>comparator - comparator used to sort dataimmediateReset - true if an internal reset should be performed
immediately after updating the comparator (unless full reset
is already pending), false if you are going to trigger
reset separately laterpublic void setInMemorySorting(Comparator<T> comparator)
DataCommunicatorComparator to use with in-memory sorting.setInMemorySorting in class DataCommunicator<T>comparator - comparator used to sort dataprotected <F> void setFilter(F filter)
DataCommunicatorDataCommunicator.setDataProvider(com.vaadin.data.provider.DataProvider<T, F>, F) and should not
be called elsewhere.setFilter in class DataCommunicator<T>F - the filter typefilter - the filterprotected HierarchyMapper<T,?> getHierarchyMapper()
HierarchyMapper used by this data communicator.Copyright © 2022 Vaadin Ltd. All rights reserved.