T
- the bean typepublic class HierarchicalDataCommunicator<T> extends DataCommunicator<T>
HierarchicalDataProvider
and sending it to client side.DataCommunicator.ActiveDataHandler, DataCommunicator.SimpleDataRequestRpc
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
reset
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
null . |
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.
|
void |
setBackEndSorting(List<QuerySortOrder> sortOrder)
Sets the
QuerySortOrder s to use with backend sorting. |
void |
setBackEndSorting(List<QuerySortOrder> sortOrder,
boolean immediateReset)
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)
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, getMinPushSize, getPushRows, getUpdatedData, onDropRows, onRequestRows, pushData, refresh, removeDataGenerator, reset, sendDataToClient, setDataProvider, setMinPushSize, setPushRows
extend, getParent, getSupportedParentType, remove, setParent
addAttachListener, addDetachListener, addExtension, 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, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstate
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
addAttachListener, addDetachListener, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, getUI, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
getConnectorId
public 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)
AbstractClientConnector
getState
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)
DataCommunicator
fetchItemsWithRange
in class DataCommunicator<T>
offset
- the starting index of the rangelimit
- the max number of resultspublic 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 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 itempublic 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 null
public Integer getParentIndex(T item)
null
.item
- the item to find the parent ofnull
for top-level itemspublic ItemCollapseAllowedProvider<T> getItemCollapseAllowedProvider()
public int getDataProviderSize()
DataCommunicator
getDataProviderSize
in class DataCommunicator<T>
public void setBackEndSorting(List<QuerySortOrder> sortOrder, boolean immediateReset)
DataCommunicator
QuerySortOrder
s 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)
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(Comparator<T> comparator, boolean immediateReset)
DataCommunicator
Comparator
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)
DataCommunicator
Comparator
to use with in-memory sorting.setInMemorySorting
in class DataCommunicator<T>
comparator
- comparator used to sort dataprotected <F> void setFilter(F filter)
DataCommunicator
DataCommunicator.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 © 2019 Vaadin Ltd. All rights reserved.