Package org.zkoss.stateless.sul

## Interface ITreeitem

- All Superinterfaces:
    `IComponent<ITreeitem>`, `IComposite<ITreeitem,​ITreeitemComposite>`, `IDisable<ITreeitem>`, `IHtmlBasedComponent<ITreeitem>`, `IXulElement<ITreeitem>`

      public interface ITreeitem
      extends IXulElement<ITreeitem>, IDisable<ITreeitem>, IComposite<ITreeitem,​ITreeitemComposite>

  Immutable `Treeitem` component

  Treeitem contains a row of data (treerow), and an optional treechildren.

  If the component doesn't contain a treechildren, it is a leaf node that doesn't accept any child items.

  If it contains a treechildren, it is a branch node that might contain other items. For a branch node, an `+/-` button will appear at the beginning of the row, such that user could open and close the item by clicking on the `+/-` button.

  ### Support @Action

  Name | Action Type
  --- | ---
  onOpen | ActionData: `OpenData` Denotes user has opened or closed a component. It is useful to implement load-on-demand by listening to the onOpen action, and creating components when the first time the component is opened.

  Author:
    jumperchen
  See Also:
    `Treeitem`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface | Description
    --- | --- | ---
    `static class` | `ITreeitem.Builder` | Builds instances of type `ITreeitem`.
    `static class` | `ITreeitem.Updater` | Builds an updater of type `ITreeitem` for `UiAgent.smartUpdate(Locator, SmartUpdater)`.

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static ITreeitem` | `DEFAULT` | Constant for default attributes of this immutable component.

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `default java.lang.String` | `getHflex()` | Return horizontal flex hint of this component.
    `default java.lang.String` | `getImage()` | Returns the image of the first `ITreecell` it contains.
    `default int` | `getIndex()` | Return the index of this item
    `default java.lang.String` | `getLabel()` | Returns the label of the first `ITreecell` it contains.
    `ITreechildren` | `getTreechildren()` | Returns the treechildren that this tree item owns, or null if doesn't have any child.
    `ITreerow` | `getTreerow()` | Returns the treerow that this tree item owns (might null).
    `default java.lang.String` | `getWidgetClass()` | Returns the client widget class.
    `default java.lang.String` | `getWidth()` | Returns the width of the component.
    `default boolean` | `isContainer()` | Returns whether the component is to act as a container which can have sublevel items.
    `default boolean` | `isEmpty()` | Returns whether to contain any sublevel tree items or not.
    `default boolean` | `isLoaded()` | Return true whether all children of this tree item, if any, is loaded at client
    `default boolean` | `isOpen()` | Returns whether this container is open.
    `default boolean` | `isRendered()` | Returns true whether this tree item is rendered at client.
    `default boolean` | `isSelectable()` | Returns whether it is selectable.
    `default boolean` | `isSelected()` | Returns whether this item is selected.
    `static ITreeitem` | `of​(java.lang.String label)` | Returns the instance with the given label.
    `static ITreeitem` | `of​(java.lang.String label, java.lang.Iterable<? extends ITreeitem> items)` | Returns the instance with the given label and all sublevel items.
    `static ITreeitem` | `of​(java.lang.String label, ITreeitem... items)` | Returns the instance with the given label and all sublevel items.
    `static ITreeitem` | `ofId​(java.lang.String id)` | Returns the instance with the given id.
    `static ITreeitem` | `ofTreecells​(java.lang.Iterable<? extends ITreecell<IAnyGroup>> treecells)` | Returns the instance with the given tree cells.
    `static ITreeitem` | `ofTreecells​(ITreecell<IAnyGroup>... treecells)` | Returns the instance with the given tree cells.
    `static ITreeitem` | `ofTreerow​(ITreerow treerow)` | Returns the instance with the given treerow.
    `default ITreeitem` | `withAllComponents​(java.lang.Iterable<? extends ITreeitemComposite> elements)` | Copy the current immutable object with elements that replace the content of `children`.
    `default ITreeitem` | `withHflex​(java.lang.String hflex)` | To control the size of Treeitem related components, please refer to `ITree` and `ITreecol` instead.
    `ITreeitem` | `withImage​(java.lang.String image)` | Returns a copy of `this` immutable component with the specified `image`.
    `ITreeitem` | `withIndex​(int index)` | Returns a copy of `this` immutable component with the specified `index`.
    `ITreeitem` | `withLabel​(java.lang.String label)` | Returns a copy of `this` immutable component with the specified `label`.
    `ITreeitem` | `withOpen​(boolean open)` | Returns a copy of `this` immutable component with the specified `open`.
    `ITreeitem` | `withSelectable​(boolean selectable)` | Returns a copy of `this` immutable component with the specified `selectable`.
    `ITreeitem` | `withSelected​(boolean selected)` | Returns a copy of `this` immutable component with the specified `selected`.
    `ITreeitem` | `withTreechildren​(ITreechildren treechildren)` | Returns a copy of `this` immutable component with the specified `treechildren`.
    `ITreeitem` | `withTreerow​(ITreerow treerow)` | Returns a copy of `this` immutable component with the specified `treerow`.
    `default ITreeitem` | `withWidth​(java.lang.String width)` | To control the size of Treeitem related components, please refer to `ITree` and `ITreecol` instead.

    - ### Methods inherited from interface org.zkoss.stateless.sul.IComponent

      `getAction, getActions, getClientAttributes, getId, getMold, getWidgetListeners, getWidgetOverrides, isVisible, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withActions, withActions, withClientAttribute, withClientAttributes, withId, withMold, withVisible, withWidgetClass, withWidgetListener, withWidgetListeners, withWidgetOverride, withWidgetOverrides`

    - ### Methods inherited from interface org.zkoss.stateless.sul.IDisable

      `isDisabled, withDisabled`

    - ### Methods inherited from interface org.zkoss.stateless.sul.IHtmlBasedComponent

      `getClientAction, getDraggable, getDroppable, getHeight, getLeft, getRenderdefer, getSclass, getStyle, getTabindex, getTooltiptext, getTop, getVflex, getZclass, getZIndex, isFocus, withClientAction, withDraggable, withDroppable, withFocus, withHeight, withLeft, withRenderdefer, withSclass, withStyle, withTabindex, withTabindex, withTooltiptext, withTop, withVflex, withZclass, withZIndex`

    - ### Methods inherited from interface org.zkoss.stateless.sul.IXulElement

      `getContext, getCtrlKeys, getPopup, getTooltip, withContext, withCtrlKeys, withPopup, withTooltip`

- - ### Field Detail

    - #### DEFAULT

          static final ITreeitem DEFAULT

      Constant for default attributes of this immutable component.

  - ### Method Detail

    - #### getWidgetClass

          default java.lang.String getWidgetClass()

      Returns the client widget class.

      Default: `"zul.sel.Treeitem"`

      Specified by:
        `getWidgetClass` in interface `IComponent<ITreeitem>`

    - #### getWidth

          @Derived
          @Nullable
          default java.lang.String getWidth()

      Description copied from interface: `IHtmlBasedComponent`
      Returns the width of the component. If not specified, `null` is assumed.

      Default: `null`

      Specified by:
        `getWidth` in interface `IHtmlBasedComponent<ITreeitem>`

    - #### withWidth

          default ITreeitem withWidth​(@Nullable
                                      java.lang.String width)

      To control the size of Treeitem related components, please refer to `ITree` and `ITreecol` instead.
      Specified by:
        `withWidth` in interface `IHtmlBasedComponent<ITreeitem>`
      Parameters:
        `width` - The width of the component.

        Default: `null`

      Returns:
        A modified copy of the `this` object

    - #### getHflex

          @Derived
          @Nullable
          default java.lang.String getHflex()

      Description copied from interface: `IHtmlBasedComponent`
      Return horizontal flex hint of this component.

      Default: `null`

      Specified by:
        `getHflex` in interface `IHtmlBasedComponent<ITreeitem>`

    - #### withHflex

          default ITreeitem withHflex​(@Nullable
                                      java.lang.String hflex)

      To control the size of Treeitem related components, please refer to `ITree` and `ITreecol` instead.
      Specified by:
        `withHflex` in interface `IHtmlBasedComponent<ITreeitem>`
      Parameters:
        `hflex` - The horizontal flex hint.

        Default: `null`

      Returns:
        A modified copy of the `this` object

    - #### withAllComponents

          default ITreeitem withAllComponents​(java.lang.Iterable<? extends ITreeitemComposite> elements)

      Description copied from interface: `IComposite`
      Copy the current immutable object with elements that replace the content of `children`. A shallow reference equality check is used to prevent copying of the same value by returning `this`.
      Specified by:
        `withAllComponents` in interface `IComposite<ITreeitem,​ITreeitemComposite>`
      Parameters:
        `elements` - An iterable of children elements to set
      Returns:
        A modified copy of `this` object

    - #### getTreerow

          @Nullable
          ITreerow getTreerow()

      Returns the treerow that this tree item owns (might null). Each tree items has exactly one tree row.

    - #### withTreerow

          ITreeitem withTreerow​(@Nullable
                                ITreerow treerow)

      Returns a copy of `this` immutable component with the specified `treerow`.

      Sets the treerow as a child to this component

      Parameters:
        `treerow` - The treerow child.

        Default: `null`.

      Returns:
        A modified copy of the `this` object

    - #### getTreechildren

          @Nullable
          ITreechildren getTreechildren()

      Returns the treechildren that this tree item owns, or null if doesn't have any child.

    - #### withTreechildren

          ITreeitem withTreechildren​(@Nullable
                                     ITreechildren treechildren)

      Returns a copy of `this` immutable component with the specified `treechildren`.

      Sets the treechildren as a child to this component

      Parameters:
        `treechildren` - The treechildren child.

        Default: `null`.

      Returns:
        A modified copy of the `this` object

    - #### getIndex

          default int getIndex()

      Return the index of this item

      Default: `-1`, meaning not set

    - #### withIndex

          ITreeitem withIndex​(int index)

      Returns a copy of `this` immutable component with the specified `index`.

      Sets the index of this component.

      Parameters:
        `index` - The index of the child from its parent component.

        Default: `-1`, meaning not set.

      Returns:
        A modified copy of the `this` object

    - #### getImage

          @Nullable
          default java.lang.String getImage()

      Returns the image of the first `ITreecell` it contains.

      Default: `null`

    - #### withImage

          ITreeitem withImage​(@Nullable
                              java.lang.String image)

      Returns a copy of `this` immutable component with the specified `image`.

      Sets the image of the first `ITreecell` it contains.

      If treerow and treecell are not created, this method create them automatically.

      Parameters:
        `image` - The image of the first `ITreecell` it contains.

        Default: `null`.

      Returns:
        A modified copy of the `this` object

    - #### getLabel

          @Nullable
          default java.lang.String getLabel()

      Returns the label of the first `ITreecell` it contains.

      Default: `null`

    - #### withLabel

          ITreeitem withLabel​(@Nullable
                              java.lang.String label)

      Returns a copy of `this` immutable component with the specified `label`.

      Sets the label of the first `ITreecell` it contains.

      If treerow and treecell are not created, this method create them automatically.

      Parameters:
        `label` - The label of the first `ITreecell` it contains.

        Default: `null`.

      Returns:
        A modified copy of the `this` object

    - #### isOpen

          default boolean isOpen()

      Returns whether this container is open.

      Default: `true`.

    - #### withOpen

          ITreeitem withOpen​(boolean open)

      Returns a copy of `this` immutable component with the specified `open`.

      Sets whether this container is open.

      Parameters:
        `open` - `false` to hide all sublevel items.

        Default: `true`.

      Returns:
        A modified copy of the `this` object

    - #### isSelected

          default boolean isSelected()

      Returns whether this item is selected.

      Default: `false`

    - #### withSelected

          ITreeitem withSelected​(boolean selected)

      Returns a copy of `this` immutable component with the specified `selected`.

      Sets whether the component is selected.

      Parameters:
        `selected` - `true` to select this component.

        Default: `false`.

      Returns:
        A modified copy of the `this` object

    - #### isLoaded

          default boolean isLoaded()

      Return true whether all children of this tree item, if any, is loaded at client

      Default: `false`

    - #### isSelectable

          default boolean isSelectable()

      Returns whether it is selectable.

      Default: `true`.

    - #### isContainer

          @Lazy
          default boolean isContainer()

      Returns whether the component is to act as a container which can have sublevel items.

    - #### isEmpty

          @Lazy
          default boolean isEmpty()

      Returns whether to contain any sublevel tree items or not.

    - #### withSelectable

          ITreeitem withSelectable​(boolean selectable)

      Returns a copy of `this` immutable component with the specified `selectable`.

      If the tree is in a checkmark mode, the selectable state will affect the checkable icon to display or not.

      Parameters:
        `selectable` - `false` to indicate the checkable icon is not displayed.

        Default: `true`.

      Returns:
        A modified copy of the `this` object

    - #### isRendered

          default boolean isRendered()

      Returns true whether this tree item is rendered at client. Unlike `isLoaded()` which is used to check whether all children of this tree item are loaded.

      Default: `true`

    - #### of

          static ITreeitem of​(java.lang.String label)

      Returns the instance with the given label.
      Parameters:
        `label` - The label that the first tree cell holds.

    - #### of

          static ITreeitem of​(java.lang.String label,
                              ITreeitem... items)

      Returns the instance with the given label and all sublevel items.
      Parameters:
        `label` - The label that the first tree cell holds.
        `items` - All sublevel items belong to this item

    - #### of

          static ITreeitem of​(java.lang.String label,
                              java.lang.Iterable<? extends ITreeitem> items)

      Returns the instance with the given label and all sublevel items.
      Parameters:
        `label` - The label that the first tree cell holds.
        `items` - All sublevel items belong to this item

    - #### ofId

          static ITreeitem ofId​(java.lang.String id)

      Returns the instance with the given id.
      Parameters:
        `id` - The id to identify this component

    - #### ofTreerow

          static ITreeitem ofTreerow​(ITreerow treerow)

      Returns the instance with the given treerow.
      Parameters:
        `treerow` - The treerow belongs to this component.

    - #### ofTreecells

          static ITreeitem ofTreecells​(ITreecell<IAnyGroup>... treecells)

      Returns the instance with the given tree cells.
      Parameters:
        `treecells` - All tree cells belong to this component.

    - #### ofTreecells

          static ITreeitem ofTreecells​(java.lang.Iterable<? extends ITreecell<IAnyGroup>> treecells)

      Returns the instance with the given tree cells.
      Parameters:
        `treecells` - All tree cells belong to this component.