Class OrgChart
- All Implemented Interfaces:
AttachNotifier,ClickNotifier<Div>,DetachNotifier,HasComponents,HasElement,HasEnabled,HasOrderedComponents,HasSize,HasStyle,HasText,Serializable
Uses JQuery library OrgChart to show an organization chart.
More information about this library at https://github.com/dabeng/OrgChart
- Author:
- pbartolo
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classEvent thrown when a node is dragged and dropped.static classEvent thrown when a node is clicked. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChildren(Integer nodeId, List<OrgChartItem> children) Adds one or more child nodes to a specified parent node in the chart.Adds a listener for child addition events.voidAdds aOrgChart.DragAndDropEventlistener to the component.Adds a listener for node removal events.Adds a listener for node updated event.voidaddParent(OrgChartItem newParentItem) Adds a new parent node to the organization chart.Adds a listener for parent addition event.voidaddSiblings(Integer nodeId, List<OrgChartItem> siblings) Adds one or more sibling nodes to a target node in the chart.Adds a listener for sibling addition events.protected voidfireChildrenAddedEvent(OrgChartItem item, List<OrgChartItem> newChildren, boolean fromClient) Fires a children added event.protected voidfireDragAndDropEvent(OrgChartItem draggedItem, boolean fromClient) Fires aOrgChart.DragAndDropEvent.protected voidfireNodeClickEvent(OrgChartItem clickedItem, boolean fromClient) Fires aOrgChart.NodeClickEvent.protected voidfireNodesRemovedEvent(Integer nodeId, boolean fromClient) Fires a nodes removed event.protected voidfireNodeUpdatedEvent(OrgChartItem item, boolean fromClient) Fires a node updated event.protected voidfireParentAddedEvent(OrgChartItem newParent, boolean fromClient) Fires a parent added event.protected voidfireSiblingsAddedEvent(OrgChartItem item, List<OrgChartItem> newSiblings, boolean fromClient) Fires a siblings added event.Returns latest value of the orgchart element.protected OrgChartStategetState()voidDeprecated.This method is no longer needed.protected voidonAttach(AttachEvent attachEvent) voidFires event on node click.voidremoveNodes(Integer nodeId) Removes a specified node and all of its descendants from the chart.voidsetChartDepth(Integer chartDepth) orgchart visibleLevel optionvoidsetChartDirection(String chartDirection) voidsetChartDraggable(Boolean chartDraggable) voidsetChartExpandCollapse(Boolean chartExpandCollapse) voidsetChartExportButton(Boolean chartExportButton) voidsetChartExportFileExtension(String chartExportFileExtension) voidsetChartExportFileName(String chartExportFileName) voidsetChartNodeContent(String chartNodeContent) voidsetChartNodeTitle(String chartNodeTitle) voidsetChartPan(Boolean chartPan) voidsetChartTitle(String chartTitle) voidsetChartToggleSiblingsResp(Boolean chartToggleSiblingsResp) voidsetChartVerticalDepth(Integer chartVerticalDepth) orgchart verticalLevel optionvoidsetChartZoom(Boolean chartZoom) voidsetChartZoominLimit(Double chartZoominLimit) voidsetChartZoomoutLimit(Double chartZoomoutLimit) voidCollapses all nodes except the rootvoidsetNodeTemplate(String parameterName, String functionBody) Sets the template generation function used to customize the internal structure of nodes.voidsetValue(OrgChartItem orgChartItem) voidupdateDraggedNode(String draggedNode, String dragZone, String dropZone) Updates chart after drag and drop event.voidupdateNode(Integer nodeId, OrgChartItem newDataItem) Updates a node in the chart with new data.Methods inherited from class com.vaadin.flow.component.HtmlComponent
getTitle, setTitleMethods inherited from class com.vaadin.flow.component.Component
addListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.ClickNotifier
addClickListener, addClickShortcutMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasComponents
add, add, addComponentAsFirst, addComponentAtIndex, remove, removeAllMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasOrderedComponents
getChildren, getComponentAt, getComponentCount, indexOf, replaceMethods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Constructor Details
-
OrgChart
-
-
Method Details
-
onAttach
-
initializeChart
Deprecated.This method is no longer needed. Initialization is done inonAttach(AttachEvent). -
setValue
-
getState
-
setChartNodeTitle
-
setChartNodeContent
-
setChartDirection
-
setChartTitle
-
setChartZoom
-
setChartExportButton
-
setChartExportFileName
-
setChartExportFileExtension
-
setChartPan
-
setChartZoominLimit
-
setChartZoomoutLimit
-
setChartDepth
orgchart visibleLevel option -
setChartVerticalDepth
orgchart verticalLevel option -
setChartToggleSiblingsResp
-
setChartExpandCollapse
-
setChartDraggable
-
getOrgChartItem
Returns latest value of the orgchart element. -
onClick
Fires event on node click.- Parameters:
nodeId-
-
updateDraggedNode
Updates chart after drag and drop event.- Parameters:
draggedNode-dragZone-dropZone-
-
setNodeTemplate
Sets the template generation function used to customize the internal structure of nodes.functionBodyis the body of a javascript function that recieves one parameter (the JSON datasoure representing a node) and returns an HTML snippet. The name of this parameter is given byparameterName.Example:
setNodeTemplate("item","return ''+item.name+'';")configures the following JS function as node template:function(item) { return ''+item.name+''; }custom properties are accessible throughitem.data- Parameters:
parameterName- the name of the parameter of a javascript functionfunctionBody- the body of a javascript function
-
addDragAndDropListener
Adds aOrgChart.DragAndDropEventlistener to the component.- Parameters:
listener- the listener to be added.
-
fireDragAndDropEvent
Fires aOrgChart.DragAndDropEvent.- Parameters:
draggedItem- the item being dragged.
-
addOnNodeClickListener
public Registration addOnNodeClickListener(ComponentEventListener<OrgChart.NodeClickEvent> listener) -
fireNodeClickEvent
Fires aOrgChart.NodeClickEvent.- Parameters:
clickedItem- the item being clicked.
-
setCollapsedNodes
public void setCollapsedNodes()Collapses all nodes except the root -
addSiblings
Adds one or more sibling nodes to a target node in the chart.This method inserts the new items at the same level as the target node, under the same parent. It updates both the internal data structure and the client-side visual representation.
- Parameters:
nodeId- the ID of the existing node that will serve as the anchor for adding siblings. This must not be the root node's ID.siblings- a list ofOrgChartItemobjects to be added as siblings- Throws:
IllegalArgumentException- if thenodeIdbelongs to the root node of the chart, as the root cannot have siblings or if thenodeIdis not found in the chart
-
addSiblingsAddedListener
Adds a listener for sibling addition events. The listener will be notified when new siblings are added to any node in the chart.- Parameters:
listener- the listener to be added- Returns:
- a
Registrationfor removing the listener
-
fireSiblingsAddedEvent
protected void fireSiblingsAddedEvent(OrgChartItem item, List<OrgChartItem> newSiblings, boolean fromClient) Fires a siblings added event.- Parameters:
item- the node that received new siblingsnewSiblings- list of the newly added siblingsfromClient- whether the event originated from the client side
-
addChildren
Adds one or more child nodes to a specified parent node in the chart.This method updates both the internal data model and the client-side visuals. Note the specific client-side behavior: if the parent node has no existing children, this uses the library's
addChildrenfunction. If the parent already has children, it uses theaddSiblingsfunction on the first existing child to append the new nodes.- Parameters:
nodeId- the ID of the parent node to which the new children will be addedchildren- a list ofOrgChartItemobjects to be added as new children- Throws:
IllegalArgumentException- if thenodeIdis not found in the chart
-
addChildrenAddedListener
Adds a listener for child addition events. The listener will be notified when new children are added to any node in the chart.- Parameters:
listener- the listener to be added- Returns:
- a
Registrationfor removing the listener
-
fireChildrenAddedEvent
protected void fireChildrenAddedEvent(OrgChartItem item, List<OrgChartItem> newChildren, boolean fromClient) Fires a children added event.- Parameters:
item- the node that received new childrennewChildren- list of the newly added childrenfromClient- whether the event originated from the client side
-
removeNodes
Removes a specified node and all of its descendants from the chart.This action updates both the server-side data model and the client-side visualization. If the root node is removed, the chart will likely become empty. This operation is permanent for the current state of the chart.
- Parameters:
nodeId- the ID of the node to remove. All children and subsequent descendants of this node will also be removed from the chart.- Throws:
IllegalArgumentException- if thenodeIdis not found in the chart
-
addNodesRemovedListener
Adds a listener for node removal events. The listener will be notified when a node and its descendants are removed from the chart.- Parameters:
listener- the listener to be added- Returns:
- a
Registrationfor removing the listener
-
fireNodesRemovedEvent
Fires a nodes removed event.- Parameters:
nodeId- the ID of the removed nodefromClient- whether the event originated from the client side
-
addParent
Adds a new parent node to the organization chart. This method:- Updates the visual representation of the chart
- Maintains the internal data structure by updating the root item
- Parameters:
newParentItem- the new root item of the chart
-
addParentAddedListener
Adds a listener for parent addition event. The listener will be notified when a new parent (root) is added to the chart.- Parameters:
listener- the listener to be added- Returns:
- a
Registrationfor removing the listener
-
fireParentAddedEvent
Fires a parent added event.- Parameters:
newParent- the node that was added as the new parent/rootfromClient- whether the event originated from the client side
-
updateNode
Updates a node in the chart with new data.This method updates the server-side data model and then calls the client-side function to visually redraw the node with the new information.
- Parameters:
nodeId- the ID of the node to updatenewDataItem- anOrgChartItemcontaining the new data to be merged. The ID of this item is ignored; only its other properties (name, title, custom data, etc) are used for the update.- Throws:
IllegalArgumentException- if thenodeIdis not found in the chart
-
addNodeUpdatedListener
Adds a listener for node updated event.- Parameters:
listener- the listener to be added- Returns:
- a
Registrationfor removing the listener
-
fireNodeUpdatedEvent
Fires a node updated event.- Parameters:
item- the updated nodefromClient- whether the event originated from the client side
-