Package org.zkoss.zul

Interface TreeModel<E>

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      void addTreeDataListener​(TreeDataListener l)
      Add a listener to the tree that's notified each time a change to the data model occurs
      E getChild​(int[] path)
      Returns the child at the given path where the path indicates the child is placed in the whole tree.
      E getChild​(E parent, int index)
      Returns the child of the given parent at the given index where the index indicates in the parent's child array.
      int getChildCount​(E parent)
      Returns the number of children of the given parent.
      int getIndexOfChild​(E parent, E child)
      Returns the index of the given child in the given parent.
      int[] getPath​(E child)
      Returns the path from the given child, where the path indicates the child is placed in the whole tree.
      E getRoot()
      Returns the root of the tree.
      default java.util.List<TreeDataListener> getTreeDataListeners()
      Returns all listeners.
      boolean isLeaf​(E node)
      Returns true if node is a leaf.
      void removeTreeDataListener​(TreeDataListener l)
      Remove a listener to the tree that's notified each time a change to the data model occurs
    • Method Detail

      • isLeaf

        boolean isLeaf​(E node)
        Returns true if node is a leaf. Notice that not all non-leaf nodes have children. In file-system terminology, a leaf node is a file, while a non-leaf node is a folder.
        Parameters:
        node - a node in the tree, obtained from this data source
        Returns:
        true if node is a leaf.
      • getChild

        E getChild​(E parent,
                   int index)
        Returns the child of the given parent at the given index where the index indicates in the parent's child array.
        Parameters:
        parent - a node in the tree, obtained from this data source
        Returns:
        the child of parent at index
      • getChild

        E getChild​(int[] path)
        Returns the child at the given path where the path indicates the child is placed in the whole tree.
        Parameters:
        path - the tree path
        Returns:
        the child at path
        Since:
        6.0.0
      • getChildCount

        int getChildCount​(E parent)
        Returns the number of children of the given parent.
        Parameters:
        parent - a node in the tree, obtained from this data source
        Returns:
        the number of children of the node parent
      • getIndexOfChild

        int getIndexOfChild​(E parent,
                            E child)
        Returns the index of the given child in the given parent. If either parent or child is null, returns -1. If either parent or child don't belong to this tree model, returns -1.
        Parameters:
        parent - a node in the tree, obtained from this data source
        child - the node we are interested in
        Returns:
        the index of the child in the parent, or -1 if either child or parent are null or don't belong to this tree model
        Since:
        5.0.6
      • getRoot

        E getRoot()
        Returns the root of the tree.
        Returns:
        the root of Tree.
      • getPath

        int[] getPath​(E child)
        Returns the path from the given child, where the path indicates the child is placed in the whole tree.
        Parameters:
        child - the node we are interested in
        Since:
        6.0.0
      • addTreeDataListener

        void addTreeDataListener​(TreeDataListener l)
        Add a listener to the tree that's notified each time a change to the data model occurs
        Parameters:
        l - the listener to add
      • removeTreeDataListener

        void removeTreeDataListener​(TreeDataListener l)
        Remove a listener to the tree that's notified each time a change to the data model occurs
        Parameters:
        l - the listener to remove
      • getTreeDataListeners

        default java.util.List<TreeDataListener> getTreeDataListeners()
        Returns all listeners.