Interface TreeItem
-
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
TreeItemImpl
public interface TreeItem extends Serializable
- Author:
- Bogdan Stefanescu
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Object
accept(TreeItemVisitor visitor)
Accepts a visitor.void
collapse()
Collapses this item.TreeItem[]
expand()
Expands the item.TreeItem
find(Path path)
Finds the item given its relative path to that item.TreeItem
findAndReveal(Path path)
Finds the item given its relative path to that item and expand all its parents so that the item will be visible in the tree.TreeItem
getChild(String name)
Gets the child item given its name.TreeItem[]
getChildren()
Gets the cached children.ContentProvider
getContentProvider()
Gets the current content provider.String
getLabel()
Gets the label to be displayed for this item.String
getName()
Gets this node name.Object
getObject()
Gets the object attached to this item.TreeItem
getParent()
Gets the parent item or null if this is the root item.Path
getPath()
Gets the item path.int
getValidationState()
Returns the validation state.boolean
hasChildren()
Tests whether this item has any children.void
invalidate(int type)
Invalidates the item.boolean
isContainer()
Tests whether or not the item may have children.boolean
isExpanded()
Tests whether or not the item is expanded.void
refresh(int type)
Reloads item information like label, properties and children depending on the specified refresh type.void
validate()
Validates the item.
-
-
-
Field Detail
-
NONE
static final int NONE
- See Also:
- Constant Field Values
-
DATA
static final int DATA
- See Also:
- Constant Field Values
-
CHILDREN
static final int CHILDREN
- See Also:
- Constant Field Values
-
BOTH
static final int BOTH
- See Also:
- Constant Field Values
-
-
Method Detail
-
getPath
Path getPath()
Gets the item path.The path is uniquely identifying the item in its tree and is consistent with the tree structure so the parent item will have the same path as the child minus the last segment. The root item path will always be "/". (The root item should not be displayed in the tree - it has no label or other properties.)
Paths are useful to locate items in the tree using
find
methods.- Returns:
- the item path
- See Also:
find(Path)
,findAndReveal(Path)
,TreeModel.find(Path)
,TreeModel.findAndReveal(Path)
-
getObject
Object getObject()
Gets the object attached to this item.The nature of the object depends on the registered content provider which will populate the tree branches when
ContentProvider.getChildren(Object)
is called. The root item is specified by usingTreeModel.setInput(Object)
- Returns:
- the attached object or null if none
-
getParent
TreeItem getParent()
Gets the parent item or null if this is the root item.- Returns:
- the parent item
-
getName
String getName()
Gets this node name.This is the same as the last segment on the item path
-
getLabel
String getLabel()
Gets the label to be displayed for this item.
-
isExpanded
boolean isExpanded()
Tests whether or not the item is expanded.- Returns:
- true of expanded, false otherwise
-
isContainer
boolean isContainer()
Tests whether or not the item may have children.- Returns:
- true if a container, false otherwise
-
getChildren
TreeItem[] getChildren()
Gets the cached children.The children items are created using the content provider the first time you call
expand()
-
getChild
TreeItem getChild(String name)
Gets the child item given its name.This method will force loading children using the provider if not already loaded or if invalidated.
- Parameters:
name
- the name of the child item- Returns:
- the child item or null if none
-
hasChildren
boolean hasChildren()
Tests whether this item has any children.This method will not load children if not already loaded.
- Returns:
- true if the children item has children, false otherwise
-
find
TreeItem find(Path path)
Finds the item given its relative path to that item.This method will search only the loaded items - it will not make additional calls to provider to get new items.
- Parameters:
path
- the item path to find- Returns:
- the item or null if none.
-
findAndReveal
TreeItem findAndReveal(Path path)
Finds the item given its relative path to that item and expand all its parents so that the item will be visible in the tree.The item itself will not be expanded. Use
expand()
on the returned item if you want so.This method is loading any parent if not already loaded by using the registered provider.
- Parameters:
path
- the item path to find- Returns:
- the item or null if none
-
expand
TreeItem[] expand()
Expands the item.This will load children items from the provider if they are not already loaded or if invalidated.
-
collapse
void collapse()
Collapses this item. This will hide any loaded children.
-
refresh
void refresh(int type)
Reloads item information like label, properties and children depending on the specified refresh type.The argument is used to specify the type of refresh and can have one of the following values:
- Parameters:
type
- of refresh
-
invalidate
void invalidate(int type)
Invalidates the item.This will force reloading item data and/or children next time item and/or children are accessed. The argument is used to specify the type of invalidation and can have one of the following values:
- Parameters:
type
- of invalidation
-
validate
void validate()
Validates the item.If the item was not invalidated do nothing.
-
getValidationState
int getValidationState()
Returns the validation state.Can be one of:
- Returns:
- the validation state.
-
getContentProvider
ContentProvider getContentProvider()
Gets the current content provider.- Returns:
- the content provider. never return null
-
accept
Object accept(TreeItemVisitor visitor)
Accepts a visitor. This is to support visitor pattern.- Parameters:
visitor
- the visitor to accept- Returns:
- the result of the visit
-
-