Class AbstractTreeRowModel<T>
- java.lang.Object
-
- org.eclipse.nebula.widgets.nattable.tree.AbstractTreeRowModel<T>
-
- All Implemented Interfaces:
ITreeRowModel<T>
- Direct Known Subclasses:
GlazedListTreeRowModel
,TreeRowModel
public abstract class AbstractTreeRowModel<T> extends Object implements ITreeRowModel<T>
-
-
Constructor Summary
Constructors Constructor Description AbstractTreeRowModel(ITreeData<T> treeData)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<Integer>
collapse(T object)
Collapse the tree node that represent the given object.int
depth(int index)
List<Integer>
expand(T object)
Expands the tree node that represents the given object.List<Integer>
expandToLevel(T object, int level)
Expands the tree node that represents the given object to a certain level.List<Integer>
getChildIndexes(int parentIndex)
This method returns all visible child indexes below the node at the given index.List<T>
getChildren(int parentIndex)
This method returns all children below the node at the given index.protected List<T>
getChildren(T parent)
List<Integer>
getDirectChildIndexes(int parentIndex)
This method returns only the direct visible child indexes of the node at the given index.List<T>
getDirectChildren(int parentIndex)
This method returns only the direct children of the node at the given index.protected List<T>
getDirectChildren(T parent)
ITreeData<T>
getTreeData()
Returns theITreeData
that is backed by this tree row model.boolean
hasChildren(int index)
boolean
isCollapsed(T object)
boolean
isCollapsible(int index)
Checks if the tree node at the given index is collapsible or not.boolean
isLeaf(int index)
void
notifyListeners()
void
registerRowGroupModelListener(ITreeRowModelListener listener)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.nebula.widgets.nattable.tree.ITreeRowModel
collapse, collapseAll, expand, expandAll, expandToLevel, expandToLevel, isCollapsed
-
-
-
-
Method Detail
-
registerRowGroupModelListener
public void registerRowGroupModelListener(ITreeRowModelListener listener)
-
notifyListeners
public void notifyListeners()
-
depth
public int depth(int index)
- Specified by:
depth
in interfaceITreeRowModel<T>
- Parameters:
index
- The index of the tree element to check.- Returns:
- The number of ancestors of the node at the specified index. Root nodes have depth 0, other nodes depth is one greater than the depth of their parent node.
-
isLeaf
public boolean isLeaf(int index)
- Specified by:
isLeaf
in interfaceITreeRowModel<T>
- Parameters:
index
- The index of the tree element to check.- Returns:
true
if the tree element at the given index has no children and therefore is a leaf,false
if the tree element has children and therefore is a node.
-
hasChildren
public boolean hasChildren(int index)
- Specified by:
hasChildren
in interfaceITreeRowModel<T>
- Parameters:
index
- The index of the tree element to check.- Returns:
true
if the tree element at the given index has children,false
if not.
-
isCollapsed
public boolean isCollapsed(T object)
- Specified by:
isCollapsed
in interfaceITreeRowModel<T>
- Parameters:
object
- The element that should be checked.- Returns:
true
if the children of the given element are visible,false
if not.
-
isCollapsible
public boolean isCollapsible(int index)
Checks if the tree node at the given index is collapsible or not.- Specified by:
isCollapsible
in interfaceITreeRowModel<T>
- Parameters:
index
- The index of the tree node to check.- Returns:
true
if the tree node at the given index has children,false
if not.
-
collapse
public List<Integer> collapse(T object)
Description copied from interface:ITreeRowModel
Collapse the tree node that represent the given object.- Specified by:
collapse
in interfaceITreeRowModel<T>
- Parameters:
object
- The object that represents the tree node to collapse.- Returns:
- The indexes of all children of the collapsed tree node that become invisible by performing the collapse operation.
-
expand
public List<Integer> expand(T object)
Description copied from interface:ITreeRowModel
Expands the tree node that represents the given object.- Specified by:
expand
in interfaceITreeRowModel<T>
- Parameters:
object
- The object that represents the tree node to expand.- Returns:
- The indexes of all children of the expanded tree node that become visible by performing the expand operation.
-
expandToLevel
public List<Integer> expandToLevel(T object, int level)
Description copied from interface:ITreeRowModel
Expands the tree node that represents the given object to a certain level.- Specified by:
expandToLevel
in interfaceITreeRowModel<T>
- Parameters:
object
- The object that represents the tree node to expand.level
- The level to which the tree node should be expanded.- Returns:
- The indexes of all children that are showed after the expand operation is performed.
-
getChildIndexes
public List<Integer> getChildIndexes(int parentIndex)
Description copied from interface:ITreeRowModel
This method returns all visible child indexes below the node at the given index. It search all the way down the tree structure to find every child, even the sub children, sub sub children and so on.If you only need to get the direct child indexes of the node at the given index you need to use
ITreeRowModel.getDirectChildIndexes(int)
instead.- Specified by:
getChildIndexes
in interfaceITreeRowModel<T>
- Parameters:
parentIndex
- The index for which the child indexes are requested.- Returns:
- The list of all child indexes for the node at the given index.
-
getDirectChildIndexes
public List<Integer> getDirectChildIndexes(int parentIndex)
Description copied from interface:ITreeRowModel
This method returns only the direct visible child indexes of the node at the given index. It does not search all the way down for further sub children.If you need to get all child indexes of the node at the given index you need to use
ITreeRowModel.getChildIndexes(int)
instead.- Specified by:
getDirectChildIndexes
in interfaceITreeRowModel<T>
- Parameters:
parentIndex
- The index for which the direct child indexes are requested.- Returns:
- The list of the direct child indexes for the node at the given index.
-
getChildren
public List<T> getChildren(int parentIndex)
Description copied from interface:ITreeRowModel
This method returns all children below the node at the given index. It search all the way down the tree structure to find every child, even the sub children, sub sub children and so on.If you only need to get the direct children of the node at the given index you need to use
ITreeRowModel.getDirectChildren(int)
instead.- Specified by:
getChildren
in interfaceITreeRowModel<T>
- Parameters:
parentIndex
- The index for which the children are requested.- Returns:
- The list of all children for the node at the given index.
-
getDirectChildren
public List<T> getDirectChildren(int parentIndex)
Description copied from interface:ITreeRowModel
This method returns only the direct children of the node at the given index. It does not search all the way down for further sub children.If you need to get all children of the node at the given index you need to use
ITreeRowModel.getChildren(int)
instead.- Specified by:
getDirectChildren
in interfaceITreeRowModel<T>
- Parameters:
parentIndex
- The index for which the direct children are requested.- Returns:
- The list of the direct children for the node at the given index.
-
-