Package org.zkoss.zkmax.zul

## Class Organigram

- java.lang.Object
- - org.zkoss.zk.ui.AbstractComponent
  - - org.zkoss.zk.ui.HtmlBasedComponent
    - - org.zkoss.zul.impl.XulElement
      - - org.zkoss.zkmax.zul.Organigram

- All Implemented Interfaces:
    `java.io.Serializable`, `java.lang.Cloneable`, `Component`, `Scope`, `ComponentCtrl`

      public class Organigram
      extends XulElement

  A container which can be used to draw a hierarchical organizational chart, you can specify a `TreeModel` to render the data.

  Event:

  1. `SelectEvent` is sent when user changes the selection.

  To retrieve what is selected in Organigram with a `TreeSelectableModel`, you shall use `TreeSelectableModel.isPathSelected(int[])` to check whether the current path is selected in `TreeSelectableModel` rather than using `getSelectedItem()`. That is, you shall operate on the item of the `TreeSelectableModel` rather than on the `Orgitem` of the `Organigram` if you use the `TreeSelectableModel` and `TreeModel`.

  To retrieve what are opened nodes in Organigram with a `TreeOpenableModel`, you shall use `TreeOpenableModel.isPathOpened(int[])` to check whether the current path is opened in `TreeOpenableModel` rather than using `Orgitem.isOpen()`. That is, you shall operate on the item of the `TreeOpenableModel` rather than on the `Orgitem` of the `Organigram` if you use the `TreeOpenableModel` and `TreeModel`.

  Since:
    8.6.0
  See Also:
    Serialized Form

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.zkoss.zk.ui.HtmlBasedComponent

      `HtmlBasedComponent.ExtraCtrl`

    - ### Nested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent

      `AbstractComponent.Children, AbstractComponent.ForwardInfo, AbstractComponent.TargetInfo`

  - ### Field Summary

    - ### Fields inherited from class org.zkoss.zk.ui.HtmlBasedComponent

      `_zclass`

    - ### Fields inherited from interface org.zkoss.zk.ui.Component

      `APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPE`

    - ### Fields inherited from interface org.zkoss.zk.ui.sys.ComponentCtrl

      `AFTER_CHILD_ADDED, AFTER_CHILD_REMOVED, AFTER_CLONED, AFTER_PAGE_ATTACHED, AFTER_PAGE_DETACHED, AFTER_PARENT_CHANGED, CE_BUSY_IGNORE, CE_DUPLICATE_IGNORE, CE_IMPORTANT, CE_NON_DEFERRABLE, CE_REPEAT_IGNORE`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `Organigram()` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `beforeChildAdded​(Component child, Component insertBefore)` | Default: does nothing.
    `void` | `clear()` | Clears all child Orgitems (`Orgitem`.
    `java.lang.Object` | `clone()` | Clones the component.
    `int` | `getItemCount()` | Returns the number of child `Orgitem`.
    `<T> OrgitemRenderer<T>` | `getItemRenderer()` | Returns the renderer to render each item, or null if the default renderer is used.
    `java.util.Collection<Orgitem>` | `getItems()` | Returns a readonly list of all descending `Orgitem` (children's children and so on).
    `<T> TreeModel<T>` | `getModel()` | Returns the tree model associated with this Organigram, or null if this Organigram is not associated with any tree data model.
    `Orgchildren` | `getOrgchildren()` | Returns the Orgchildren that this Organigram owns.
    `Orgitem` | `getSelectedItem()` | Returns the selected item.
    `int` | `getVisibleItemCount()` | Returns the number of visible descendant `Orgitem`.
    `java.lang.String` | `getZclass()` | Returns the ZK Cascading Style class for this component.
    `boolean` | `insertBefore​(Component newChild, Component refChild)` | Inserts a child before the reference child.
    `void` | `onChildRemoved​(Component child)` | Default: handles special event listeners.
    `void` | `onInitRender()` | Handles a private event, onInitRender.
    `void` | `onPageAttached​(Page newpage, Page oldpage)` | Default: handles special event listeners.
    `void` | `onPageDetached​(Page page)` | Default: handles special event listeners.
    `void` | `renderItem​(Orgitem item)` | Renders the specified `Orgitem`, if not loaded yet, with `getItemRenderer()`.
    `protected void` | `renderProperties​(ContentRenderer renderer)` | Renders the content of this component, excluding the enclosing tags and children.
    `void` | `service​(AuRequest request, boolean everError)` | Processes an AU request.
    `void` | `sessionDidActivate​(Page page)` | Notification that the session, which owns this component, has just been activated (a.k.a., deserialized).
    `void` | `sessionWillPassivate​(Page page)` | Notification that the session, which owns this component, is about to be passivated (a.k.a., serialized).
    `void` | `setItemRenderer​(java.lang.String clsnm)` | Sets the renderer by use of a class name.
    `void` | `setItemRenderer​(OrgitemRenderer<?> renderer)` | Sets the renderer which is used to render each item if `getModel()` is not null.
    `void` | `setModel​(TreeModel<?> model)` | Sets the tree model associated with this Organigram.
    `void` | `setSelectedItem​(Orgitem selectedItem)` | Deselects previous selected item and selects the given item.

    - ### Methods inherited from class org.zkoss.zul.impl.XulElement

      `getContext, getCtrlKeys, getPopup, getPropertyAccess, getTooltip, setContext, setContext, setContextAttributes, setCtrlKeys, setPopup, setPopup, setPopupAttributes, setTooltip, setTooltip, setTooltipAttributes`

    - ### Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent

      `addSclass, evalCSSFlex, focus, getAction, getClientAction, getDraggable, getDroppable, getExtraCtrl, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getStyle, getTabindex, getTabindexInteger, getTooltiptext, getTop, getVflex, getWidth, getZindex, getZIndex, removeSclass, removeSclass, setAction, setClass, setClientAction, setDraggable, setDroppable, setFocus, setHeight, setHeight0, setHeightDirectly, setHflex, setHflex0, setHflexDirectly, setLeft, setLeftDirectly, setRenderdefer, setSclass, setStyle, setTabindex, setTabindex, setTooltiptext, setTop, setTopDirectly, setVflex, setVflex0, setVflexDirectly, setWidth, setWidth0, setWidthDirectly, setZclass, setZindex, setZIndex, setZIndexDirectly`

    - ### Methods inherited from class org.zkoss.zk.ui.AbstractComponent

      `addAnnotation, addCallback, addClientEvent, addEventHandler, addEventListener, addEventListener, addForward, addForward, addForward, addForward, addMoved, addRedrawCallback, addScopeListener, addShadowRoot, addShadowRootBefore, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildRemoved, beforeParentChanged, destroyIndexCacheMap, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableBindingAnnotation, disableClientUpdate, disableHostChanged, enableBindingAnnotation, enableHostChanged, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getAutag, getCallback, getChildren, getClientAttribute, getClientDataAttribute, getClientEvents, getDefaultMold, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getEventListenerMap, getEventListeners, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getForwards, getId, getIndexCacheMap, getLastChild, getMold, getNextSibling, getPage, getParent, getPreviousSibling, getRedrawCallback, getRoot, getShadowFellowIfAny, getShadowRoots, getShadowVariable, getShadowVariable, getShadowVariable0, getSpaceOwner, getSpecialRendererOutput, getStubonly, getSubBindingAnnotationCount, getTemplate, getTemplateNames, getUuid, getWidgetAttributeNames, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasBindingAnnotation, hasFellow, hasFellow, hasSubBindingAnnotation, initIndexCacheMap, invalidate, isChildable, isDisabledHostChanged, isInitialized, isInvalidated, isListenerAvailable, isVisible, onChildAdded, onParentChanged, onWrongValue, query, queryAll, redraw, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeCallback, removeChild, removeEventListener, removeForward, removeForward, removeRedrawCallback, removeScopeListener, removeShadowRoot, render, render, render, renderPropertiesOnly, replace, response, response, response, service, setAttribute, setAttribute, setAttribute, setAuService, setAutag, setClientAttribute, setClientDataAttribute, setDefinition, setDefinition, setId, setMold, setPage, setPageBefore, setParent, setStubonly, setStubonly, setSubBindingAnnotationCount, setTemplate, setVisible, setVisibleDirectly, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, updateByClient, updateSubBindingAnnotationCount, willPassivate, willPassivate, willSerialize, willSerialize`

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### Organigram

          public Organigram()

  - ### Method Detail

    - #### getOrgchildren

          public Orgchildren getOrgchildren()

      Returns the Orgchildren that this Organigram owns.
      Returns:
        Orgchildren

    - #### getItems

          public java.util.Collection<Orgitem> getItems()

      Returns a readonly list of all descending `Orgitem` (children's children and so on).

      Note: the performance of the size method of returned collection is no good.

      Returns:
        readonly list of all descending `Orgitem`

    - #### getItemCount

          public int getItemCount()

      Returns the number of child `Orgitem`. The same as `getItems()`.size().

      Note: the performance of this method is no good.

      Returns:
        the number of child `Orgitem`.

    - #### getVisibleItemCount

          public int getVisibleItemCount()

      Returns the number of visible descendant `Orgitem`. Descendants include direct children, grand children and so on.
      Returns:
        the number of visible descendant `Orgitem`.

    - #### getSelectedItem

          public Orgitem getSelectedItem()

      Returns the selected item. Note: Organigram only accepts one selected item.
      Returns:
        the selected item.

    - #### setSelectedItem

          public void setSelectedItem​(Orgitem selectedItem)

      Deselects previous selected item and selects the given item. Note: Organigram only accepts one selected item.
      Parameters:
        `selectedItem` - the item will be selected

    - #### clear

          public void clear()

      Clears all child Orgitems (`Orgitem`.

      Note: after clear, `getOrgchildren()` won't be null, but it has no child.

    - #### beforeChildAdded

          public void beforeChildAdded​(Component child,
                                       Component insertBefore)

      Description copied from class: `AbstractComponent`
      Default: does nothing.
      Specified by:
        `beforeChildAdded` in interface `ComponentCtrl`
      Overrides:
        `beforeChildAdded` in class `AbstractComponent`
      Parameters:
        `child` - the child to be added (never null).
        `insertBefore` - another child component that the new child will be inserted before it. If null, the new child will be the last child.
      See Also:
        `ComponentCtrl.beforeChildAdded(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component)`

    - #### insertBefore

          public boolean insertBefore​(Component newChild,
                                      Component refChild)

      Description copied from interface: `Component`
      Inserts a child before the reference child.

      You could use `Component.setParent(org.zkoss.zk.ui.Component)` or `Component.appendChild(org.zkoss.zk.ui.Component)` instead of this method, unless you want to control where to put the child.

      Note: `Component.setParent(org.zkoss.zk.ui.Component)` always calls back `Component.insertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component)` and/or `Component.removeChild(org.zkoss.zk.ui.Component)`, while `Component.insertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component)` and `Component.removeChild(org.zkoss.zk.ui.Component)` always calls back `Component.setParent(org.zkoss.zk.ui.Component)`, if the parent is changed. Thus, you don't need to override both `Component.insertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component)` and `Component.setParent(org.zkoss.zk.ui.Component)`, if you want to customize the behavior.

      If you would like to monitor if a component is attached or detached from a page, you could register a desktop listener implementing `UiLifeCycle`.

      Specified by:
        `insertBefore` in interface `Component`
      Overrides:
        `insertBefore` in class `AbstractComponent`
      Parameters:
        `newChild` - the new child to be inserted.
        `refChild` - the child before which you want the new child being inserted. If null, the new child is append to the end.
      Returns:
        true if newChild is added successfully or moved; false if it already has the specified child and the order doesn't change.

    - #### onChildRemoved

          public void onChildRemoved​(Component child)

      Description copied from class: `AbstractComponent`
      Default: handles special event listeners.
      Specified by:
        `onChildRemoved` in interface `ComponentCtrl`
      Overrides:
        `onChildRemoved` in class `AbstractComponent`
      See Also:
        `ComponentCtrl.onChildRemoved(org.zkoss.zk.ui.Component)`

    - #### onPageAttached

          public void onPageAttached​(Page newpage,
                                     Page oldpage)

      Description copied from class: `AbstractComponent`
      Default: handles special event listeners.
      Specified by:
        `onPageAttached` in interface `ComponentCtrl`
      Overrides:
        `onPageAttached` in class `AbstractComponent`
      Parameters:
        `newpage` - the new page (never null).
        `oldpage` - the previous page, if any, or null if it didn't belong to any page.
      See Also:
        `ComponentCtrl.onPageAttached(org.zkoss.zk.ui.Page, org.zkoss.zk.ui.Page)`

    - #### onPageDetached

          public void onPageDetached​(Page page)

      Description copied from class: `AbstractComponent`
      Default: handles special event listeners.
      Specified by:
        `onPageDetached` in interface `ComponentCtrl`
      Overrides:
        `onPageDetached` in class `AbstractComponent`
      Parameters:
        `page` - the previous page (never null)
      See Also:
        `ComponentCtrl.onPageDetached(org.zkoss.zk.ui.Page)`

    - #### clone

          public java.lang.Object clone()

      Description copied from interface: `Component`
      Clones the component. All of its children and descendants are cloned. Also, ID are preserved.
      Specified by:
        `clone` in interface `Component`
      Overrides:
        `clone` in class `XulElement`
      Returns:
        the new component. Notice that it doesn't belong to any page, nor desktop. It doesn't have a parent, either.

    - #### sessionWillPassivate

          public void sessionWillPassivate​(Page page)

      Description copied from interface: `ComponentCtrl`
      Notification that the session, which owns this component, is about to be passivated (a.k.a., serialized).

      Note: only root components are notified by this method.

      Specified by:
        `sessionWillPassivate` in interface `ComponentCtrl`
      Overrides:
        `sessionWillPassivate` in class `AbstractComponent`

    - #### sessionDidActivate

          public void sessionDidActivate​(Page page)

      Description copied from interface: `ComponentCtrl`
      Notification that the session, which owns this component, has just been activated (a.k.a., deserialized).

      Note: only root components are notified by this method.

      Specified by:
        `sessionDidActivate` in interface `ComponentCtrl`
      Overrides:
        `sessionDidActivate` in class `AbstractComponent`

    - #### getModel

          public <T> TreeModel<T> getModel()

      Returns the tree model associated with this Organigram, or null if this Organigram is not associated with any tree data model.
      Returns:
        the tree model associated with this Organigram

    - #### setModel

          public void setModel​(TreeModel<?> model)

      Sets the tree model associated with this Organigram.

      Parameters:
        `model` - the tree model to associate, or null to dissociate any previous model.
      Throws:
        `UiException` - if failed to initialize with the model

    - #### onInitRender

          public void onInitRender()

      Handles a private event, onInitRender. It is used only for implementation, and you rarely need to invoke it explicitly.

    - #### getItemRenderer

          public <T> OrgitemRenderer<T> getItemRenderer()

      Returns the renderer to render each item, or null if the default renderer is used.

    - #### setItemRenderer

          public void setItemRenderer​(OrgitemRenderer<?> renderer)

      Sets the renderer which is used to render each item if `getModel()` is not null.

      Note: changing a render will cause the Organigram to re-render.

      Parameters:
        `renderer` - the renderer, or null to use the default.

    - #### setItemRenderer

          public void setItemRenderer​(java.lang.String clsnm)
                               throws java.lang.ClassNotFoundException,
                                      java.lang.NoSuchMethodException,
                                      java.lang.IllegalAccessException,
                                      java.lang.InstantiationException,
                                      java.lang.reflect.InvocationTargetException

      Sets the renderer by use of a class name. It creates an instance automatically.
      Parameters:
        `clsnm` - the class name of renderer
      Throws:
        `java.lang.ClassNotFoundException`
        `java.lang.NoSuchMethodException`
        `java.lang.IllegalAccessException`
        `java.lang.InstantiationException`
        `java.lang.reflect.InvocationTargetException`

    - #### renderItem

          public void renderItem​(Orgitem item)

      Renders the specified `Orgitem`, if not loaded yet, with `getItemRenderer()`.

      It does nothing if `getModel()` returns null.

      Parameters:
        `item` - the item to be rendered

    - #### service

          public void service​(AuRequest request,
                              boolean everError)

      Description copied from class: `HtmlBasedComponent`
      Processes an AU request.

      Default: it handles onClick, onDoubleClick, onRightClick onMove, onSize, onZIndex.

      Specified by:
        `service` in interface `ComponentCtrl`
      Overrides:
        `service` in class `HtmlBasedComponent`
        `everError` - whether any error ever occurred before processing this request.
      See Also:
        `AbstractComponent.setAuService(org.zkoss.zk.au.AuService)`

    - #### renderProperties

          protected void renderProperties​(ContentRenderer renderer)
                                   throws java.io.IOException

      Description copied from class: `HtmlBasedComponent`
      Renders the content of this component, excluding the enclosing tags and children.

      See also ZK Client-side Reference: Property Rendering

      Overrides:
        `renderProperties` in class `XulElement`
      Throws:
        `java.io.IOException`

    - #### getZclass

          public java.lang.String getZclass()

      Description copied from class: `HtmlBasedComponent`
      Returns the ZK Cascading Style class for this component. It usually depends on the implementation of the mold (`AbstractComponent.getMold()`).

      Default: null (the default value depends on element).

      `HtmlBasedComponent.setZclass(java.lang.String)`) will completely replace the default style of a component. In other words, the default style of a component is associated with the default value of `HtmlBasedComponent.getZclass()`. Once it is changed, the default style won't be applied at all. If you want to perform small adjustments, use `HtmlBasedComponent.setSclass(java.lang.String)` instead.

      Overrides:
        `getZclass` in class `HtmlBasedComponent`
      See Also:
        `HtmlBasedComponent.getSclass()`