Class TreeviewNode
java.lang.Object
com.jbstrap.core.messagebus.MessageBus
com.jbstrap.ui.Component<ListItem>
com.jbstrap.ui.components.list.ListItem
com.jbstrap.ui.components.treeview.TreeviewNode
- All Implemented Interfaces:
Animatable<ListItem>
,CanDrop<ListItem>
,Clickable<ListItem>
,Draggable<ListItem>
,Focusable<ListItem>
,HandleHotKey<ListItem>
,HandleMouseEvents<ListItem>
,Scrollable<ListItem>
,Touchable<ListItem>
A component representing a node in the treeview component The component is not intended for standalone use, it can only be inserted into the Treeview
as node of the tree.
- Since:
- 4.0
- Author:
- JBStrap
- See Also:
-
Field Summary
Fields inherited from class com.jbstrap.ui.Component
animation, attributes, backgroundColor, borderColor, color, defaultHotKeyHandler, handlers, hotKeys, styleClasses, textAlign, toolTip, toolTipPosition
-
Constructor Summary
ConstructorDescriptionTreeviewNode
(String name) Creates a tree by the specified nameTreeviewNode
(String name, TreeviewNode parent) Creates a node with the specified name and adds it below the parameter-specified parent node -
Method Summary
Modifier and TypeMethodDescriptionaddChildNode
(TreeviewNode child) Adds a child to the current node.addChildNodes
(TreeviewNode... children) Adds multiple child nodes to the current node.addClickHandler
(ClickEventHandler handler) Adds a single click event handler to the component.addComponent
(Component<?> component) Adds the specified component as a subcomponent, and redraws the component immediatelyAdds a double click event handler to the component.close()
Collapses the node.final TreeviewNode
Collapses the current node and all its children.final List<TreeviewNode>
find
(Predicate<TreeviewNode> filter) Gets all children nodes fulfilling the specified predicate.final TreeviewNode
findFirst
(Predicate<TreeviewNode> filter) Looks up the first node corresponding to the specified criterion.getChildNode
(String name) Gets a child node by its name.Gets all children of the current node.Gets the icon for a collapsed node.Gets the icon color for a collapsed node.Collection<Component<?>>
Gets all components in a node.getIcon()
Gets the node icon.Gets the node icon color.getName()
Gets the node name.Gets the icon for an expanded node.Gets the icon color for an expanded node.final TreeviewNode
Gets the parent of the nodeGets all the checked children nodes.getState()
Gets the node state.getTitle()
Gets the node textprotected final Treeview
Gets theTreeview
component where the node is displayed.final boolean
hasChild()
Sets if the node contains any children.protected final TreeviewNode
highlightNode
(boolean highlight) Highlights the node.boolean
Determines if the node is checked.final boolean
Sets if the node content is visible on the interface.boolean
Determines if the node is selected.open()
Expands the current node and all containing parents.final TreeviewNode
Expands the current node and all its children.removeChildNode
(TreeviewNode node) Removes a child node from the current node.removeChildNode
(TreeviewNode... nodes) Removes multiple chldren from the current node.removeChildNode
(String name) Removes a child from the node, referenced by the child node name.removeChildNodes
(String... names) Removes multiple children from the current node by the specified names.removeComponent
(Component<?> component) Removes the specified subcomponent.final TreeviewNode
select
(boolean select) Highlights the nodesetChecked
(boolean checked) Sets the checkbox state for the current node.setCloseIcon
(Icon icon) Sets the icon for a collapsed node.setCloseIcon
(Icon icon, String color) Sets the icon for a collapsed node and its color.final TreeviewNode
Sets an icon for the node.Sets an icon and its color for the node.setOpenIcon
(Icon icon) Sets the icon for an expanded node.setOpenIcon
(Icon icon, String color) Sets the icon for an expanded node and the icon color.final TreeviewNode
setParentNode
(TreeviewNode parent) Sets the parent for the nodefinal TreeviewNode
setState
(TreeviewNodeState state) Sets the node state.Sets the node text.final TreeviewNode
showContent
(boolean showContent) Displays or hides node content.Methods inherited from class com.jbstrap.ui.Component
_hide, _setAttribute, addAllowedRole, addComponent, addComponents, addDeniedRole, addHandler, addStyle, addStyleClass, addStyleClasses, afterDraw, clearfix, closeTag, combinateAccess, containsStyle, containsStyleClass, draw, drawSubComponents, error, flattendComponentTree, getAccess, getAccessMode, getAllowedRoles, getAttribute, getAttributes, getBackgroundColor, getBorderColor, getClient, getComponentById, getComponents, getComponents, getComponentsByClass, getData, getDeniedRoles, getHandlers, getId, getLanguageCode, getParent, getParent, getRegisteredEvents, getStyle, getStyleClasses, getTextAlign, getTextColor, getToolTip, getToolTipPosition, getTypeName, getUI, init, insertComponentAfter, insertComponentBefore, isAccess, isDrawn, isEnabled, isEventBubbling, isVisible, onHide, onHotKeyEventHandler, onShow, openTag, redraw, removeAllComponents, removeAllowedRole, removeAllStyleClasses, removeAttribute, removeComponent, removeComponents, removeDeniedRole, removeHandler, removeStyle, removeStyle, removeStyleClass, removeStyleClasses, replaceComponent, replaceStyleClass, runAfterDraw, runJavaScript, runJavaScript, runJavaScript, runOnHide, runOnShow, say, setAttribute, setBackgroundColor, setBorder, setBorderColor, setData, setDisplayType, setEnabled, setEventBubbling, setFlex, setFloating, setHeight100, setHeight25, setHeight50, setHeight75, setHeightAuto, setLanguage, setMargin, setName, setOverflow, setPadding, setParent, setScrollable, setSelectionType, setShadow, setStyle, setTextAlign, setTextColor, setToolTip, setToolTipPosition, setVisible, setWidth100, setWidth25, setWidth50, setWidth75, setWidthAuto, showNotification, showNotification, showProcessIndicator, toggleStyleClass
Methods inherited from class com.jbstrap.core.messagebus.MessageBus
closeMessageBus, messageBusOpened, openMessageBus, renewSubscription, sendMessageToMessageBus, subscribeMessageBus, unsubscribeAllListeners, unsubscribeMessageBus
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.jbstrap.ui.Animatable
addAnimationEndHandler, addAnimationStartHandler, getAnimation, removeAnimation, setAnimation
Methods inherited from interface com.jbstrap.ui.CanDrop
addDropEventHandler
Methods inherited from interface com.jbstrap.ui.Draggable
addDragEndEventHandler, addDragStartEventHandler, setDraggable
Methods inherited from interface com.jbstrap.ui.Focusable
addFocusHandler, addFocusInHandler, addFocusOutHandler, addLosesFocusHandler, setFocus
Methods inherited from interface com.jbstrap.ui.HandleHotKey
addHotKey, addHotKey, removeHotKey, removeHotKeys
Methods inherited from interface com.jbstrap.ui.HandleMouseEvents
addMouseDownHandler, addMouseEnterHandler, addMouseLeaveHandler, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseUpHandler, addMouseWheelHandler
Methods inherited from interface com.jbstrap.ui.Scrollable
addScrollHandler
Methods inherited from interface com.jbstrap.ui.Touchable
addTouchCancelHandler, addTouchEndHandler, addTouchMoveHandler, addTouchStartHandler
-
Constructor Details
-
TreeviewNode
Creates a tree by the specified name- Parameters:
name
- The distinct name of the node- Throws:
NullPointerException
- Thrown if the specified name isnull
-
TreeviewNode
Creates a node with the specified name and adds it below the parameter-specified parent node- Parameters:
name
- The distinct name of the nodeparent
- An instance of the node’s parent- Throws:
NullPointerException
- Thrown if the specified name isnull
-
-
Method Details
-
select
Highlights the node- Parameters:
select
- Iftrue
is set, the node gets selected, otherwise it is not selected- Returns:
- The treeview component
-
setParentNode
Sets the parent for the node- Parameters:
parent
- An instance of the node used to set the parent- Returns:
- The node component
-
getParentNode
Gets the parent of the node- Returns:
- The parent of the node or
null
if the node has no parent (root node)
-
getTreeview
Gets theTreeview
component where the node is displayed.- Returns:
- The treeview component where the node is displayed If the node is not displayed,
null
is returned.
-
getName
Gets the node name. -
setTitle
Sets the node text.- Parameters:
title
- The text to be displayed on the node- Returns:
- The treeview node
-
getTitle
Gets the node text- Returns:
- Node text or
null
if there is no text set for the node
-
setIcon
Sets an icon for the node. This method sets an icon for the node, irrespective of its state (expanded, collapsed).- Parameters:
icon
- The icon to be set for the node. Available icon are listed in the enumIcon
.- Returns:
- The treeview node
-
setIcon
Sets an icon and its color for the node. This method sets an icon for the node, irrespective of its state (expanded, collapsed).- Parameters:
icon
- The icon to be set for the node. Available icon are listed in the enumIcon
.color
- The color of the displayed icon as defined by the CSS3 standard- Returns:
- The treeview node
-
getIcon
Gets the node icon.- Returns:
- The node icon or
null
if no icon is set for the node
-
getIconColor
Gets the node icon color.- Returns:
- The node icon color in the specified format
-
setOpenIcon
Sets the icon for an expanded node. The icon specified here is displayed only if the node is expanded.- Parameters:
icon
- The icon to be displayed if the node is expanded. Available icon are listed in the enumIcon
.- Returns:
- The treeview node
-
setOpenIcon
Sets the icon for an expanded node and the icon color. The icon specified here is displayed only if the node is expanded.- Parameters:
icon
- The icon to be displayed if the node is expanded. Available icon are listed in the enumIcon
.color
- The icon color as defined by the CSS3 standard- Returns:
- The treeview node
-
setCloseIcon
Sets the icon for a collapsed node. The icon specified here is displayed only if the node is collapsed.- Parameters:
icon
- The icon to be displayed only if the node is collapsed. Available icon are listed in the enumIcon
.- Returns:
- The treeview node
-
setCloseIcon
Sets the icon for a collapsed node and its color. The icon specified here is displayed only if the node is expanded.- Parameters:
icon
- The icon to be displayed only if the node is collapsed. Available icon are listed in the enumIcon
.color
- The icon color as defined by the CSS3 standard- Returns:
- The treeview node
-
getOpenIcon
Gets the icon for an expanded node.- Returns:
- The icon for an expanded node or
null
if the icon is not displayed if the node is expanded
-
getOpenIconColor
Gets the icon color for an expanded node.- Returns:
- The icon color for an expanded node in the specified format
-
getCloseIcon
Gets the icon for a collapsed node.- Returns:
- The icon for a collapsed node or
null
if no icon is displayed if the node is collapsed
-
getCloseIconColor
Gets the icon color for a collapsed node.- Returns:
- The icon color for a collapsed node in the specified format
-
addChildNode
Adds a child to the current node. The node is automatically set as a parent to the child node specified here.- Parameters:
child
- Child node instance- Returns:
- The treeview node
-
addChildNodes
Adds multiple child nodes to the current node. The parent node is automatically set for all of the child nodes specified here.- Parameters:
children
- An enumeration of all nodes to be added to the current node as children- Returns:
- The treeview node
-
removeChildNode
Removes a child from the node, referenced by the child node name. If no child is found by the specified name under the current node, the method does nothing.- Parameters:
name
- The name of the child node to be removed- Returns:
- The treeview node
-
removeChildNode
Removes a child node from the current node. If the specified node is not the child of the current node, the method does nothing.- Parameters:
node
- An instance of the node we want to remove from the node’s children- Returns:
- The treeview node
-
removeChildNodes
Removes multiple children from the current node by the specified names. If there is name among the specified name that is not a child of the current node, it is ignored.- Parameters:
names
- An enumeration of all the names whose corresponding nodes we want to remove from the node’s children- Returns:
- The treeview node
-
removeChildNode
Removes multiple chldren from the current node. If the enumeration contains a node that is not a child of the current node, it is ignored.- Parameters:
nodes
- An enumeration of all nodes to be removed- Returns:
- The treeview node
-
getChildNodes
Gets all children of the current node.- Returns:
- A collection of all children nodes of the current node or
null
if the current node has no children, that is, it is a leaf node.
-
getChildNode
Gets a child node by its name.- Parameters:
name
- The name of the child node we want to get- Returns:
- The child node corresponding to the specified name or
null
if the node by the specified name is not a child of the current node
-
isChecked
public boolean isChecked()Determines if the node is checked.- Returns:
- If
true
, the node is checked, otherwisefalse
-
isSelected
public boolean isSelected()Determines if the node is selected.- Returns:
- If
true
, the node is selected, otherwisefalse
-
setChecked
Sets the checkbox state for the current node.- Parameters:
checked
- Iftrue
is set, the node is checked, otherwise not checked- Returns:
- The treeview node
-
open
Expands the current node and all containing parents.- Returns:
- The treeview node
-
openCascade
Expands the current node and all its children.- Returns:
- The treeview node
-
close
Collapses the node.- Returns:
- The treeview node
-
closeCascade
Collapses the current node and all its children.- Returns:
- The treeview node
-
getState
Gets the node state. (A node can have two states: expanded or collapsed.)- Returns:
- The current state of the node
-
setState
Sets the node state.- Parameters:
state
- The node state Available node states are listed in the enumTreeviewNodeState
.- Returns:
- The treeview node
-
addComponent
Description copied from class:Component
Adds the specified component as a subcomponent, and redraws the component immediately- Overrides:
addComponent
in classComponent<ListItem>
- Parameters:
component
- The component to be added- Returns:
- The component
-
removeComponent
Description copied from class:Component
Removes the specified subcomponent.- Overrides:
removeComponent
in classComponent<ListItem>
- Parameters:
component
- The component instance- Returns:
- The component
-
getContent
Gets all components in a node.- Returns:
- A collection of all components in a node. If the node contains no components, an empty collection is returned.
-
getSelectedChildNodes
Gets all the checked children nodes.- Returns:
- A list of all the checked children nodes If there are no checked children nodes, an empty list is returned.
-
hasChild
public final boolean hasChild()Sets if the node contains any children.- Returns:
- If
true
, the node has children, otherwisefalse
-
findFirst
Looks up the first node corresponding to the specified criterion. This means if the node fulfils the specified criterion, the current node is returned, in all other cases the first node of the current one, fulfilling the criterion is returned, that is, either an immediate child or the child of some of the children.- Parameters:
filter
- The predicate that the node must fulfil- Returns:
- The first node fulfilling the specified predicate or
null
if there is no node fulfilling the predicate. - Throws:
NullPointerException
- Thrown if the specified predicate isnull
-
find
Gets all children nodes fulfilling the specified predicate. The lookup returns not only the immediate children, but also the children of the children, fulfilling the specified predicate.- Parameters:
filter
- The predicate that the nodes in the lookup must fulfil- Returns:
- All children nodes fulfilling the specified predicate or an empty list if no children fulfil the specified predicate
-
showContent
Displays or hides node content. The node’s content is not visible by default. The method is responsible for making the content visible or invisible.- Parameters:
showContent
- Iftrue
is set, the node content is visible, otherwise invisible- Returns:
- The treeview node
-
isContentShown
public final boolean isContentShown()Sets if the node content is visible on the interface.- Returns:
- If
true
, the content is displayed on the interface, otherwisefalse
-
highlightNode
Highlights the node.- Parameters:
highlight
- Iftrue
is set, the node is highlighted, otherwisefalse
- Returns:
- The treeview node
-
setCurrent
- Returns:
- The treeview node
-
addClickHandler
Description copied from interface:Clickable
Adds a single click event handler to the component. This handler runs when the user clicks once on the component.- Parameters:
handler
- TheClickEventHandler
implementation- Returns:
- The component
- See Also:
-
addDoubleClickHandler
Description copied from interface:Clickable
Adds a double click event handler to the component. This handler runs when the user clicks twice on the component.- Parameters:
handler
- ADoubleClickEventHandler
implementation- Returns:
- The component
- See Also:
-