Class TreeItemImpl
- java.lang.Object
-
- org.nuxeo.ecm.webengine.ui.tree.TreeItemImpl
-
- All Implemented Interfaces:
Serializable,TreeItem
public class TreeItemImpl extends Object implements TreeItem
- Author:
- Bogdan Stefanescu
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected TreeItem[]childrenstatic TreeItem[]EMPTY_CHILDRENstatic intF_CONTAINERstatic intF_EXPANDEDprotected String[]facetsstatic TreeItem[]HAS_CHILDRENprotected Stringlabelprotected Objectobjprotected TreeItemparentprotected Pathpathprotected ContentProviderproviderprotected intstate
-
Constructor Summary
Constructors Constructor Description TreeItemImpl(ContentProvider provider, Object data)TreeItemImpl(TreeItem parent, Object data)TreeItemImpl(TreeItem parent, ContentProvider provider, Object data)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected TreeItem_getChild(String name)Objectaccept(TreeItemVisitor visitor)Accepts a visitor.voidcollapse()Collapses this item.booleanequals(Object obj)TreeItem[]expand()Expands the item.TreeItemfind(Path path)Finds the item given its relative path to that item.TreeItemfindAndReveal(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.TreeItemgetChild(String name)Gets the child item given its name.TreeItem[]getChildren()Gets the cached children.ContentProvidergetContentProvider()Gets the current content provider.String[]getFacets()StringgetLabel()Gets the label to be displayed for this item.StringgetName()Gets this node name.ObjectgetObject()Gets the object attached to this item.TreeItemgetParent()Gets the parent item or null if this is the root item.PathgetPath()Gets the item path.intgetValidationState()Returns the validation state.booleanhasChildren()Tests whether this item has any children.voidinvalidate(int type)Invalidates the item.booleanisContainer()Tests whether or not the item may have children.booleanisExpanded()Tests whether or not the item is expanded.protected voidloadChildren()protected voidloadData()voidrefresh(int type)Reloads item information like label, properties and children depending on the specified refresh type.StringtoString()voidvalidate()Validates the item.voidvalidateChildren()voidvalidateData()
-
-
-
Field Detail
-
F_CONTAINER
public static final int F_CONTAINER
- See Also:
- Constant Field Values
-
F_EXPANDED
public static final int F_EXPANDED
- See Also:
- Constant Field Values
-
EMPTY_CHILDREN
public static final TreeItem[] EMPTY_CHILDREN
-
HAS_CHILDREN
public static final TreeItem[] HAS_CHILDREN
-
provider
protected final ContentProvider provider
-
state
protected volatile int state
-
-
Constructor Detail
-
TreeItemImpl
public TreeItemImpl(TreeItem parent, ContentProvider provider, Object data)
-
TreeItemImpl
public TreeItemImpl(ContentProvider provider, Object data)
-
TreeItemImpl
public TreeItemImpl(TreeItem parent, Object data)
-
-
Method Detail
-
hasChildren
public boolean hasChildren()
Description copied from interface:TreeItemTests whether this item has any children.This method will not load children if not already loaded.
- Specified by:
hasChildrenin interfaceTreeItem- Returns:
- true if the children item has children, false otherwise
-
getChildren
public TreeItem[] getChildren()
Description copied from interface:TreeItemGets the cached children.The children items are created using the content provider the first time you call
TreeItem.expand()- Specified by:
getChildrenin interfaceTreeItem
-
getObject
public Object getObject()
Description copied from interface:TreeItemGets 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)
-
getPath
public Path getPath()
Description copied from interface:TreeItemGets 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
findmethods.- Specified by:
getPathin interfaceTreeItem- Returns:
- the item path
- See Also:
TreeItem.find(Path),TreeItem.findAndReveal(Path),TreeModel.find(Path),TreeModel.findAndReveal(Path)
-
getParent
public TreeItem getParent()
Description copied from interface:TreeItemGets the parent item or null if this is the root item.
-
getContentProvider
public ContentProvider getContentProvider()
Description copied from interface:TreeItemGets the current content provider.- Specified by:
getContentProviderin interfaceTreeItem- Returns:
- the content provider. never return null
-
getName
public String getName()
Description copied from interface:TreeItemGets this node name.This is the same as the last segment on the item path
-
getLabel
public String getLabel()
Description copied from interface:TreeItemGets the label to be displayed for this item.
-
isContainer
public boolean isContainer()
Description copied from interface:TreeItemTests whether or not the item may have children.- Specified by:
isContainerin interfaceTreeItem- Returns:
- true if a container, false otherwise
-
find
public TreeItem find(Path path)
Description copied from interface:TreeItemFinds 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.
-
findAndReveal
public TreeItem findAndReveal(Path path)
Description copied from interface:TreeItemFinds 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
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.
- Specified by:
findAndRevealin interfaceTreeItem- Parameters:
path- the item path to find- Returns:
- the item or null if none
-
getChild
public TreeItem getChild(String name)
Description copied from interface:TreeItemGets the child item given its name.This method will force loading children using the provider if not already loaded or if invalidated.
-
expand
public TreeItem[] expand()
Description copied from interface:TreeItemExpands the item.This will load children items from the provider if they are not already loaded or if invalidated.
-
loadData
protected void loadData()
-
validateData
public void validateData()
-
validateChildren
public void validateChildren()
-
loadChildren
protected void loadChildren()
-
collapse
public void collapse()
Description copied from interface:TreeItemCollapses this item. This will hide any loaded children.
-
isExpanded
public boolean isExpanded()
Description copied from interface:TreeItemTests whether or not the item is expanded.- Specified by:
isExpandedin interfaceTreeItem- Returns:
- true of expanded, false otherwise
-
refresh
public void refresh(int type)
Description copied from interface:TreeItemReloads 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:
TreeItem.DATA- to refresh only item data like labelsTreeItem.CHILDREN- to refresh only item childrenTreeItem.BOTH- to refresh both data and children
-
validate
public void validate()
Description copied from interface:TreeItemValidates the item.If the item was not invalidated do nothing.
-
invalidate
public void invalidate(int type)
Description copied from interface:TreeItemInvalidates 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:
TreeItem.DATA- to invalidate only item data like labelsTreeItem.CHILDREN- to invalidate only item childrenTreeItem.BOTH- to invalidate both data and children
- Specified by:
invalidatein interfaceTreeItem- Parameters:
type- of invalidation
-
getValidationState
public int getValidationState()
Description copied from interface:TreeItemReturns the validation state.Can be one of:
TreeItem.DATA- the item data is invalid (not loaded or invalidated)TreeItem.CHILDREN- the item children are invalidTreeItem.BOTH- both data and children are invalid
- Specified by:
getValidationStatein interfaceTreeItem- Returns:
- the validation state.
-
accept
public Object accept(TreeItemVisitor visitor)
Description copied from interface:TreeItemAccepts a visitor. This is to support visitor pattern.
-
-