Class OrgChart

All Implemented Interfaces:
AttachNotifier, ClickNotifier<Div>, DetachNotifier, HasComponents, HasElement, HasEnabled, HasOrderedComponents, HasSize, HasStyle, HasText, Serializable

@NpmPackage(value="orgchart",version="3.7.0") @NpmPackage(value="html2canvas",version="1.4.1") @NpmPackage(value="jquery",version="3.6.2") @NpmPackage(value="json-digger",version="2.0.2") @JsModule("jquery/dist/jquery.js") @JsModule("orgchart/dist/js/jquery.orgchart.js") @JsModule("./fc-orgchart.js") @CssImport("orgchart/dist/css/jquery.orgchart.min.css") @CssImport("./fc-orgchart-styles.css") @Tag("fc-orgchart") public class OrgChart extends Div
OrgChart component definition.
Uses JQuery library OrgChart to show an organization chart.
More information about this library at https://github.com/dabeng/OrgChart
Author:
pbartolo
See Also:
  • Constructor Details

  • Method Details

    • onAttach

      protected void onAttach(AttachEvent attachEvent)
      Overrides:
      onAttach in class Component
    • initializeChart

      @Deprecated public void initializeChart()
      Deprecated.
      This method is no longer needed. Initialization is done in onAttach(AttachEvent).
    • setValue

      public void setValue(OrgChartItem orgChartItem)
    • getState

      protected OrgChartState getState()
    • setChartNodeTitle

      public void setChartNodeTitle(String chartNodeTitle)
    • setChartNodeContent

      public void setChartNodeContent(String chartNodeContent)
    • setChartDirection

      public void setChartDirection(String chartDirection)
    • setChartTitle

      public void setChartTitle(String chartTitle)
    • setChartZoom

      public void setChartZoom(Boolean chartZoom)
    • setChartExportButton

      public void setChartExportButton(Boolean chartExportButton)
    • setChartExportFileName

      public void setChartExportFileName(String chartExportFileName)
    • setChartExportFileExtension

      public void setChartExportFileExtension(String chartExportFileExtension)
    • setChartPan

      public void setChartPan(Boolean chartPan)
    • setChartZoominLimit

      public void setChartZoominLimit(Double chartZoominLimit)
    • setChartZoomoutLimit

      public void setChartZoomoutLimit(Double chartZoomoutLimit)
    • setChartDepth

      public void setChartDepth(Integer chartDepth)
      orgchart visibleLevel option
    • setChartVerticalDepth

      public void setChartVerticalDepth(Integer chartVerticalDepth)
      orgchart verticalLevel option
    • setChartToggleSiblingsResp

      public void setChartToggleSiblingsResp(Boolean chartToggleSiblingsResp)
    • setChartExpandCollapse

      public void setChartExpandCollapse(Boolean chartExpandCollapse)
    • setChartDraggable

      public void setChartDraggable(Boolean chartDraggable)
    • getOrgChartItem

      public OrgChartItem getOrgChartItem()
      Returns latest value of the orgchart element.
    • onClick

      @ClientCallable public void onClick(String nodeId)
      Fires event on node click.
      Parameters:
      nodeId -
    • updateDraggedNode

      @ClientCallable public void updateDraggedNode(String draggedNode, String dragZone, String dropZone)
      Updates chart after drag and drop event.
      Parameters:
      draggedNode -
      dragZone -
      dropZone -
    • setNodeTemplate

      public void setNodeTemplate(String parameterName, String functionBody)
      Sets the template generation function used to customize the internal structure of nodes. functionBody is 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 by parameterName.

      Example: setNodeTemplate("item","return ''+item.name+'';") configures the following JS function as node template: function(item) { return ''+item.name+''; } custom properties are accessible through item.data

      Parameters:
      parameterName - the name of the parameter of a javascript function
      functionBody - the body of a javascript function
    • addDragAndDropListener

      public void addDragAndDropListener(ComponentEventListener<OrgChart.DragAndDropEvent> listener)
      Adds a OrgChart.DragAndDropEvent listener to the component.
      Parameters:
      listener - the listener to be added.
    • fireDragAndDropEvent

      protected void fireDragAndDropEvent(OrgChartItem draggedItem, boolean fromClient)
      Parameters:
      draggedItem - the item being dragged.
    • addOnNodeClickListener

      public Registration addOnNodeClickListener(ComponentEventListener<OrgChart.NodeClickEvent> listener)
    • fireNodeClickEvent

      protected void fireNodeClickEvent(OrgChartItem clickedItem, boolean fromClient)
      Parameters:
      clickedItem - the item being clicked.
    • setCollapsedNodes

      public void setCollapsedNodes()
      Collapses all nodes except the root
    • addSiblings

      public void addSiblings(Integer nodeId, List<OrgChartItem> siblings)
      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 of OrgChartItem objects to be added as siblings
      Throws:
      IllegalArgumentException - if the nodeId belongs to the root node of the chart, as the root cannot have siblings or if the nodeId is not found in the chart
    • addSiblingsAddedListener

      public Registration addSiblingsAddedListener(ComponentEventListener<SiblingsAddedEvent> listener)
      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 Registration for 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 siblings
      newSiblings - list of the newly added siblings
      fromClient - whether the event originated from the client side
    • addChildren

      public void addChildren(Integer nodeId, List<OrgChartItem> children)
      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 addChildren function. If the parent already has children, it uses the addSiblings function 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 added
      children - a list of OrgChartItem objects to be added as new children
      Throws:
      IllegalArgumentException - if the nodeId is not found in the chart
    • addChildrenAddedListener

      public Registration addChildrenAddedListener(ComponentEventListener<ChildrenAddedEvent> listener)
      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 Registration for 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 children
      newChildren - list of the newly added children
      fromClient - whether the event originated from the client side
    • removeNodes

      public void removeNodes(Integer nodeId)
      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 the nodeId is not found in the chart
    • addNodesRemovedListener

      public Registration addNodesRemovedListener(ComponentEventListener<NodesRemovedEvent> listener)
      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 Registration for removing the listener
    • fireNodesRemovedEvent

      protected void fireNodesRemovedEvent(Integer nodeId, boolean fromClient)
      Fires a nodes removed event.
      Parameters:
      nodeId - the ID of the removed node
      fromClient - whether the event originated from the client side
    • addParent

      public void addParent(OrgChartItem newParentItem)
      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

      public Registration addParentAddedListener(ComponentEventListener<ParentAddedEvent> listener)
      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 Registration for removing the listener
    • fireParentAddedEvent

      protected void fireParentAddedEvent(OrgChartItem newParent, boolean fromClient)
      Fires a parent added event.
      Parameters:
      newParent - the node that was added as the new parent/root
      fromClient - whether the event originated from the client side
    • updateNode

      public void updateNode(Integer nodeId, OrgChartItem newDataItem)
      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 update
      newDataItem - an OrgChartItem containing 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 the nodeId is not found in the chart
    • addNodeUpdatedListener

      public Registration addNodeUpdatedListener(ComponentEventListener<NodeUpdatedEvent> listener)
      Adds a listener for node updated event.
      Parameters:
      listener - the listener to be added
      Returns:
      a Registration for removing the listener
    • fireNodeUpdatedEvent

      protected void fireNodeUpdatedEvent(OrgChartItem item, boolean fromClient)
      Fires a node updated event.
      Parameters:
      item - the updated node
      fromClient - whether the event originated from the client side