T
- the grid bean typepublic class TreeGrid<T> extends Grid<T> implements HasHierarchicalDataProvider<T>
_treegrid.scss
from Valo theme.Grid.AbstractGridExtension<T>, Grid.Column<T,V>, Grid.ColumnReorderEvent, Grid.ColumnResizeEvent, Grid.ColumnVisibilityChangeEvent, Grid.DetailsManager<T>, Grid.FetchItemsCallback<T>, Grid.GridContextClickEvent<T>, Grid.ItemClick<T>, Grid.SelectionMode
AbstractListing.AbstractListingExtension<T>
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
Sizeable.Unit
HasComponents.ComponentAttachDetachNotifier, HasComponents.ComponentAttachEvent, HasComponents.ComponentAttachListener, HasComponents.ComponentDetachEvent, HasComponents.ComponentDetachListener
DESIGN_ATTR_PLAIN_TEXT
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
Modifier | Constructor and Description |
---|---|
|
TreeGrid()
Creates a new
TreeGrid without support for creating columns based
on property names. |
|
TreeGrid(Class<T> beanType)
Creates a new
TreeGrid that uses reflection based on the provided
bean type to automatically set up an initial set of columns. |
protected |
TreeGrid(HierarchicalDataCommunicator<T> dataCommunicator)
Creates a new TreeGrid with the given data communicator and without
support for creating columns based on property names.
|
|
TreeGrid(HierarchicalDataProvider<T,?> dataProvider)
Creates a new
TreeGrid using the given
HierarchicalDataProvider , without support for creating columns
based on property names. |
protected |
TreeGrid(PropertySet<T> propertySet,
HierarchicalDataCommunicator<T> dataCommunicator)
Creates a
TreeGrid using a custom PropertySet
implementation and custom data communicator. |
Modifier and Type | Method and Description |
---|---|
Registration |
addCollapseListener(CollapseEvent.CollapseListener<T> listener)
Adds a CollapseListener to this TreeGrid.
|
Registration |
addExpandListener(ExpandEvent.ExpandListener<T> listener)
Adds an ExpandListener to this TreeGrid.
|
void |
collapse(Collection<T> items)
Collapse the given items.
|
void |
collapse(T... items)
Collapse the given items.
|
void |
collapseRecursively(Collection<T> items,
int depth)
Collapse the given items and their children recursively until the given
depth.
|
void |
collapseRecursively(Stream<T> items,
int depth)
Collapse the given items and their children recursively until the given
depth.
|
protected void |
doReadDesign(org.jsoup.nodes.Element design,
DesignContext context)
Reads the listing specific state from the given design.
|
protected void |
doWriteDesign(org.jsoup.nodes.Element design,
DesignContext designContext)
Writes listing specific state into the given design.
|
void |
expand(Collection<T> items)
Expands the given items.
|
void |
expand(T... items)
Expands the given items.
|
void |
expandRecursively(Collection<T> items,
int depth)
Expands the given items and their children recursively until the given
depth.
|
void |
expandRecursively(Stream<T> items,
int depth)
Expands the given items and their children recursively until the given
depth.
|
HierarchicalDataCommunicator<T> |
getDataCommunicator()
Returns the data communicator of this listing.
|
HierarchicalDataProvider<T,?> |
getDataProvider()
Returns the source of data items used by this listing.
|
Grid.Column<T,?> |
getHierarchyColumn()
Get the currently set hierarchy column.
|
ItemCollapseAllowedProvider<T> |
getItemCollapseAllowedProvider()
Gets the item collapse allowed provider.
|
protected TreeGridState |
getState()
Returns the shared state bean with information to be sent from the server
to the client.
|
protected TreeGridState |
getState(boolean markAsDirty)
Returns the shared state for this connector.
|
boolean |
isExpanded(T item)
Returns whether a given item is expanded or collapsed.
|
protected void |
readData(org.jsoup.nodes.Element body,
List<com.vaadin.ui.DeclarativeValueProvider<T>> providers)
Reads the declarative representation of a grid's data from the given
element and stores it in the given
DeclarativeValueProvider s. |
void |
scrollTo(int row)
Deprecated.
|
void |
scrollTo(int row,
ScrollDestination destination)
Deprecated.
|
void |
setDataProvider(DataProvider<T,?> dataProvider)
Sets the data provider for this listing.
|
void |
setHierarchyColumn(Grid.Column<T,?> column)
Set the column that displays the hierarchy of this grid's data.
|
void |
setHierarchyColumn(String id)
Set the column that displays the hierarchy of this grid's data.
|
void |
setItemCollapseAllowedProvider(ItemCollapseAllowedProvider<T> provider)
Sets the item collapse allowed provider for this TreeGrid.
|
static <BEAN> TreeGrid<BEAN> |
withPropertySet(PropertySet<BEAN> propertySet)
Creates a
TreeGrid using a custom PropertySet
implementation for creating a default set of columns and for resolving
property names with Grid.addColumn(String) and
Column#setEditorComponent(HasValue) . |
protected void |
writeData(org.jsoup.nodes.Element body,
DesignContext designContext)
Writes the data contained in this grid.
|
addColumn, addColumn, addColumn, addColumn, addColumn, addColumn, addColumn, addColumnReorderListener, addColumnResizeListener, addColumnVisibilityChangeListener, addComponentColumn, addContextClickListener, addFooterRowAt, addHeaderRowAt, addItemClickListener, addSelectionListener, addSortListener, appendFooterRow, appendHeaderRow, asMultiSelect, asSingleSelect, beforeClientResponse, clearSortOrder, createColumn, createEditor, createSortingComparator, deselect, deselectAll, deserializeDeclarativeRepresentation, fireColumnVisibilityChangeEvent, getBeanType, getBodyRowHeight, getColumn, getColumnByInternalId, getColumnResizeMode, getColumns, getCustomAttributes, getDefaultHeaderRow, getDescriptionGenerator, getEditor, getFooter, getFooterRow, getFooterRowCount, getFooterRowHeight, getFrozenColumnCount, getHeader, getHeaderRow, getHeaderRowCount, getHeaderRowHeight, getHeightByRows, getHeightMode, getInternalIdForColumn, getPropertySet, getRowHeight, getSelectedItems, getSelectionModel, getSortOrder, getStyleGenerator, internalSetDataProvider, isColumnReorderingAllowed, isDetailsVisible, isFooterVisible, isHeaderVisible, isReadOnly, iterator, prependFooterRow, prependHeaderRow, readItems, recalculateColumnWidths, removeAllColumns, removeColumn, removeColumn, removeFooterRow, removeFooterRow, removeHeaderRow, removeHeaderRow, scrollToEnd, scrollToStart, select, setBeanType, setBeanType, setBodyRowHeight, setColumnId, setColumnOrder, setColumnOrder, setColumnReorderingAllowed, setColumnResizeMode, setColumns, setDataProvider, setDefaultHeaderRow, setDescriptionGenerator, setDescriptionGenerator, setDetailsGenerator, setDetailsVisible, setFooterRowHeight, setFooterVisible, setFrozenColumnCount, setHeaderRowHeight, setHeaderVisible, setHeight, setHeightByRows, setHeightMode, setPropertySet, setReadOnly, setRowHeight, setSelectionMode, setSelectionModel, setSortOrder, setSortOrder, setStyleGenerator, sort, sort, sort, sort
addDataGenerator, focus, getItemCaptionGenerator, getItemIconGenerator, getTabIndex, internalGetDataProvider, internalSetDataProvider, readDesign, readItem, removeDataGenerator, serializeDeclarativeRepresentation, setItemCaptionGenerator, setItemIconGenerator, setTabIndex, writeDesign, writeItem, writeItems
addListener, addShortcutListener, addStyleName, attach, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, getActionManager, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorMessage, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isOrHasAncestor, isRequiredIndicatorVisible, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setDescription, setEnabled, setHeight, setHeightUndefined, setIcon, setId, setLocale, setParent, setPrimaryStyleName, setRequiredIndicatorVisible, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth, setWidth, setWidthUndefined
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, 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
getTreeData, setItems, setItems, setItems, setItems, setItems, setTreeData
addListener, addStyleName, addStyleNames, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isVisible, readDesign, removeListener, removeStyleName, removeStyleNames, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setStyleName, setStyleName, setVisible, writeDesign
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
getConnectorId
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthUndefined
forEach, spliterator
public TreeGrid()
TreeGrid
without support for creating columns based
on property names. Use an alternative constructor, such as
TreeGrid(Class)
, to create a TreeGrid
that
automatically sets up columns based on the type of presented data.public TreeGrid(Class<T> beanType)
TreeGrid
that uses reflection based on the provided
bean type to automatically set up an initial set of columns. All columns
will be configured using the same Object.toString()
renderer that
is used by Grid.addColumn(ValueProvider)
.beanType
- the bean type to use, not null
public TreeGrid(HierarchicalDataProvider<T,?> dataProvider)
TreeGrid
using the given
HierarchicalDataProvider
, without support for creating columns
based on property names. Use an alternative constructor, such as
TreeGrid(Class)
, to create a TreeGrid
that
automatically sets up columns based on the type of presented data.dataProvider
- the data provider, not null
protected TreeGrid(PropertySet<T> propertySet, HierarchicalDataCommunicator<T> dataCommunicator)
TreeGrid
using a custom PropertySet
implementation and custom data communicator.
Property set is used for configuring the initial columns and resolving
property names for Grid.addColumn(String)
and
Column#setEditorComponent(HasValue)
.
propertySet
- the property set implementation to use, not null
dataCommunicator
- the data communicator to use, not null
protected TreeGrid(HierarchicalDataCommunicator<T> dataCommunicator)
dataCommunicator
- the custom data communicator to setpublic static <BEAN> TreeGrid<BEAN> withPropertySet(PropertySet<BEAN> propertySet)
TreeGrid
using a custom PropertySet
implementation for creating a default set of columns and for resolving
property names with Grid.addColumn(String)
and
Column#setEditorComponent(HasValue)
.
This functionality is provided as static method instead of as a public constructor in order to make it possible to use a custom property set without creating a subclass while still leaving the public constructors focused on the common use cases.
propertySet
- the property set implementation to use, not null
null
TreeGrid()
,
TreeGrid(Class)
@Deprecated public void scrollTo(int row) throws IllegalArgumentException
scrollTo
in class Grid<T>
row
- zero based index of the item to scroll to in the current view.IllegalArgumentException
- if the provided row is outside the item range@Deprecated public void scrollTo(int row, ScrollDestination destination)
public Registration addExpandListener(ExpandEvent.ExpandListener<T> listener)
listener
- the listener to addExpandEvent
public Registration addCollapseListener(CollapseEvent.CollapseListener<T> listener)
listener
- the listener to addCollapseEvent
public void setDataProvider(DataProvider<T,?> dataProvider)
HasDataProvider
setDataProvider
in interface HasDataProvider<T>
setDataProvider
in class Grid<T>
dataProvider
- the data provider, not nullpublic Grid.Column<T,?> getHierarchyColumn()
null
if no column
has been explicitly setpublic void setHierarchyColumn(Grid.Column<T,?> column)
Setting a hierarchy column by calling this method also sets the column to be visible and not hidable.
Note: Changing the Renderer of the hierarchy column is not supported.
column
- the column to use for displaying hierarchypublic void setHierarchyColumn(String id)
Setting a hierarchy column by calling this method also sets the column to be visible and not hidable.
Note: Changing the Renderer of the hierarchy column is not supported.
id
- id of the column to use for displaying hierarchyColumn#setId(String)
public 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.
This method is a shortcut to method with the same name in
HierarchicalDataCommunicator
.
provider
- the item collapse allowed provider, not null
HierarchicalDataCommunicator.setItemCollapseAllowedProvider(ItemCollapseAllowedProvider)
public void expand(T... items)
If an item is currently expanded, does nothing. If an item does not have any children, does nothing.
items
- the items to expandpublic void expand(Collection<T> items)
If an item is currently expanded, does nothing. If an item does not have any children, does nothing.
items
- the items to expandpublic void expandRecursively(Collection<T> items, int depth)
depth
describes the maximum distance between a given item and its
descendant, meaning that expandRecursively(items, 0)
expands only
the given items while expandRecursively(items, 2)
expands the
given items as well as their children and grandchildren.
This method will not fire events for expanded nodes.
items
- the items to expand recursivelydepth
- the maximum depth of recursionpublic void expandRecursively(Stream<T> items, int depth)
depth
describes the maximum distance between a given item and its
descendant, meaning that expandRecursively(items, 0)
expands only
the given items while expandRecursively(items, 2)
expands the
given items as well as their children and grandchildren.
This method will not fire events for expanded nodes.
items
- the items to expand recursivelydepth
- the maximum depth of recursionpublic void collapse(T... items)
For items that are already collapsed, does nothing.
items
- the collection of items to collapsepublic void collapse(Collection<T> items)
For items that are already collapsed, does nothing.
items
- the collection of items to collapsepublic void collapseRecursively(Collection<T> items, int depth)
depth
describes the maximum distance between a given item and its
descendant, meaning that collapseRecursively(items, 0)
collapses
only the given items while collapseRecursively(items, 2)
collapses the given items as well as their children and grandchildren.
This method will not fire events for collapsed nodes.
items
- the items to collapse recursivelydepth
- the maximum depth of recursionpublic void collapseRecursively(Stream<T> items, int depth)
depth
describes the maximum distance between a given item and its
descendant, meaning that collapseRecursively(items, 0)
collapses
only the given items while collapseRecursively(items, 2)
collapses the given items as well as their children and grandchildren.
This method will not fire events for collapsed nodes.
items
- the items to collapse recursivelydepth
- the maximum depth of recursionpublic boolean isExpanded(T item)
item
- the item to checkprotected TreeGridState getState()
AbstractComponent
protected TreeGridState getState(boolean markAsDirty)
AbstractClientConnector
getState
in class Grid<T>
markAsDirty
- true if the connector should automatically be marked dirty,
false otherwiseAbstractClientConnector.getState()
public HierarchicalDataCommunicator<T> getDataCommunicator()
AbstractListing
getDataCommunicator
in class AbstractListing<T>
public HierarchicalDataProvider<T,?> getDataProvider()
HasItems
getDataProvider
in interface HasItems<T>
getDataProvider
in class Grid<T>
protected void doReadDesign(org.jsoup.nodes.Element design, DesignContext context)
AbstractListing
This method is separated from AbstractListing.readDesign(Element, DesignContext)
to be overridable in subclasses that need to replace this, but still must
be able to call super.readDesign(...)
.
doReadDesign
in class Grid<T>
design
- The element to obtain the state fromcontext
- The DesignContext instance used for parsing the designAbstractListing.doWriteDesign(Element, DesignContext)
protected void readData(org.jsoup.nodes.Element body, List<com.vaadin.ui.DeclarativeValueProvider<T>> providers)
Grid
DeclarativeValueProvider
s.
Each member in the list of value providers corresponds to a column in the
grid.protected void doWriteDesign(org.jsoup.nodes.Element design, DesignContext designContext)
AbstractListing
This method is separated from
AbstractListing.writeDesign(Element, DesignContext)
to be overridable in
subclasses that need to replace this, but still must be able to call
super.writeDesign(...)
.
doWriteDesign
in class Grid<T>
design
- The element to write the component state to. Any previous
attributes or child nodes are not cleared.designContext
- The DesignContext instance used for writing the designAbstractListing.doReadDesign(Element, DesignContext)
protected void writeData(org.jsoup.nodes.Element body, DesignContext designContext)
Grid
DesignContext.shouldWriteData(Component)
returns true
for
the grid that is being written.public ItemCollapseAllowedProvider<T> getItemCollapseAllowedProvider()
Copyright © 2019 Vaadin Ltd. All rights reserved.