public class TreeItemImpl extends Object implements TreeItem
Modifier and Type | Field and Description |
---|---|
protected TreeItem[] |
children |
static TreeItem[] |
EMPTY_CHILDREN |
static int |
F_CONTAINER |
static int |
F_EXPANDED |
protected String[] |
facets |
static TreeItem[] |
HAS_CHILDREN |
protected String |
label |
protected Object |
obj |
protected TreeItem |
parent |
protected Path |
path |
protected ContentProvider |
provider |
protected int |
state |
Constructor and Description |
---|
TreeItemImpl(ContentProvider provider,
Object data) |
TreeItemImpl(TreeItem parent,
ContentProvider provider,
Object data) |
TreeItemImpl(TreeItem parent,
Object data) |
Modifier and Type | Method and Description |
---|---|
protected TreeItem |
_getChild(String name) |
Object |
accept(TreeItemVisitor visitor)
Accepts a visitor.
|
void |
collapse()
Collapses this item.
|
boolean |
equals(Object obj) |
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[] |
getFacets() |
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.
|
protected void |
loadChildren() |
protected void |
loadData() |
void |
refresh(int type)
Reloads item information like label, properties and children depending on the specified refresh type.
|
String |
toString() |
void |
validate()
Validates the item.
|
void |
validateChildren() |
void |
validateData() |
public static final int F_CONTAINER
public static final int F_EXPANDED
public static final TreeItem[] EMPTY_CHILDREN
public static final TreeItem[] HAS_CHILDREN
protected final ContentProvider provider
protected volatile int state
public TreeItemImpl(TreeItem parent, ContentProvider provider, Object data)
public TreeItemImpl(ContentProvider provider, Object data)
public TreeItemImpl(TreeItem parent, Object data)
public boolean hasChildren()
TreeItem
This method will not load children if not already loaded.
hasChildren
in interface TreeItem
public TreeItem[] getChildren()
TreeItem
The children items are created using the content provider the first time you call TreeItem.expand()
getChildren
in interface TreeItem
public Object getObject()
TreeItem
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 using
TreeModel.setInput(Object)
public Path getPath()
TreeItem
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.
getPath
in interface TreeItem
TreeItem.find(Path)
,
TreeItem.findAndReveal(Path)
,
TreeModel.find(Path)
,
TreeModel.findAndReveal(Path)
public TreeItem getParent()
TreeItem
public ContentProvider getContentProvider()
TreeItem
getContentProvider
in interface TreeItem
public String getName()
TreeItem
This is the same as the last segment on the item path
public String getLabel()
TreeItem
public boolean isContainer()
TreeItem
isContainer
in interface TreeItem
public TreeItem find(Path path)
TreeItem
This method will search only the loaded items - it will not make additional calls to provider to get new items.
public TreeItem findAndReveal(Path path)
TreeItem
The item itself will not be expanded. Use TreeItem.expand()
on the returned item if you want so.
This method is loading any parent if not already loaded by using the registered provider.
findAndReveal
in interface TreeItem
path
- the item path to findpublic TreeItem getChild(String name)
TreeItem
This method will force loading children using the provider if not already loaded or if invalidated.
public TreeItem[] expand()
TreeItem
This will load children items from the provider if they are not already loaded or if invalidated.
protected void loadData()
public void validateData()
public void validateChildren()
protected void loadChildren()
public void collapse()
TreeItem
public boolean isExpanded()
TreeItem
isExpanded
in interface TreeItem
public void refresh(int type)
TreeItem
The argument is used to specify the type of refresh and can have one of the following values:
TreeItem.DATA
- to refresh only item data like labels
TreeItem.CHILDREN
- to refresh only item children
TreeItem.BOTH
- to refresh both data and children
public void validate()
TreeItem
If the item was not invalidated do nothing.
public void invalidate(int type)
TreeItem
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:
TreeItem.DATA
- to invalidate only item data like labels
TreeItem.CHILDREN
- to invalidate only item children
TreeItem.BOTH
- to invalidate both data and children
invalidate
in interface TreeItem
type
- of invalidationpublic int getValidationState()
TreeItem
Can be one of:
TreeItem.DATA
- the item data is invalid (not loaded or invalidated)
TreeItem.CHILDREN
- the item children are invalid
TreeItem.BOTH
- both data and children are invalid
getValidationState
in interface TreeItem
public Object accept(TreeItemVisitor visitor)
TreeItem
Copyright © 2018 Nuxeo. All rights reserved.