public class TreeTableUtils extends Object
Constructor and Description |
---|
TreeTableUtils() |
Modifier and Type | Method and Description |
---|---|
static Row |
getChildAt(TableModel model,
Row parent,
int index)
Get the child of the parent row in the designated index inside the table model.
|
static int |
getChildIndex(TableModel model,
Row parent,
Row child)
Get the index of the child within the parent's children inside the table model.
|
static List<Row> |
getChildren(TableModel model,
Row parent)
Get children list of the parent row inside the table model.
|
static int |
getChildrenCount(TableModel model,
Row parent)
Get the direct children count of a row inside the table model.
|
static int |
getDescendantCount(TableModel model,
Row parent,
boolean leafOnly,
boolean includeCollapsedNodes)
The method can only be used for any table model who has one inner model as
TreeTableModel to find the current visible descendant count in that level. |
static List<Row> |
getDescendants(TableModel model,
Row parent,
boolean directChildOnly,
boolean leafOnly,
boolean includeCollapsedNodes)
Gets descendants list of the parent row inside the table model.
|
static Row |
getRow(TableModel model,
int rowIndex)
Gets the row in the row index of the table model.
|
static boolean |
hasDescendant(TableModel model,
Row parent,
boolean leafOnly,
boolean includeCollapsedNodes)
Gets if there is at least one descendant for the parent row in the model.
|
public static int getChildrenCount(TableModel model, Row parent)
getDescendantCount(javax.swing.table.TableModel, Row, boolean, boolean)
returns the count of its descendant.model
- the table model. In most case, it should be an instance of ITreeTableModelparent
- the parent rowgetChildren(javax.swing.table.TableModel, Row)
public static int getChildIndex(TableModel model, Row parent, Row child)
model
- the table model. In most case, it should be an instance of ITreeTableModelparent
- the parent rowchild
- the child rowgetChildren(javax.swing.table.TableModel, Row)
public static Row getChildAt(TableModel model, Row parent, int index)
model
- the table model. In most case, it should be an instance of ITreeTableModelparent
- the parent rowindex
- the child indexgetChildren(javax.swing.table.TableModel, Row)
public static Row getRow(TableModel model, int rowIndex)
model
- the table modelrowIndex
- the row indexpublic static List<Row> getChildren(TableModel model, Row parent)
model
- the table model. In most case, it should be an instance of ITreeTableModelparent
- the parent rowpublic static List<Row> getDescendants(TableModel model, Row parent, boolean directChildOnly, boolean leafOnly, boolean includeCollapsedNodes)
model
- the table model. In most case, it should be an instance of ITreeTableModelparent
- the parent rowdirectChildOnly
- the flag if only direct child should be returnedleafOnly
- the flag if only leaf descendants should be returnedincludeCollapsedNodes
- the flag if the collapsed nodes need to be includedpublic static boolean hasDescendant(TableModel model, Row parent, boolean leafOnly, boolean includeCollapsedNodes)
getDescendantCount(javax.swing.table.TableModel, Row, boolean, boolean)
since it will simply return true without looping all child nodes as long as it gets one visible child row.model
- the outer table modelparent
- the Row to be queriedleafOnly
- the count will only include leaf children or notincludeCollapsedNodes
- if the collapsed nodes need to be includedpublic static int getDescendantCount(TableModel model, Row parent, boolean leafOnly, boolean includeCollapsedNodes)
TreeTableModel
to find the current visible descendant count in that level. It has two options,
leaf only or count collapsed nodes.
It could hit performance since we have to expand all to count the actual leaf nodes then set the original expansion
state back.model
- the outer table modelparent
- the Row to be queriedleafOnly
- the count will only include leaf children or notincludeCollapsedNodes
- if the collapsed nodes need to be included