Class TreeRows

java.lang.Object
com.codename1.ui.table.TreeRows

public final class TreeRows extends Object

The open nodes of a TreeTableModel, flattened into rows in the order they are shown: the row engine of a tree DataGrid, for any other view of a tree that needs rows.

The rows are empty until refresh() reads the roots. Nodes are told apart by equals and hashCode (see TreeTableModel). A row is a node and its depth, 0 for a root; opening a row inserts the rows of its open descendants after it, and closing it removes them.

Children are asked of the model the first time a node is opened and kept; opening a node inserts its rows and closing one removes them, so either costs what the node shows and not what the tree holds. A filter is the exception: deciding which paths lead to a match reads the whole tree.

  • Constructor Details

    • TreeRows

      public TreeRows(TreeTableModel model)
      Rows over a tree model, empty until refresh().
  • Method Details

    • getModel

      public TreeTableModel getModel()
      The model the rows show.
    • getRowCount

      public int getRowCount()
      How many rows there are.
    • getNode

      public Object getNode(int row)
      The node a row shows.
    • getDepth

      public int getDepth(int row)
      How deep a row is: 0 for a root.
    • isRowExpandable

      public boolean isRowExpandable(int row)
      Whether a row can open: its node is not a leaf.
    • isRowExpanded

      public boolean isRowExpanded(int row)
      Whether a row is open.
    • setRowExpanded

      public int setRowExpanded(int row, boolean open)

      Opens or closes a row.

      Returns

      how many rows were inserted after it, or removed after it when negative; 0 when nothing moved

    • getRow

      public int getRow(Object node)
      The row showing a node, or -1 when it has none.
    • isNodeExpanded

      public boolean isNodeExpanded(Object node)
      Whether a node is open, shown or not.
    • setNodeExpanded

      public int setNodeExpanded(Object node, boolean open)

      Opens or closes a node whether it is shown or not; one that is not shown opens the next time it is.

      Returns

      the rows inserted or, when negative, removed after the node's row

    • refresh

      public void refresh()
      Asks the model for the whole tree again and flattens it, keeping which nodes are open.
    • refreshNode

      public void refreshNode(Object node)
      Asks the model again for the children of one node and flattens the tree, keeping which nodes are open.