Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.webengine.ui.tree
Class TreeItemImpl

java.lang.Object
  extended by 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
static TreeItem[] EMPTY_CHILDREN
           
static int F_CONTAINER
           
static int F_EXPANDED
           
static TreeItem[] HAS_CHILDREN
           
 
Fields inherited from interface org.nuxeo.ecm.webengine.ui.tree.TreeItem
BOTH, CHILDREN, DATA, NONE
 
Constructor Summary
TreeItemImpl(ContentProvider provider, Object data)
           
TreeItemImpl(TreeItem parent, ContentProvider provider, Object data)
           
TreeItemImpl(TreeItem parent, Object data)
           
 
Method Summary
 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.
 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()
           
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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
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: TreeItem
Tests whether this item has any children.

This method will not load children if not already loaded.

Specified by:
hasChildren in interface TreeItem
Returns:
true if the children item has children, false otherwise

getChildren

public TreeItem[] getChildren()
Description copied from interface: TreeItem
Gets the cached children.

The children items are created using the content provider the first time you call TreeItem.expand()

Specified by:
getChildren in interface TreeItem

getObject

public Object getObject()
Description copied from interface: TreeItem
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 using TreeModel.setInput(Object)

Specified by:
getObject in interface TreeItem
Returns:
the attached object or null if none

getPath

public Path getPath()
Description copied from interface: TreeItem
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.

Specified by:
getPath in interface TreeItem
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: TreeItem
Gets the parent item or null if this is the root item.

Specified by:
getParent in interface TreeItem
Returns:
the parent item

getContentProvider

public ContentProvider getContentProvider()
Description copied from interface: TreeItem
Gets the current content provider.

Specified by:
getContentProvider in interface TreeItem
Returns:
the content provider. never return null

getName

public String getName()
Description copied from interface: TreeItem
Gets this node name.

This is the same as the last segment on the item path

Specified by:
getName in interface TreeItem

getLabel

public String getLabel()
Description copied from interface: TreeItem
Gets the label to be displayed for this item.

Specified by:
getLabel in interface TreeItem

getFacets

public String[] getFacets()

isContainer

public boolean isContainer()
Description copied from interface: TreeItem
Tests whether or not the item may have children.

Specified by:
isContainer in interface TreeItem
Returns:
true if a container, false otherwise

find

public TreeItem find(Path path)
Description copied from interface: TreeItem
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.

Specified by:
find in interface TreeItem
Parameters:
path - the item path to find
Returns:
the item or null if none.

findAndReveal

public TreeItem findAndReveal(Path path)
Description copied from interface: TreeItem
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 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:
findAndReveal in interface TreeItem
Parameters:
path - the item path to find
Returns:
the item or null if none

getChild

public TreeItem getChild(String name)
Description copied from interface: TreeItem
Gets the child item given its name.

This method will force loading children using the provider if not already loaded or if invalidated.

Specified by:
getChild in interface TreeItem
Parameters:
name - the name of the child item
Returns:
the child item or null if none

expand

public TreeItem[] expand()
Description copied from interface: TreeItem
Expands the item.

This will load children items from the provider if they are not already loaded or if invalidated.

Specified by:
expand in interface TreeItem

validateData

public void validateData()

validateChildren

public void validateChildren()

collapse

public void collapse()
Description copied from interface: TreeItem
Collapses this item. This will hide any loaded children.

Specified by:
collapse in interface TreeItem

isExpanded

public boolean isExpanded()
Description copied from interface: TreeItem
Tests whether or not the item is expanded.

Specified by:
isExpanded in interface TreeItem
Returns:
true of expanded, false otherwise

refresh

public void refresh(int type)
Description copied from interface: TreeItem
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:

Specified by:
refresh in interface TreeItem
Parameters:
type - of refresh

validate

public void validate()
Description copied from interface: TreeItem
Validates the item.

If the item was not invalidated do nothing.

Specified by:
validate in interface TreeItem

invalidate

public void invalidate(int type)
Description copied from interface: TreeItem
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:

Specified by:
invalidate in interface TreeItem
Parameters:
type - of invalidation

getValidationState

public int getValidationState()
Description copied from interface: TreeItem
Returns the validation state.

Can be one of:

Specified by:
getValidationState in interface TreeItem
Returns:
the validation state.

accept

public Object accept(TreeItemVisitor visitor)
Description copied from interface: TreeItem
Accepts a visitor. This is to support visitor pattern.

Specified by:
accept in interface TreeItem
Parameters:
visitor - the visitor to accept
Returns:
the result of the visit

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.