Package io.jmix.ui.component
Interface Tree<E>
- Type Parameters:
E
- an entity type
- All Superinterfaces:
ActionsHolder
,Component
,Component.BelongToFrame
,Component.Focusable
,Component.HasCaption
,Component.HasDescription
,Component.HasIcon
,HasButtonsPanel
,HasContextHelp
,HasHtmlCaption
,HasHtmlDescription
,HasHtmlSanitizer
,HasItemCaptionProvider<E>
,HasSubParts
,ListComponent<E>
,LookupComponent<E>
- All Known Implementing Classes:
TreeImpl
@StudioComponent(caption="Tree",
category="Components",
xmlElement="tree",
icon="io/jmix/ui/icon/component/tree.svg",
canvasBehaviour=TREE,
documentationURL="https://docs.jmix.io/jmix/%VERSION%/ui/vcl/components/tree.html")
public interface Tree<E>
extends ListComponent<E>, HasButtonsPanel, Component.HasCaption, Component.HasIcon, LookupComponent<E>, Component.Focusable, HasContextHelp, HasItemCaptionProvider<E>, HasHtmlCaption, HasHtmlDescription, HasHtmlSanitizer
A component is intended to display hierarchical structures represented by entities referencing themselves.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
An event that is fired when an item is collapsed.static class
An event that is fired when an item is expanded.static class
Event sent when the selection changes.static enum
Nested classes/interfaces inherited from interface io.jmix.ui.component.Component
Component.Alignment, Component.BelongToFrame, Component.Disposable, Component.Editable, Component.Focusable, Component.HasCaption, Component.HasDescription, Component.HasIcon, Component.HasXmlDescriptor, Component.Wrapper
Nested classes/interfaces inherited from interface io.jmix.ui.component.HasContextHelp
HasContextHelp.ContextHelpIconClickEvent
Nested classes/interfaces inherited from interface io.jmix.ui.component.LookupComponent
LookupComponent.LookupSelectionChangeEvent<T>, LookupComponent.LookupSelectionChangeNotifier<T>
-
Field Summary
Fields inherited from interface io.jmix.ui.component.Component
AUTO_SIZE, AUTO_SIZE_PX, FULL_SIZE
-
Method Summary
Modifier and TypeMethodDescriptionaddCollapseListener
(Consumer<Tree.CollapseEvent<E>> listener) Registers a new collapse listener.addExpandListener
(Consumer<Tree.ExpandEvent<E>> listener) Registers a new expand listener.addSelectionListener
(Consumer<Tree.SelectionEvent<E>> listener) Registers a new selection listener.void
addStyleProvider
(Function<? super E, String> styleProvider) Adds a style provider for tree items.void
Collapses all tree nodes that are lower in level than a given item.void
Collapses tree nodes.void
Expands all tree nodes that are higher in level that a given item.void
Expands all tree nodes.void
expandUpTo
(int level) Expands tree including specified levelGets the item description generator.getItems()
boolean
boolean
isDetailsVisible
(E entity) Checks whether details are visible for the given item.boolean
isExpanded
(Object itemId) Returns whether an item with given itemId is expanded or collapsed.static <T> org.springframework.core.ParameterizedTypeReference<Tree<T>>
void
removeStyleProvider
(Function<? super E, String> styleProvider) Removes a previously added style provider.void
repaint()
Repaints UI representation of the tree including style providers and icon providers without refreshing the tree data.void
setContentMode
(ContentMode contentMode) Sets the content mode of the item captions.void
setContextMenuEnabled
(boolean contextMenuEnabled) Sets whether or not context menu is enabled.void
setDescriptionProvider
(Function<? super E, String> provider) Sets the description generator that is used for generating tooltip descriptions for items.void
setDescriptionProvider
(Function<? super E, String> provider, ContentMode contentMode) Sets the description generator that is used for generating HTML tooltip descriptions for items.void
setDetailsGenerator
(Function<E, Component> generator) Sets a new details generator for item details.void
setDetailsVisible
(E entity, boolean visible) Shows or hides the details for a specific item.void
setEnterPressAction
(Action action) Sets the action to be executed on Enter key press.void
setIconProvider
(Function<? super E, String> iconProvider) Sets the icon provider for the tree.void
setItemClickAction
(Action action) Sets the action to be executed when double-clicking inside a tree node.void
Sets aDataUnit
supported by the Tree.void
setRowHeight
(double rowHeight) Sets the height of a row.void
setSelectionMode
(Tree.SelectionMode selectionMode) Sets the Tree's selection mode.void
setStyleProvider
(Function<? super E, String> styleProvider) Sets a single style provider for tree items.Methods inherited from interface io.jmix.ui.component.ActionsHolder
addAction, addAction, getAction, getActionNN, getActions, getSubPart, removeAction, removeAction, removeAllActions
Methods inherited from interface io.jmix.ui.component.Component
addStyleName, getAlignment, getHeight, getHeightSizeUnit, getId, getParent, getStyleName, getWidth, getWidthSizeUnit, isEnabled, isEnabledRecursive, isResponsive, isVisible, isVisibleRecursive, removeStyleName, setAlignment, setEnabled, setHeight, setHeightAuto, setHeightFull, setId, setParent, setResponsive, setSizeAuto, setSizeFull, setStyleName, setVisible, setWidth, setWidthAuto, setWidthFull, unwrap, unwrapComposition, unwrapCompositionOrNull, unwrapOrNull, withUnwrapped, withUnwrappedComposition
Methods inherited from interface io.jmix.ui.component.Component.BelongToFrame
getFrame, setFrame
Methods inherited from interface io.jmix.ui.component.Component.Focusable
focus, getTabIndex, isFocusable, setFocusable, setTabIndex
Methods inherited from interface io.jmix.ui.component.Component.HasCaption
getCaption, setCaption
Methods inherited from interface io.jmix.ui.component.Component.HasDescription
getDescription, setDescription
Methods inherited from interface io.jmix.ui.component.Component.HasIcon
getIcon, setIcon, setIconFromSet
Methods inherited from interface io.jmix.ui.component.HasButtonsPanel
getButtonsPanel, setButtonsPanel
Methods inherited from interface io.jmix.ui.component.HasContextHelp
getContextHelpIconClickHandler, getContextHelpText, isContextHelpTextHtmlEnabled, setContextHelpIconClickHandler, setContextHelpText, setContextHelpTextHtmlEnabled
Methods inherited from interface io.jmix.ui.component.HasHtmlCaption
isCaptionAsHtml, setCaptionAsHtml
Methods inherited from interface io.jmix.ui.component.HasHtmlDescription
isDescriptionAsHtml, setDescriptionAsHtml
Methods inherited from interface io.jmix.ui.component.HasHtmlSanitizer
isHtmlSanitizerEnabled, setHtmlSanitizerEnabled
Methods inherited from interface io.jmix.ui.component.HasItemCaptionProvider
getItemCaptionProvider, setItemCaptionProvider
Methods inherited from interface io.jmix.ui.component.ListComponent
getSelected, getSingleSelected, isMultiSelect, setSelected, setSelected
Methods inherited from interface io.jmix.ui.component.LookupComponent
getLookupSelectedItems, setLookupSelectHandler
-
Field Details
-
NAME
- See Also:
-
-
Method Details
-
of
-
expandTree
void expandTree()Expands all tree nodes. -
expand
Expands all tree nodes that are higher in level that a given item.- Parameters:
item
- an item
-
collapseTree
void collapseTree()Collapses tree nodes. -
collapse
Collapses all tree nodes that are lower in level than a given item.- Parameters:
item
- an item
-
expandUpTo
void expandUpTo(int level) Expands tree including specified level- Parameters:
level
- level of Tree nodes to expand, if passed level = 1 then root items will be expanded- Throws:
IllegalArgumentException
- if level < 1
-
isExpanded
Returns whether an item with given itemId is expanded or collapsed.- Parameters:
itemId
- item id to check- Returns:
- true if the item with itemId is expanded, false if collapsed
-
getHierarchyProperty
String getHierarchyProperty()- Returns:
- the name of the property which forms the hierarchy
-
getItems
- Specified by:
getItems
in interfaceListComponent<E>
- Returns:
- a
DataUnit
supported by the Tree
-
setItems
Sets aDataUnit
supported by the Tree.- Parameters:
treeItems
-DataUnit
supported by the Tree
-
setItemClickAction
Sets the action to be executed when double-clicking inside a tree node.- Parameters:
action
- a new action
-
getItemClickAction
- Returns:
- an item double-click action
-
setStyleProvider
Sets a single style provider for tree items.- Parameters:
styleProvider
- a style provider to set
-
addStyleProvider
Adds a style provider for tree items.- Parameters:
styleProvider
- a style provider to add
-
removeStyleProvider
Removes a previously added style provider.- Parameters:
styleProvider
- a style provider to remove
-
setIconProvider
Sets the icon provider for the tree.- Parameters:
iconProvider
- an icon provider to set
-
repaint
void repaint()Repaints UI representation of the tree including style providers and icon providers without refreshing the tree data. -
setEnterPressAction
Sets the action to be executed on Enter key press.- Parameters:
action
- a new action
-
getEnterPressAction
- Returns:
- an Enter key press action
-
getSelectionMode
Tree.SelectionMode getSelectionMode()- Returns:
- the currently used
Tree.SelectionMode
-
setSelectionMode
@StudioProperty(type=ENUMERATION, defaultValue="SINGLE", options={"SINGLE","MULTI","NONE"}) void setSelectionMode(Tree.SelectionMode selectionMode) Sets the Tree's selection mode.- Parameters:
selectionMode
- the selection mode to use
-
isContextMenuEnabled
boolean isContextMenuEnabled()- Returns:
true
if context menu is enabled,false
otherwise
-
setContextMenuEnabled
void setContextMenuEnabled(boolean contextMenuEnabled) Sets whether or not context menu is enabled. Default value istrue
.- Parameters:
contextMenuEnabled
- specifies whether context menu is enabled
-
setDescriptionProvider
Sets the description generator that is used for generating tooltip descriptions for items.- Parameters:
provider
- the description generator to use ornull
to remove a previously set provider if any
-
setDescriptionProvider
Sets the description generator that is used for generating HTML tooltip descriptions for items.- Parameters:
provider
- the description generator to use ornull
to remove a previously set provider if anycontentMode
- the content mode for row tooltips
-
getDescriptionProvider
Gets the item description generator.- Returns:
- the item description generator
-
getDetailsGenerator
- Returns:
- the current details generator for item details or
null
if not set
-
setDetailsGenerator
Sets a new details generator for item details.The currently opened item details will be re-rendered.
- Parameters:
generator
- the details generator to set
-
isDetailsVisible
Checks whether details are visible for the given item.- Parameters:
entity
- the item for which to check details visibility- Returns:
true
if the details are visible
-
setDetailsVisible
Shows or hides the details for a specific item.- Parameters:
entity
- the item for which to set details visibilityvisible
-true
to show the details, orfalse
to hide them
-
addExpandListener
Registers a new expand listener.- Parameters:
listener
- the listener to be added- Returns:
- a registration object for removing an event listener added to a source
-
addCollapseListener
Registers a new collapse listener.- Parameters:
listener
- the listener to be added- Returns:
- a registration object for removing an event listener added to a source
-
setRowHeight
Sets the height of a row. If -1 (default), the row height is calculated based on the theme for an empty row before the Tree is displayed.- Parameters:
rowHeight
- The height of a row in pixels or -1 for automatic calculation
-
getContentMode
ContentMode getContentMode()- Returns:
- the content mode of the item captions
-
setContentMode
@StudioProperty(type=ENUMERATION, defaultValue="TEXT", options={"TEXT","PREFORMATTED","HTML"}) void setContentMode(ContentMode contentMode) Sets the content mode of the item captions.- Parameters:
contentMode
- the content mode
-
addSelectionListener
Registers a new selection listener.- Parameters:
listener
- the listener to register
-