public class Tree extends RecordList implements HasDataChangedHandlers
A Tree has no visual presentation, it
is displayed by a TreeGrid
or ColumnTree
when supplied as TreeGrid.data
or ColumnTree.data
.
A Tree can be
constructed out of a List of objects interlinked by IDs or via explicitly specified Arrays of child objects. See modelType
for an explanation of how to pass data to a Tree.
Typical usage is to call TreeGrid.fetchData()
to cause
automatic creation of a ResultTree
, which is a type of Tree that automatically
handles loading data on demand. For information on DataBinding Trees, see TreeDataBinding
.
RecordList.SortNormalizer
jsObj
config, configOnly, factoryCreated, factoryProperties, id, scClassName
Constructor and Description |
---|
Tree() |
Tree(com.google.gwt.core.client.JavaScriptObject jsObj) |
Modifier and Type | Method and Description |
---|---|
TreeNode |
add(TreeNode node,
java.lang.String parentPath)
Add a single node under the specified parent
|
TreeNode |
add(TreeNode node,
java.lang.String parentPath,
int position) |
TreeNode |
add(TreeNode node,
TreeNode parent)
Add a single node under the specified parent
|
TreeNode |
add(TreeNode node,
TreeNode parent,
int position)
Add a single node under the specified parent
|
com.google.gwt.event.shared.HandlerRegistration |
addDataChangedHandler(DataChangedHandler handler)
Add a dataChanged handler.
|
TreeNode[] |
addList(TreeNode[] nodeList,
java.lang.String parentPath)
Add a list of nodes to some parent.
|
TreeNode[] |
addList(TreeNode[] nodeList,
java.lang.String parentPath,
int position)
Add a list of nodes to some parent.
|
TreeNode[] |
addList(TreeNode[] nodeList,
TreeNode parent)
Add a list of nodes to some parent.
|
TreeNode[] |
addList(TreeNode[] nodeList,
TreeNode parent,
int position)
Add a list of nodes to some parent.
|
java.lang.Boolean |
allChildrenLoaded(TreeNode node)
For a databound tree, do the children of this folder form a ResultSet with a full cache.
|
void |
closeAll()
Close all nodes under a particular node
|
void |
closeAll(NodeLocator node)
Close all nodes under a particular node
|
void |
closeAll(TreeNode node)
Close all nodes under a particular node
|
void |
closeFolder(java.lang.Integer node)
Closes a folder.
|
void |
closeFolder(NodeLocator node)
Closes a folder.
|
void |
closeFolder(java.lang.String node)
Closes a folder.
|
void |
closeFolder(TreeNode node)
Closes a folder.
|
void |
closeFolders(TreeNode[] nodeList)
Close a set of folders, specified by path or as pointers to nodes.
|
com.google.gwt.core.client.JavaScriptObject |
create() |
void |
createNodeLocator(TreeNode node,
TreeNode parent,
java.lang.Integer position,
java.lang.String path)
Returns a
NodeLocator object suitable for passing to methods, such as getParent() , which require a NodeLocator when the tree is
multi-linked . |
void |
createNodeLocator(TreeNode node,
TreeNode parent,
java.lang.Integer position,
java.lang.String path,
java.lang.Integer openListIndex)
Returns a
NodeLocator object suitable for passing to methods, such as getParent() , which require a NodeLocator when the tree is
multi-linked . |
static void |
discoverTree(TreeNode[] nodes,
DiscoverTreeSettings settings,
java.lang.String parentChildrenField)
given a hierarchy of objects with children under mixed names, heuristically discover the property that holds children
and copy it to a single, uniform childrenProperty.
|
TreeNode |
find(java.lang.String fieldNameOrPath)
Find a node within this tree using a string path or by attribute value(s).
|
TreeNode |
find(java.lang.String propertyName,
java.util.Date value)
Find a node within this tree using a string path or by attribute value(s).
|
TreeNode |
find(java.lang.String fieldNameOrPath,
java.lang.Object value)
Find a node within this tree using a string path or by attribute value(s).
|
TreeNode |
findById(java.lang.String id)
Find the node with the specified ID.
|
static java.lang.String |
findChildrenProperty(TreeNode node,
ChildrenPropertyMode mode)
heuristically find a property that appears to contain child objects.
|
int |
findIndex(AdvancedCriteria propertyName)
Like
List.findIndex() , but operates only on the list of currently opened
nodes. |
int |
findIndex(java.util.Map propertyName)
Like
List.findIndex() , but operates only on the list of currently opened
nodes. |
int |
findIndex(java.lang.String propertyName)
Like
List.findIndex() , but operates only on the list of currently opened
nodes. |
int |
findIndex(java.lang.String propertyName,
java.lang.Object value)
Like
List.findIndex() , but operates only on the list of currently opened
nodes. |
int |
findNextIndex(int startIndex,
java.lang.String propertyName)
|
int |
findNextIndex(int startIndex,
java.lang.String propertyName,
java.lang.Object value) |
int |
findNextIndex(int startIndex,
java.lang.String propertyName,
java.lang.Object value,
int endIndex)
|
int |
findNextNodeIndex(int startIndex,
java.lang.String propertyName)
Like
findNextIndex() , but includes both open and closed
nodes. |
int |
findNextNodeIndex(int startIndex,
java.lang.String propertyName,
java.lang.Object value) |
int |
findNextNodeIndex(int startIndex,
java.lang.String propertyName,
java.lang.Object value,
int endIndex)
Like
findNextIndex() , but includes both open and closed
nodes. |
int |
findNodeIndex(AdvancedCriteria propertyName)
Like
findIndex() , but searches all tree nodes regardless of
their open/closed state. |
int |
findNodeIndex(java.util.Map propertyName)
Like
findIndex() , but searches all tree nodes regardless of
their open/closed state. |
int |
findNodeIndex(java.lang.String propertyName)
Like
findIndex() , but searches all tree nodes regardless of
their open/closed state. |
int |
findNodeIndex(java.lang.String propertyName,
java.lang.Object value)
Like
findIndex() , but searches all tree nodes regardless of
their open/closed state. |
TreeNode[] |
getAllNodes()
Get all the nodes that exist in the tree under a particular node, as a flat list, in depth-first traversal order.
|
TreeNode[] |
getAllNodes(TreeNode node)
Get all the nodes that exist in the tree under a particular node, as a flat list, in depth-first traversal order.
|
java.lang.Boolean |
getAllowFilterOnLinkFields()
For a
multi-link tree , indicates whether client-side
filtering is allowed on the fields of the linkDataSource . |
java.lang.Boolean |
getAutoOpenRoot()
If true, the root node is automatically opened when the tree is created or
setRoot() is called. |
TreeNode[] |
getChildren(TreeNode node)
Returns all children of a node.
|
java.lang.String |
getChildrenProperty()
For trees with the modelType "children", this property specifies the name of the property that contains the list of
children for a node.
|
ResultSet |
getChildrenResultSet(TreeNode node)
Returns a ResultSet that provides access to any partially-loaded children of a node.
|
ListGridRecord[] |
getData() |
DataSource |
getDataSource()
Specifies what
DataSource this tree is associated with. |
java.lang.String |
getDataSourceAsString()
Specifies what
DataSource this tree is associated with. |
java.lang.Boolean |
getDefaultIsFolder()
Controls whether nodes are assumed to be folders or leaves by default.
|
java.lang.String |
getDefaultNodeTitle()
Title assigned to nodes without a
titleProperty value or
a nameProperty value. |
TreeNode[] |
getDescendantFolders()
Ruturns the list of all descendants of a node that are folders.
|
TreeNode[] |
getDescendantFolders(TreeNode node)
Ruturns the list of all descendants of a node that are folders.
|
TreeNode[] |
getDescendantLeaves()
Returns the list of all descendants of a node that are leaves.
|
TreeNode[] |
getDescendantLeaves(TreeNode node)
Returns the list of all descendants of a node that are leaves.
|
java.util.List |
getDescendantNodeLocators()
Returns a list of link{type:NodeLocator)s identifying all descendants of a node (identified by the parameter
NodeLocator ). |
java.util.List |
getDescendantNodeLocators(TreeNode node)
Returns a list of link{type:NodeLocator)s identifying all descendants of a node (identified by the parameter
NodeLocator ). |
TreeNode[] |
getDescendants()
Returns the list of all descendants of a node.
|
TreeNode[] |
getDescendants(TreeNode node)
Returns the list of all descendants of a node.
|
java.lang.Boolean |
getDiscardParentlessNodes()
If this tree has
modelType:"parent" , should nodes in the data
array for the tree be dropped if they have an explicitly specified value for the parentIdField which doesn't match any other nodes in the tree. |
Tree |
getFilteredTree(Criteria criteria)
Filters this tree by the provided criteria, returning a new Tree containing just the nodes that match the criteria.
|
Tree |
getFilteredTree(Criteria criteria,
TreeFilterMode filterMode,
DataSource dataSource)
Filters this tree by the provided criteria, returning a new Tree containing just the nodes that match the criteria.
|
TreeNode[] |
getFolders(TreeNode node)
Returns all the first-level folders of a node.
|
java.lang.String |
getIdField()
Name of the property on a
TreeNode that holds an id for the node which is
unique across the entire Tree. |
java.lang.String |
getIsFolderProperty()
Name of property that defines whether a node is a folder.
|
TreeNode[] |
getLeaves(TreeNode node)
Return all the first-level leaves of a node.
|
int |
getLength()
Returns the number of items in the current open list.
|
int |
getLevel(NodeLocator node)
Return the number of levels deep this node is in the tree.
|
int |
getLevel(TreeNode node)
Return the number of levels deep this node is in the tree.
|
Record[] |
getLinkData() |
java.lang.String |
getLinkPositionField()
The name of the "position" field in this
multi-link tree 's
link data. |
LoadState |
getLoadState(TreeNode node)
What is the loadState of a given folder?
|
TreeModelType |
getModelType()
Selects the model used to construct the tree representation.
|
TreeNode[] |
getMultiLinkParents(TreeNode node)
For
multiLink trees , returns the array of this node's
direct parents (the actual node objects, not the IDs). |
java.lang.String |
getName(NodeLocator node)
Get the 'name' of a node.
|
java.lang.String |
getName(TreeNode node)
Get the 'name' of a node.
|
java.lang.String |
getNameProperty()
Name of the property on a
TreeNode that holds a name for the node that is
unique among its immediate siblings, thus allowing a unique path to be used to identify the node, similar to a file
system. |
NodeLocator |
getNodeLocator(java.lang.Integer recordIndex)
For a
multi-link tree , this method returns the nodeLocator associated with the particular occurence of the node at the
specified index within the current open list of nodes in the
tree. |
TreeNode[] |
getOpenList(TreeNode node)
Return a flattened list of nodes that are open under some parent, including the parent itself.
|
java.lang.String |
getOpenProperty()
The property consulted by the default implementation of
isOpen() to
determine if the node is open or not. |
static Tree |
getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj) |
TreeNode |
getParent(TreeNode node)
Returns the parent of this node.
|
java.lang.String |
getParentIdField()
For trees with modelType "parent", this property specifies the name of the property that contains the unique parent ID
of a node.
|
java.lang.String |
getParentPath(TreeNode node)
Given a node, return the path to its parent.
|
TreeNode[] |
getParents(TreeNode node)
Given a node, return an array of the node's parents with the immediate parent first.
|
Record[] |
getParentsAndPositions(TreeNode node)
For
multiLink trees , returns the array of this node's
direct
parents and the node's position within each parent. |
java.lang.String |
getPath(TreeNode node)
Returns the path of a node - a path has the following format:
([name][pathDelim]?)*
For example, in this tree: |
java.lang.String |
getPathDelim()
Specifies the delimiter between node names.
|
java.lang.String |
getPathForOpenListIndex(java.lang.Integer recordIndex)
This method returns the path to the node at the specified index within the current open list of nodes in this tree.
|
java.lang.Boolean |
getReportCollisions()
If new nodes are added to a tree with modelType:"parent" which have the same
id field value as existing nodes, the existing nodes are removed when
the new nodes are added. |
TreeNode |
getRoot()
If you're using the "parent" modelType, you can provide the root node configuration via this
property.
|
java.lang.String |
getRootValue() |
java.lang.Boolean |
getSeparateFolders()
Should folders be sorted separately from leaves or should nodes be ordered according to their sort field value
regardless of whether the node is a leaf or folder?
|
java.lang.Boolean |
getShowRoot()
Controls whether the implicit root node is returned as part of the visible tree, specifically, whether it is returned in
getOpenList() , which is the API view components typically use
to get the list of visible nodes. |
java.lang.Boolean |
getSortFoldersBeforeLeaves()
If
separateFolders is true, should folders be displayed
above or below leaves? When set to true folders will appear above leaves when the
sortDirection applied to the tree is "ascending" |
java.lang.String |
getTitle(TreeNode node)
Return the title of a node -- the name as it should be presented to the user.
|
java.lang.String |
getTitleProperty()
Name of the property on a
TreeNode that holds the title of the node as it
should be shown to the user. |
java.lang.Boolean |
hasChildren(TreeNode node)
Returns true if this node has any children.
|
java.lang.Boolean |
hasFolders(TreeNode node)
Return true if this this node has any children that are folders.
|
java.lang.Boolean |
hasLeaves(TreeNode node)
Return whether this node has any children that are leaves.
|
java.lang.Boolean |
isDescendantOf(TreeNode child,
TreeNode parent)
Is one node a descendant of the other?
|
java.lang.Boolean |
isFolder(TreeNode node)
Determines whether a particular node is a folder.
|
java.lang.Boolean |
isLeaf(TreeNode node)
Returns true if the passed in node is a leaf.
|
java.lang.Boolean |
isLoaded(TreeNode node)
For a databound tree, has this folder either already loaded its children or is it in the process of loading them.
|
void |
isMultiLinkTree()
Returns true if this is a multi-link tree - ie, one that can contain the same node in more than one place.
|
java.lang.Boolean |
isOpen(java.lang.Integer node)
Whether a particular node is open or closed (works for leaves and folders).
|
java.lang.Boolean |
isOpen(NodeLocator node)
Whether a particular node is open or closed (works for leaves and folders).
|
java.lang.Boolean |
isOpen(java.lang.String node)
Whether a particular node is open or closed (works for leaves and folders).
|
java.lang.Boolean |
isOpen(TreeNode node)
Whether a particular node is open or closed (works for leaves and folders).
|
java.lang.Boolean |
isParent(TreeNode node,
TreeNode parent)
Returns true if "parent" is the parent of "node".
|
java.lang.Boolean |
isRoot(TreeNode node)
Return true if the passed node is the root node.
|
void |
linkDataChanged()
For
multi-link tree s only, called when links are added to
or removed form the tree. |
void |
linkNodes(TreeNode[] nodes)
This method is provided as a mechanism to link new nodes into the tree of modelType "parent".
|
void |
loadChildren(TreeNode node)
Load the children of a given node.
|
void |
loadChildren(TreeNode node,
DSCallback callback)
Load the children of a given node.
|
void |
move(TreeNode node,
TreeNode newParent)
Moves the specified node to a new parent.
|
void |
move(TreeNode node,
TreeNode newParent,
java.lang.Integer position)
Moves the specified node to a new parent.
|
static TreeNode |
nodeForRecord(ListGridRecord record)
A TreeNode and ListGridRecord represent similar datastructures and it is possible
that certain TreeGrid operations return a ListGridRecord since TreeGrid extends ListGrid.
|
void |
openAll()
Open all nodes under a particular node.
|
void |
openAll(java.lang.Integer node)
Open all nodes under a particular node.
|
void |
openAll(NodeLocator node)
Open all nodes under a particular node.
|
void |
openAll(java.lang.String node)
Open all nodes under a particular node.
|
void |
openAll(TreeNode node)
Open all nodes under a particular node.
|
void |
openFolder(TreeNode node)
Open a particular node
|
void |
openFolders(TreeNode[] nodeList)
Open a set of folders, specified by path or as pointers to nodes.
|
void |
reloadChildren(TreeNode node)
Reload the children of a folder.
|
java.lang.Boolean |
remove(java.lang.Integer node)
Removes a node, along with all its children.
|
java.lang.Boolean |
remove(NodeLocator node)
Removes a node, along with all its children.
|
java.lang.Boolean |
remove(java.lang.String node)
Removes a node, along with all its children.
|
java.lang.Boolean |
remove(TreeNode node)
Removes a node, along with all its children.
|
void |
removeChildren(TreeNode node)
Removes all children of the node and sets it to a loaded state.
|
java.lang.Boolean |
removeList(TreeNode[] nodeList)
Remove a list of nodes (not necessarily from the same parent), and all children of those nodes.
|
Tree |
setAllowFilterOnLinkFields(java.lang.Boolean allowFilterOnLinkFields)
For a
multi-link tree , indicates whether client-side
filtering is allowed on the fields of the linkDataSource . |
Tree |
setAutoOpenRoot(java.lang.Boolean autoOpenRoot)
If true, the root node is automatically opened when the tree is created or
setRoot() is called. |
void |
setChildren(TreeNode parent,
java.util.List newChildren)
Replaces the existing children of a parent node, leaving the node in the loaded state.
|
Tree |
setChildrenProperty(java.lang.String childrenProperty)
For trees with the modelType "children", this property specifies the name of the property that contains the list of
children for a node.
|
Tree |
setData(TreeNode[] nodes)
Optional initial data for the tree.
|
Tree |
setDataSource(DataSource dataSource)
Specifies what
DataSource this tree is associated with. |
Tree |
setDataSource(java.lang.String dataSource)
Specifies what
DataSource this tree is associated with. |
Tree |
setDefaultIsFolder(java.lang.Boolean defaultIsFolder)
Controls whether nodes are assumed to be folders or leaves by default.
|
Tree |
setDefaultNodeTitle(java.lang.String defaultNodeTitle)
Title assigned to nodes without a
titleProperty value or
a nameProperty value. |
static void |
setDefaultProperties(Tree treeProperties)
Class level method to set the default properties of this class.
|
Tree |
setDiscardParentlessNodes(java.lang.Boolean discardParentlessNodes)
If this tree has
modelType:"parent" , should nodes in the data
array for the tree be dropped if they have an explicitly specified value for the parentIdField which doesn't match any other nodes in the tree. |
Tree |
setIdField(java.lang.String idField)
Name of the property on a
TreeNode that holds an id for the node which is
unique across the entire Tree. |
Tree |
setIsFolderProperty(java.lang.String isFolderProperty)
Name of property that defines whether a node is a folder.
|
void |
setJavaScriptObject(com.google.gwt.core.client.JavaScriptObject jsObj) |
void |
setLinkData(Record[] linkData)
For a
multi-link tree , this property specifies the parent-child
relationships between the nodes. |
Tree |
setLinkPositionField(java.lang.String linkPositionField)
The name of the "position" field in this
multi-link tree 's
link data. |
Tree |
setModelType(TreeModelType modelType)
Selects the model used to construct the tree representation.
|
void |
setMultiLinkTree(java.lang.Boolean multiLinkTree)
Set to true to indicate that this is a multi-link tree - ie, one that can contain the same node in more than one place.
|
Tree |
setNameProperty(java.lang.String nameProperty)
Name of the property on a
TreeNode that holds a name for the node that is
unique among its immediate siblings, thus allowing a unique path to be used to identify the node, similar to a file
system. |
Tree |
setOpenProperty(java.lang.String openProperty)
The property consulted by the default implementation of
isOpen() to
determine if the node is open or not. |
Tree |
setParentIdField(java.lang.String parentIdField)
For trees with modelType "parent", this property specifies the name of the property that contains the unique parent ID
of a node.
|
Tree |
setPathDelim(java.lang.String pathDelim)
Specifies the delimiter between node names.
|
Tree |
setReportCollisions(java.lang.Boolean reportCollisions)
If new nodes are added to a tree with modelType:"parent" which have the same
id field value as existing nodes, the existing nodes are removed when
the new nodes are added. |
Tree |
setRoot(TreeNode root)
If you're using the "parent" modelType, you can provide the root node configuration via this
property.
|
void |
setRootValue(int rootValue)
|
void |
setRootValue(java.lang.String rootValue)
|
Tree |
setSeparateFolders(java.lang.Boolean separateFolders)
Should folders be sorted separately from leaves or should nodes be ordered according to their sort field value
regardless of whether the node is a leaf or folder?
If this method is called after the component has been drawn/initialized: Setter for separateFolders . |
Tree |
setShowRoot(java.lang.Boolean showRoot)
Controls whether the implicit root node is returned as part of the visible tree, specifically, whether it is returned in
getOpenList() , which is the API view components typically use
to get the list of visible nodes. |
Tree |
setSortFoldersBeforeLeaves(java.lang.Boolean sortFoldersBeforeLeaves)
If
separateFolders is true, should folders be displayed
above or below leaves? When set to true folders will appear above leaves when the
sortDirection applied to the tree is "ascending"
If this method is called after the component has been drawn/initialized: Setter for sortFoldersBeforeLeaves . |
Tree |
setTitleProperty(java.lang.String titleProperty)
Name of the property on a
TreeNode that holds the title of the node as it
should be shown to the user. |
void |
unloadChildren(TreeNode node)
Deprecated.
It's recommended that you instead use
reloadChildren() to
reload the children of a folder, or removeChildren() if you
need to clear the cached children of a folder to add specific local data. |
add, addAt, addDataChangedHandler, addList, addList, addListAt, contains, contains, containsAll, duplicate, equals, find, find, find, findAll, findAll, findAll, findAll, findAll, findAll, findAll, findAll, findIndex, findIndex, findIndex, findIndex, findIndex, findIndex, findNextIndex, findNextIndex, findNextIndex, findNextIndex, findNextIndex, findNextIndex, findNextIndex, findNextIndex, findNextIndex, first, get, getItems, getJsObj, getOrCreateJsObj, getProperty, getRange, getRangeList, getValueMap, indexOf, indexOf, intersect, isARecordList, isCreated, isEmpty, last, lastIndexOf, lastIndexOf, remove, removeAt, removeList, set, setLength, setSort, sort, sort, sortByProperty, sortByProperty, toArray
addDynamicProperty, addDynamicProperty, addDynamicProperty, applyFactoryProperties, asSGWTComponent, clearDynamicProperty, createJsObj, destroy, doAddHandler, doInit, error, error, errorIfNotCreated, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsElement, getAttributeAsFloat, getAttributeAsInt, getAttributeAsJavaScriptObject, getAttributeAsMap, getAttributeAsString, getAttributeAsStringArray, getClassName, getConfig, getHandlerCount, getID, getRef, getRuleScope, getScClassName, getTestInstance, hasAutoAssignedID, hasDynamicProperty, internalSetID, internalSetID, isConfigOnly, isFactoryCreated, onBind, onInit, registerID, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setConfig, setConfigOnly, setFactoryCreated, setID, setProperty, setProperty, setProperty, setProperty, setRuleScope, setScClassName
public Tree()
public Tree(com.google.gwt.core.client.JavaScriptObject jsObj)
public static Tree getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)
public void setJavaScriptObject(com.google.gwt.core.client.JavaScriptObject jsObj)
setJavaScriptObject
in class BaseClass
public com.google.gwt.core.client.JavaScriptObject create()
create
in class RecordList
public Tree setAllowFilterOnLinkFields(java.lang.Boolean allowFilterOnLinkFields) throws java.lang.IllegalStateException
multi-link tree
, indicates whether client-side
filtering is allowed on the fields of the linkDataSource
. When this property is true, filtering operations involving link fields work as expected (ie, as if
those fields were present on the main dataSource
);
when this value is not true, criterions involving link fields are simply ignored. Note, setting this property true causes filtering operations to perform an additional record duplication per node in the dataset to be filtered. This adds some overhead, so you should consider likely data volumes before enabling it (though in fact, client-side filtering of trees is relatively expensive anyway, so acceptable use cases probably already involve quite low data volumes)
This property has no effect for regular, non-multiLink trees.
allowFilterOnLinkFields
- New allowFilterOnLinkFields value. Default value is nullTree
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdpublic java.lang.Boolean getAllowFilterOnLinkFields()
multi-link tree
, indicates whether client-side
filtering is allowed on the fields of the linkDataSource
. When this property is true, filtering operations involving link fields work as expected (ie, as if
those fields were present on the main dataSource
);
when this value is not true, criterions involving link fields are simply ignored. Note, setting this property true causes filtering operations to perform an additional record duplication per node in the dataset to be filtered. This adds some overhead, so you should consider likely data volumes before enabling it (though in fact, client-side filtering of trees is relatively expensive anyway, so acceptable use cases probably already involve quite low data volumes)
This property has no effect for regular, non-multiLink trees.
public Tree setAutoOpenRoot(java.lang.Boolean autoOpenRoot)
setRoot()
is called.autoOpenRoot
- New autoOpenRoot value. Default value is trueTree
instance, for chaining setter callspublic java.lang.Boolean getAutoOpenRoot()
setRoot()
is called.public Tree setChildrenProperty(java.lang.String childrenProperty)
childrenProperty
- New childrenProperty value. Default value is "children"Tree
instance, for chaining setter callssetModelType(com.smartgwt.client.types.TreeModelType)
,
Children Arrays Examplepublic java.lang.String getChildrenProperty()
getModelType()
,
Children Arrays Examplepublic Tree setDataSource(DataSource dataSource) throws java.lang.IllegalStateException
DataSource
this tree is associated with. A DataSource
is required when filtering a tree, even if it isn't a ResultTree
, though it may be passed to getFilteredTree()
rather than set on the tree itself. If a
DataSource
is specified it will also affect sorting, where relevant, such as if the
tree is set as TreeGrid.data
.
dataSource
- New dataSource value. Default value is nullTree
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdpublic DataSource getDataSource()
DataSource
this tree is associated with. A DataSource
is required when filtering a tree, even if it isn't a ResultTree
, though it may be passed to getFilteredTree()
rather than set on the tree itself. If a
DataSource
is specified it will also affect sorting, where relevant, such as if the
tree is set as TreeGrid.data
.
public Tree setDataSource(java.lang.String dataSource) throws java.lang.IllegalStateException
DataSource
this tree is associated with. A DataSource
is required when filtering a tree, even if it isn't a ResultTree
, though it may be passed to getFilteredTree()
rather than set on the tree itself. If a
DataSource
is specified it will also affect sorting, where relevant, such as if the
tree is set as TreeGrid.data
.
dataSource
- New dataSource value. Default value is nullTree
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdpublic java.lang.String getDataSourceAsString()
DataSource
this tree is associated with. A DataSource
is required when filtering a tree, even if it isn't a ResultTree
, though it may be passed to getFilteredTree()
rather than set on the tree itself. If a
DataSource
is specified it will also affect sorting, where relevant, such as if the
tree is set as TreeGrid.data
.
public Tree setDefaultIsFolder(java.lang.Boolean defaultIsFolder) throws java.lang.IllegalStateException
Nodes that have children or have the isFolderProperty
set to true will be considered folders by
default. Other nodes will be considered folders or leaves by default according to this setting.
See also ResultTree.defaultIsFolder
for more details on how
defaultIsFolder
interacts with loading data on demand
.
defaultIsFolder
- New defaultIsFolder value. Default value is nullTree
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdpublic java.lang.Boolean getDefaultIsFolder()
Nodes that have children or have the isFolderProperty
set to true will be considered folders by
default. Other nodes will be considered folders or leaves by default according to this setting.
See also ResultTree.defaultIsFolder
for more details on how
defaultIsFolder
interacts with loading data on demand
.
public Tree setDefaultNodeTitle(java.lang.String defaultNodeTitle)
titleProperty
value or
a nameProperty
value.defaultNodeTitle
- New defaultNodeTitle value. Default value is "Untitled"Tree
instance, for chaining setter callspublic java.lang.String getDefaultNodeTitle()
titleProperty
value or
a nameProperty
value.public Tree setDiscardParentlessNodes(java.lang.Boolean discardParentlessNodes) throws java.lang.IllegalStateException
modelType:"parent"
, should nodes in the data
array for the tree be dropped if they have an explicitly specified value for the parentIdField
which doesn't match any other nodes in the tree.
If set to false these nodes will be added as children of the root node.
Note : This is an advanced setting
discardParentlessNodes
- New discardParentlessNodes value. Default value is falseTree
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdpublic java.lang.Boolean getDiscardParentlessNodes()
modelType:"parent"
, should nodes in the data
array for the tree be dropped if they have an explicitly specified value for the parentIdField
which doesn't match any other nodes in the tree.
If set to false these nodes will be added as children of the root node.public Tree setIdField(java.lang.String idField) throws java.lang.IllegalStateException
TreeNode
that holds an id for the node which is
unique across the entire Tree. Required for all nodes for trees with modelType "parent". Default value is "id". See
TreeNode.id
for usage.
Note : This is an advanced setting
idField
- New idField value. Default value is "id"Tree
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdcom.smartgwt.client.widgets.tree.TreeNode#setId
,
Node Titles Examplepublic java.lang.String getIdField()
TreeNode
that holds an id for the node which is
unique across the entire Tree. Required for all nodes for trees with modelType "parent". Default value is "id". See
TreeNode.id
for usage.com.smartgwt.client.widgets.tree.TreeNode#getId
,
Node Titles Examplepublic Tree setIsFolderProperty(java.lang.String isFolderProperty)
TreeNode.isFolder
.isFolderProperty
- New isFolderProperty value. Default value is "isFolder"Tree
instance, for chaining setter callsTreeNode.setIsFolder(boolean)
public java.lang.String getIsFolderProperty()
TreeNode.isFolder
.com.smartgwt.client.widgets.tree.TreeNode#getIsFolder
public Tree setLinkPositionField(java.lang.String linkPositionField) throws java.lang.IllegalStateException
multi-link tree
's
link data. Ignored if this tree is not a multi-link treelinkPositionField
- New linkPositionField value. Default value is "position"Tree
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdpublic java.lang.String getLinkPositionField()
multi-link tree
's
link data. Ignored if this tree is not a multi-link treepublic Tree setModelType(TreeModelType modelType)
TreeModelType
for
the available options and their implications. If the "parent" modelType is used, you can provide the initial
parent-linked data set to the tree via the data
attribute. If the
"children" modelType is used, you can provide the initial tree structure to the Tree via the root
attribute.
Note : This is an advanced setting
modelType
- New modelType value. Default value is "children"Tree
instance, for chaining setter callssetData(com.smartgwt.client.widgets.tree.TreeNode[])
,
setRoot(com.smartgwt.client.widgets.tree.TreeNode)
,
Node Titles Examplepublic TreeModelType getModelType()
TreeModelType
for
the available options and their implications. If the "parent" modelType is used, you can provide the initial
parent-linked data set to the tree via the data
attribute. If the
"children" modelType is used, you can provide the initial tree structure to the Tree via the root
attribute.
getData()
,
getRoot()
,
Node Titles Examplepublic Tree setNameProperty(java.lang.String nameProperty)
TreeNode
that holds a name for the node that is
unique among its immediate siblings, thus allowing a unique path to be used to identify the node, similar to a file
system. Default value is "name". See TreeNode.name
for
usage.nameProperty
- New nameProperty value. Default value is "name"Tree
instance, for chaining setter callsTreeNode.setName(java.lang.String)
,
Node Titles Examplepublic java.lang.String getNameProperty()
TreeNode
that holds a name for the node that is
unique among its immediate siblings, thus allowing a unique path to be used to identify the node, similar to a file
system. Default value is "name". See TreeNode.name
for
usage.TreeNode.getName()
,
Node Titles Examplepublic Tree setOpenProperty(java.lang.String openProperty)
isOpen()
to
determine if the node is open or not. By default, this property is auto-generated for you, but you can set it to a
custom value if you want to declaratively specify this state, but be careful - if you display this Tree in multiple
TreeGrids at the same time, the open state will not be tracked independently - see SharingNodes
for more info on this. For multi-link tree
s, we do not track open state on the nodes
themselves, because this would mean that multiple instances of a node in the tree would open and close in lockstep.
Instead, open state is tracked in an internal index structure, and the openProperty
is not used at all.
Note : This is an advanced setting
openProperty
- New openProperty value. Default value is nullTree
instance, for chaining setter callspublic java.lang.String getOpenProperty()
isOpen()
to
determine if the node is open or not. By default, this property is auto-generated for you, but you can set it to a
custom value if you want to declaratively specify this state, but be careful - if you display this Tree in multiple
TreeGrids at the same time, the open state will not be tracked independently - see SharingNodes
for more info on this. For multi-link tree
s, we do not track open state on the nodes
themselves, because this would mean that multiple instances of a node in the tree would open and close in lockstep.
Instead, open state is tracked in an internal index structure, and the openProperty
is not used at all.
public Tree setParentIdField(java.lang.String parentIdField) throws java.lang.IllegalStateException
TreeNode.parentId
for usage.
Note : This is an advanced setting
parentIdField
- New parentIdField value. Default value is "parentId"Tree
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdcom.smartgwt.client.widgets.tree.TreeNode#setParentId
,
Node Titles Examplepublic java.lang.String getParentIdField()
TreeNode.parentId
for usage.com.smartgwt.client.widgets.tree.TreeNode#getParentId
,
Node Titles Examplepublic Tree setPathDelim(java.lang.String pathDelim)
getPath()
and can be used to find any node in the tree by calling
find()
. Note that you can also hand-construct a path - in other
words
you are not required to call getPath()
in order to later use
find()
to retrieve it.
nameProperty
that's used
for naming the nodes. So for example, if you have the following tree:
one two three/fourThen you will be unable to find the
three/four
node using
find()
if your tree is using the default pathDelim of /.
In such a case, you can use a different pathDelim for the tree. For example if you used |
for the path delim, then you can find the three/four
node in the tree above by
calling tree.find("one|two|three/four")
.
getPath()
and find()
and
does not affect any aspect of the tree structure or other forms of tree navigation (such as
via getChildren()
).
Note : This is an advanced setting
pathDelim
- New pathDelim value. Default value is "/"Tree
instance, for chaining setter callssetNameProperty(java.lang.String)
,
find(java.lang.String)
public java.lang.String getPathDelim()
getPath()
and can be used to find any node in the tree by calling
find()
. Note that you can also hand-construct a path - in other
words
you are not required to call getPath()
in order to later use
find()
to retrieve it.
nameProperty
that's used
for naming the nodes. So for example, if you have the following tree:
one two three/fourThen you will be unable to find the
three/four
node using
find()
if your tree is using the default pathDelim of /.
In such a case, you can use a different pathDelim for the tree. For example if you used |
for the path delim, then you can find the three/four
node in the tree above by
calling tree.find("one|two|three/four")
.
getPath()
and find()
and
does not affect any aspect of the tree structure or other forms of tree navigation (such as
via getChildren()
).getNameProperty()
,
find(java.lang.String)
public Tree setReportCollisions(java.lang.Boolean reportCollisions) throws java.lang.IllegalStateException
id field value
as existing nodes, the existing nodes are removed when
the new nodes are added. If reportCollisions is true, the Tree will log a warning in the developer console about this.
Note that if an id collision occurs between a new node and its ancestor, the ancestor will be removed and the new node will not be added to the tree.
reportCollisions
- New reportCollisions value. Default value is trueTree
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdpublic java.lang.Boolean getReportCollisions()
id field value
as existing nodes, the existing nodes are removed when
the new nodes are added. If reportCollisions is true, the Tree will log a warning in the developer console about this.
Note that if an id collision occurs between a new node and its ancestor, the ancestor will be removed and the new node will not be added to the tree.
public Tree setRoot(TreeNode root)
If you're using the "children" modelType, you can provide the initial tree data via this property. So, for example, to construct the following tree:
foo bar zooYou would initialize the tree as follows:
Tree tree = new Tree(); tree.setRoot( new TreeNode("root", new TreeNode("foo", new TreeNode("bar")), new TreeNode("zoo") ) );
root
value, a root node will be
auto-created for you. You can then call add()
to construct the tree.
duplicate()
.root
- new root node. Default value is nullTree
instance, for chaining setter callssetModelType(com.smartgwt.client.types.TreeModelType)
,
setRoot(com.smartgwt.client.widgets.tree.TreeNode)
,
Children Arrays Examplepublic TreeNode getRoot()
If you're using the "children" modelType, you can provide the initial tree data via this property. So, for example, to construct the following tree:
foo bar zooYou would initialize the tree as follows:
Tree tree = new Tree(); tree.setRoot( new TreeNode("root", new TreeNode("foo", new TreeNode("bar")), new TreeNode("zoo") ) );
root
value, a root node will be
auto-created for you. You can then call add()
to construct the tree.getModelType()
,
setRoot(com.smartgwt.client.widgets.tree.TreeNode)
,
Children Arrays Examplepublic Tree setSeparateFolders(java.lang.Boolean separateFolders)
separateFolders
.separateFolders
- new separateFolders
value. Default value is falseTree
instance, for chaining setter callssetSortFoldersBeforeLeaves(java.lang.Boolean)
public java.lang.Boolean getSeparateFolders()
getSortFoldersBeforeLeaves()
public Tree setShowRoot(java.lang.Boolean showRoot)
getOpenList()
, which is the API view components typically use
to get the list of visible nodes. Default is to have the root node be implicit and not included in the open list, which means that the visible tree begins with the children of root. This allows multiple nodes to appear at the top level of the tree.
You can set showRoot:true
to show the single, logical root node as the only
top-level node. This property is only meaningful for Trees where you supplied a value for root
, otherwise, you will see an automatically generated root node that
is meaningless to the user.
If this method is called after the component has been drawn/initialized:
Setter for showRoot
.
showRoot
- new showRoot
value. Default value is falseTree
instance, for chaining setter callspublic java.lang.Boolean getShowRoot()
getOpenList()
, which is the API view components typically use
to get the list of visible nodes. Default is to have the root node be implicit and not included in the open list, which means that the visible tree begins with the children of root. This allows multiple nodes to appear at the top level of the tree.
You can set showRoot:true
to show the single, logical root node as the only
top-level node. This property is only meaningful for Trees where you supplied a value for root
, otherwise, you will see an automatically generated root node that
is meaningless to the user.
public Tree setSortFoldersBeforeLeaves(java.lang.Boolean sortFoldersBeforeLeaves)
separateFolders
is true, should folders be displayed
above or below leaves? When set to true
folders will appear above leaves when the
sortDirection
applied to the tree is "ascending"
sortFoldersBeforeLeaves
.sortFoldersBeforeLeaves
- new sortFoldersBeforeLeaves
value. Default value is trueTree
instance, for chaining setter callspublic java.lang.Boolean getSortFoldersBeforeLeaves()
separateFolders
is true, should folders be displayed
above or below leaves? When set to true
folders will appear above leaves when the
sortDirection
applied to the tree is "ascending"
public Tree setTitleProperty(java.lang.String titleProperty)
TreeNode
that holds the title of the node as it
should be shown to the user. Default value is "title". See TreeNode.title
for usage.titleProperty
- New titleProperty value. Default value is "title"Tree
instance, for chaining setter callspublic java.lang.String getTitleProperty()
TreeNode
that holds the title of the node as it
should be shown to the user. Default value is "title". See TreeNode.title
for usage.public java.lang.Boolean allChildrenLoaded(TreeNode node)
Note that this method only
applies to ResultTree.fetchMode
"paged".
node
- folder in questiongetChildrenResultSet(com.smartgwt.client.widgets.tree.TreeNode)
public void closeAll()
public void closeAll(TreeNode node)
node
- node from which to close folders (if not specified, the root node is used).
If this is a multi-link tree
, you must provide a NodeLocator
for any node other than the root
nodepublic void closeAll(NodeLocator node)
node
- node from which to close folders (if not specified, the root node is used).
If this is a multi-link tree
, you must provide a NodeLocator
for any node other than the root
nodepublic void closeFolder(TreeNode node)
multi-link tree
s, passing a
NodeLocator
is the only unambiguous way to specify the node.node
- the node to open, or its ID, or a NodeLocator objectpublic void closeFolder(java.lang.String node)
multi-link tree
s, passing a
NodeLocator
is the only unambiguous way to specify the node.node
- the node to open, or its ID, or a NodeLocator objectpublic void closeFolder(java.lang.Integer node)
multi-link tree
s, passing a
NodeLocator
is the only unambiguous way to specify the node.node
- the node to open, or its ID, or a NodeLocator objectpublic void closeFolder(NodeLocator node)
multi-link tree
s, passing a
NodeLocator
is the only unambiguous way to specify the node.node
- the node to open, or its ID, or a NodeLocator objectpublic void createNodeLocator(TreeNode node, TreeNode parent, java.lang.Integer position, java.lang.String path)
NodeLocator
object suitable for passing to methods, such as getParent()
, which require a NodeLocator
when the tree is
multi-linked
. Note, NodeLocator
s are
specific to multiLink trees; they are never required for regular trees.node
- the child nodeparent
- the parent nodeposition
- the child node's position within the parentpath
- the full path to the child nodepublic void createNodeLocator(TreeNode node, TreeNode parent, java.lang.Integer position, java.lang.String path, java.lang.Integer openListIndex)
NodeLocator
object suitable for passing to methods, such as getParent()
, which require a NodeLocator
when the tree is
multi-linked
. Note, NodeLocator
s are
specific to multiLink trees; they are never required for regular trees.node
- the child nodeparent
- the parent nodeposition
- the child node's position within the parentpath
- the full path to the child nodeopenListIndex
- the index of the node occurence in the tree's current openList. This is the same as the
record index of the node in an associated TreeGrid
public com.google.gwt.event.shared.HandlerRegistration addDataChangedHandler(DataChangedHandler handler)
Called when the structure of this tree is changed in any way.
Note that on a big change (many items being added
or deleted) this may be called multiple times
handler
- the dataChanged handlerHandlerRegistration
used to remove this handlerpublic int findIndex(java.lang.String propertyName)
List.findIndex()
, but operates only on the list of currently opened
nodes. To search all loaded nodes open or closed, use findNodeIndex()
.propertyName
- property to match, or if an Object is passed, set of properties and values to
matchpublic int findIndex(java.util.Map propertyName)
List.findIndex()
, but operates only on the list of currently opened
nodes. To search all loaded nodes open or closed, use findNodeIndex()
.findIndex
in class RecordList
propertyName
- property to match, or if an Object is passed, set of properties and values to
matchpublic int findIndex(AdvancedCriteria propertyName)
List.findIndex()
, but operates only on the list of currently opened
nodes. To search all loaded nodes open or closed, use findNodeIndex()
.findIndex
in class RecordList
propertyName
- property to match, or if an Object is passed, set of properties and values to
matchpublic int findIndex(java.lang.String propertyName, java.lang.Object value)
List.findIndex()
, but operates only on the list of currently opened
nodes. To search all loaded nodes open or closed, use findNodeIndex()
.propertyName
- property to match, or if an Object is passed, set of properties and values to
matchvalue
- value to compare against (if propertyName is a string)public int findNextIndex(int startIndex, java.lang.String propertyName)
findIndex()
, but inspects a range from
startIndex
to endIndex
. Note that as in findIndex()
, only open nodes are included. To include both open and
closed nodes, use findNextNodeIndex()
.findNextIndex
in class RecordList
startIndex
- first index to consider.propertyName
- property to match; or, if an object is passed, set of properties and values to match.public int findNextIndex(int startIndex, java.lang.String propertyName, java.lang.Object value)
findNextIndex(int, java.lang.String)
public int findNextIndex(int startIndex, java.lang.String propertyName, java.lang.Object value, int endIndex)
findIndex()
, but inspects a range from
startIndex
to endIndex
. Note that as in findIndex()
, only open nodes are included. To include both open and
closed nodes, use findNextNodeIndex()
.startIndex
- first index to consider.propertyName
- property to match; or, if an object is passed, set of properties and values to match.value
- value to compare against (if propertyName
is a string)endIndex
- last index to consider (inclusive).public int findNextNodeIndex(int startIndex, java.lang.String propertyName)
findNextIndex()
, but includes both open and closed
nodes.startIndex
- first index to consider.propertyName
- property to match; or, if an object is passed, set of properties and values to match.public int findNextNodeIndex(int startIndex, java.lang.String propertyName, java.lang.Object value)
findNextNodeIndex(int, java.lang.String)
public int findNextNodeIndex(int startIndex, java.lang.String propertyName, java.lang.Object value, int endIndex)
findNextIndex()
, but includes both open and closed
nodes.startIndex
- first index to consider.propertyName
- property to match; or, if an object is passed, set of properties and values to match.value
- value to compare against (if propertyName
is a string)endIndex
- last index to consider (inclusive).public int findNodeIndex(java.lang.String propertyName)
findIndex()
, but searches all tree nodes regardless of
their open/closed state.propertyName
- property to match, or if an Object is passed, set of properties and values to
matchpublic int findNodeIndex(java.util.Map propertyName)
findIndex()
, but searches all tree nodes regardless of
their open/closed state.propertyName
- property to match, or if an Object is passed, set of properties and values to
matchpublic int findNodeIndex(AdvancedCriteria propertyName)
findIndex()
, but searches all tree nodes regardless of
their open/closed state.propertyName
- property to match, or if an Object is passed, set of properties and values to
matchpublic int findNodeIndex(java.lang.String propertyName, java.lang.Object value)
findIndex()
, but searches all tree nodes regardless of
their open/closed state.propertyName
- property to match, or if an Object is passed, set of properties and values to
matchvalue
- value to compare against (if propertyName is a string)public ResultSet getChildrenResultSet(TreeNode node)
node
- The node whose children you want to fetch.getChildren(com.smartgwt.client.widgets.tree.TreeNode)
,
allChildrenLoaded(com.smartgwt.client.widgets.tree.TreeNode)
public java.util.List getDescendantNodeLocators()
NodeLocator
). This method is the equivalent of getDescendants()
, but for multi-link trees
. The list of
descendant nodes returned from both methods is identical - a node's descendants are the same regardless of where or how
many times that node appears in the tree - but the NodeLocator
s returned by this method provide additional
context that allows you to determine particular occurences of descendant nodes. This is necessary for some use cases -
for example, when trying to determine if a particular node occurence is open, or selected.public java.util.List getDescendantNodeLocators(TreeNode node)
NodeLocator
). This method is the equivalent of getDescendants()
, but for multi-link trees
. The list of
descendant nodes returned from both methods is identical - a node's descendants are the same regardless of where or how
many times that node appears in the tree - but the NodeLocator
s returned by this method provide additional
context that allows you to determine particular occurences of descendant nodes. This is necessary for some use cases -
for example, when trying to determine if a particular node occurence is open, or selected.node
- node in question (the root node is assumed if none is specified)public int getLength()
getLength
in class RecordList
getOpenList(com.smartgwt.client.widgets.tree.TreeNode)
public int getLevel(TreeNode node)
root foo barCalling
tree.getLevel(bar)
will return 2
.
Note showRoot
defaults to false so that multiple nodes can be
shown at top level. In
this case, the top-level nodes still have root as a parent, so have level 1, even though
they have no visible parents.
For multi-link trees
, passing a TreeNode
to
this
method will return the level of one of that node's occurences; it is not predictable which
occurence will be used. For multi-link trees, therefore, you should pass a
NodeLocator
with a path that unambiguously identifies the node occurence you
are interested in
node
- node in question, or a suitable NodeLocator
public int getLevel(NodeLocator node)
root foo barCalling
tree.getLevel(bar)
will return 2
.
Note showRoot
defaults to false so that multiple nodes can be
shown at top level. In
this case, the top-level nodes still have root as a parent, so have level 1, even though
they have no visible parents.
For multi-link trees
, passing a TreeNode
to
this
method will return the level of one of that node's occurences; it is not predictable which
occurence will be used. For multi-link trees, therefore, you should pass a
NodeLocator
with a path that unambiguously identifies the node occurence you
are interested in
node
- node in question, or a suitable NodeLocator
public LoadState getLoadState(TreeNode node)
node
- folder in questionpublic TreeNode[] getMultiLinkParents(TreeNode node)
multiLink trees
, returns the array of this node's
direct parents (the actual node objects, not the IDs). For non-multiLink trees, returns an array containing the single
parent of this node. See also getParentsAndPositions()
.node
- node in questionpublic java.lang.String getName(TreeNode node)
nameProperty
]. If
that value has not been set on the node, the node's 'ID' value will be tried (this is node[idField
]). If that value is not present on the node, a unique value
(within this parent) will be auto-generated and returned.node
- node in question, or a suitable NodeLocator
public java.lang.String getName(NodeLocator node)
nameProperty
]. If
that value has not been set on the node, the node's 'ID' value will be tried (this is node[idField
]). If that value is not present on the node, a unique value
(within this parent) will be auto-generated and returned.node
- node in question, or a suitable NodeLocator
public NodeLocator getNodeLocator(java.lang.Integer recordIndex)
multi-link tree
, this method returns the nodeLocator
associated with the particular occurence of the node at the
specified index within the current open list
of nodes in the
tree. Not applicable to non-multilink trees (always returns null)recordIndex
- position of a node occurence within the open list of the treepublic java.lang.String getParentPath(TreeNode node)
getPath()
except the node itself is not reported as part of the path.node
- node in questiongetPath(com.smartgwt.client.widgets.tree.TreeNode)
public Record[] getParentsAndPositions(TreeNode node)
multiLink trees
, returns the array of this node's
direct
parents and the node's position within each parent. Each entry is a record like this:
[ {parent: [reference-to-parent-node], position: [this-node's-position-within-the-parent]}, {parent: [reference-to-parent-node], position: [this-node's-position-within-the-parent]} ]For non-multiLink trees, returns null (calling this method makes no sense for non-multiLink trees).
node
- node in questionpublic java.lang.String getPath(TreeNode node)
([name][pathDelim]?)*
root foo barAssuming that
pathDelim
is the default /
, the
bar
node would have the path root/foo/bar
and the path for the foo
node would be root/foo
.
Note: Nodes in multi-link trees
do not have a
single path,
because a given node can occur in multiple places in the tree. Therefore, if you pass a
TreeNode
instance to this method, it returns the path to one occurence of the
node; which particular occurence it chooses is not predictable, and there may be other paths
to other occurences of the same node in the tree. The only way to obtain an unambiguous
path for a particular occurence of a node is to call getPathForOpenListIndex()
,
passing in the position of the node occurence in the tree's openList (which will be the same
as the record number of the node's visual occurence in a treeGrid
); if
the node occurence is not yet in the tree's openList - either because its parent has not yet
been opened, or because the tree is in the process of being built - the tree is not able to
provide a path to the node occurence. In this case, you would have to obtain the path
in application code, by reference to the original data
and linkData
node
- node in questiongetParentPath(com.smartgwt.client.widgets.tree.TreeNode)
public java.lang.String getPathForOpenListIndex(java.lang.Integer recordIndex)
multi-link tree
, the returned path will be the visible path to the node in the specified index. See getPath()
for more information on paths for TreeNodes.
recordIndex
- position of a node within the open list of the treepublic java.lang.String getTitle(TreeNode node)
titleProperty
is set on the node, the value of that
property is returned. nameProperty
is set on the node, that value is returned, minus any trailing pathDelim
. defaultNodeTitle
is returned. TreeGrid.getNodeTitle()
instead.node
- node for which the title is being requestedTreeGrid.getNodeTitle(com.smartgwt.client.data.Record, int, com.smartgwt.client.widgets.grid.ListGridField)
public java.lang.Boolean hasChildren(TreeNode node)
node
- node in questionpublic java.lang.Boolean hasFolders(TreeNode node)
node
- node in questionpublic java.lang.Boolean hasLeaves(TreeNode node)
node
- node in questionpublic java.lang.Boolean isDescendantOf(TreeNode child, TreeNode parent)
child
- child nodeparent
- parent nodepublic java.lang.Boolean isFolder(TreeNode node)
TreeNode
has a value for the isFolderProperty
(TreeNode.isFolder
by default) that value is returned. childrenProperty
(by default
TreeNode.children
) is checked on the TreeNode
. If the node has the children property defined (regardless of whether it
actually has any children), then isFolder() returns true for that node. node
- node in questionpublic java.lang.Boolean isLeaf(TreeNode node)
node
- node in questionisFolder(com.smartgwt.client.widgets.tree.TreeNode)
public java.lang.Boolean isLoaded(TreeNode node)
node
- folder in questionpublic void isMultiLinkTree()
See linkData
and ResultTree.linkDataSource
for further details of
multiLink trees.
public java.lang.Boolean isOpen(TreeNode node)
multi-link tree
s, passing a NodeLocator
is the only
unambiguous way to specify the node.node
- the node in question, or the the node's ID, or a
NodeLocator objectpublic java.lang.Boolean isOpen(java.lang.String node)
multi-link tree
s, passing a NodeLocator
is the only
unambiguous way to specify the node.node
- the node in question, or the the node's ID, or a
NodeLocator objectpublic java.lang.Boolean isOpen(java.lang.Integer node)
multi-link tree
s, passing a NodeLocator
is the only
unambiguous way to specify the node.node
- the node in question, or the the node's ID, or a
NodeLocator objectpublic java.lang.Boolean isOpen(NodeLocator node)
multi-link tree
s, passing a NodeLocator
is the only
unambiguous way to specify the node.node
- the node in question, or the the node's ID, or a
NodeLocator objectpublic java.lang.Boolean isParent(TreeNode node, TreeNode parent)
multiLink trees
,
however, nodes can have multiple parents, so this method returning true only means that "parent" is a parent of
"node" - there may or may not be others.node
- the node in questionparent
- the node to query to see if is a parent of the other nodepublic java.lang.Boolean isRoot(TreeNode node)
node
- node to testpublic void linkDataChanged()
multi-link tree
s only, called when links are added to
or removed form the tree. public void loadChildren(TreeNode node)
For a databound tree this will trigger a fetch against the Tree's DataSource.
node
- node in questionpublic void loadChildren(TreeNode node, DSCallback callback)
For a databound tree this will trigger a fetch against the Tree's DataSource.
node
- node in questioncallback
- Optional callback (stringMethod) to fire when loading completes. Has a single param
node
- the node whose children have been loaded, and is fired in the scope of the
Tree.public void move(TreeNode node, TreeNode newParent)
node
- node to movenewParent
- new parent to move the node topublic void move(TreeNode node, TreeNode newParent, java.lang.Integer position)
node
- node to movenewParent
- new parent to move the node toposition
- Position of the new node in the children list. If not specified, the node will be added
at the end of the list.public void openAll()
public void openAll(TreeNode node)
node
- node from which to open folders, or the node's ID, or a
NodeLocator object (if not specified, the root node is
used)public void openAll(java.lang.String node)
node
- node from which to open folders, or the node's ID, or a
NodeLocator object (if not specified, the root node is
used)public void openAll(java.lang.Integer node)
node
- node from which to open folders, or the node's ID, or a
NodeLocator object (if not specified, the root node is
used)public void openAll(NodeLocator node)
node
- node from which to open folders, or the node's ID, or a
NodeLocator object (if not specified, the root node is
used)public void reloadChildren(TreeNode node)
node
- node in questionremoveChildren(com.smartgwt.client.widgets.tree.TreeNode)
public java.lang.Boolean remove(TreeNode node)
"Modifying
ResultTrees"
when working with a ResultTree
for limitations. Note, if this is a multi-link tree
, you must pass in a NodeLocator
rather than a node or id.node
- node to remove, or the node's ID, or a NodeLocatorpublic java.lang.Boolean remove(java.lang.String node)
"Modifying
ResultTrees"
when working with a ResultTree
for limitations. Note, if this is a multi-link tree
, you must pass in a NodeLocator
rather than a node or id.node
- node to remove, or the node's ID, or a NodeLocatorpublic java.lang.Boolean remove(java.lang.Integer node)
"Modifying
ResultTrees"
when working with a ResultTree
for limitations. Note, if this is a multi-link tree
, you must pass in a NodeLocator
rather than a node or id.node
- node to remove, or the node's ID, or a NodeLocatorpublic java.lang.Boolean remove(NodeLocator node)
"Modifying
ResultTrees"
when working with a ResultTree
for limitations. Note, if this is a multi-link tree
, you must pass in a NodeLocator
rather than a node or id.node
- node to remove, or the node's ID, or a NodeLocatorpublic void removeChildren(TreeNode node)
ResultTree
s, or non-paged
ResultTree
s, add()
or addList()
can then be used to provide new children. For paged
ResultTrees
, DataSource.updateCaches()
must be used to insert nodes into the cache
as local data, since such ResultTree
s are considered read-only, and add()
and addList()
are
not perrmitted.node
- folder in questiongetLoadState(com.smartgwt.client.widgets.tree.TreeNode)
,
reloadChildren(com.smartgwt.client.widgets.tree.TreeNode)
public void setChildren(TreeNode parent, java.util.List newChildren)
addList()
.parent
- parent of childrennewChildren
- children to be setremoveChildren(com.smartgwt.client.widgets.tree.TreeNode)
,
DataSource.updateCaches(com.smartgwt.client.data.DSResponse)
public void unloadChildren(TreeNode node)
reloadChildren()
to
reload the children of a folder, or removeChildren()
if you
need to clear the cached children of a folder to add specific local data.node
- folder in questionpublic static void discoverTree(TreeNode[] nodes, DiscoverTreeSettings settings, java.lang.String parentChildrenField)
nodes
- list of nodes to link into the tree.settings
- configures how the tree will be exploredparentChildrenField
- public static java.lang.String findChildrenProperty(TreeNode node, ChildrenPropertyMode mode)
node
- the node to checkmode
- determines how to chose the property that appears to contain child objectspublic static void setDefaultProperties(Tree treeProperties)
Note: This method is intended for setting default attributes only and will affect all instances of the underlying class (including those automatically generated in JavaScript). This method should not be used to apply standard EventHandlers or override methods for a class - use a custom subclass instead. Calling this method after instances have been created can result in undefined behavior, since it bypasses any setters and a class instance may have already examined a particular property and not be expecting any changes through this route.
treeProperties
- properties that should be used as new defaults when instances of this class are createdSGWTProperties
public Tree setData(TreeNode[] nodes)
modelType
. If modelType
is
"parent"
, the list that you provide will be passed to linkNodes(com.smartgwt.client.widgets.tree.TreeNode[])
,
integrating the nodes into the tree.
In this case the root node must be supplied separately via root
.
So for example, to create this tree:
foo bar zoowith modelType:"parent", you can do this:
TreeNode root = new TreeNode("root"); Tree tree = new Tree(); tree.setRoot(root); tree.setModelType(TreeModelType.PARENT); TreeNode data[] = new TreeNode[3]; data[0] = new TreeNode("foo"); data[0].setID("foo"); data[0].setParentID("root"); data[1] = new TreeNode("bar"); data[1].setID("bar"); data[1].setParentID("foo"); data[2] = new TreeNode("zoo"); data[2].setID("zoo"); data[2].setParentID("bar"); tree.setData(data);Specifying the root node explicitly allows you to give it a name, changing the way path derivation works (see
root
for more
on naming the root node).
For modelType:"children"
trees, the data passed in will be assumed to
be an array of children of the tree's root node.
nodes
- dataTree
instance, for chaining setter
callspublic ListGridRecord[] getData()
public void setLinkData(Record[] linkData)
multi-link tree
, this property specifies the parent-child
relationships between the nodes. The nodes themselves are provided in the regular tree data
.
Note that multi-link trees must specify a modelType
of "parent".
For a regular, non-multiLink tree, linkData
is ignored.
Minimally, the link data should include a node id, parent id and optionally the position of
the child within that parent (only required if allowDuplicateChildren
is set). To
describe this multi-link tree:
foo bar baz zoo bar bazyou would provide node information in the tree's
data
like this:TreeNode data[] = new TreeNode[4]; data[0] = new TreeNode("foo"); data[0].setID("foo"); data[1] = new TreeNode("bar"); data[1].setID("bar"); data[2] = new TreeNode("baz"); data[2].setID("baz"); data[3] = new TreeNode("zoo"); data[3].setID("zoo"); tree.setData(data);and link information in
linkData
like this:Record linkData[] = new Record[4]; linkData[0] = new Record(); linkData[0].setAttribute("id", "bar"); linkData[0].setAttribute("parentId", "foo"); linkData[1] = new Record(); linkData[1].setAttribute("id", "baz"); linkData[1].setAttribute("parentId", "bar"); linkData[2] = new Record(); linkData[2].setAttribute("id", "zoo"); linkData[2].setAttribute("parentId", "foo"); linkData[3] = new Record(); linkData[3].setAttribute("id", "bar"); linkData[3].setAttribute("parentId", "zoo"); tree.setLinkData(linkData);For information on databinding multi-link trees, and further discussion on multi-link trees generally, see
ResultTree.linkDataSource
linkData
- The link datapublic Record[] getLinkData()
public void setMultiLinkTree(java.lang.Boolean multiLinkTree)
Tree.linkData
and
ResultTree.linkDataSource
for more information on multi-link treesmultiLinkTree
- True indicates that this will be a multi-link treejava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdpublic void setRootValue(java.lang.String rootValue)
root
with an id (idField
), then you can provide the root node's id via this property. See the example in data
for more info.rootValue
- rootValue Default value is nulljava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdpublic void setRootValue(int rootValue)
root
with an id (idField
), then you can provide the root node's id via this property. See the example in data
for more info.rootValue
- rootValue Default value is nulljava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdpublic java.lang.String getRootValue()
public TreeNode getParent(TreeNode node)
node
- node in questionpublic Tree getFilteredTree(Criteria criteria)
If filterMode
is "keepParents", parents are retained if any of their children match the criteria even if
those parents do not match the criteria.
criteria
- criteria to filter bypublic Tree getFilteredTree(Criteria criteria, TreeFilterMode filterMode, DataSource dataSource)
If filterMode
is "keepParents", parents are retained if any of their children match the criteria even if
those parents do not match the criteria.
criteria
- criteria to filter byfilterMode
- mode to use for filtering, defaults to "strict"dataSource
- dataSource to use for filtering, if this Tree does not already have onepublic void linkNodes(TreeNode[] nodes)
idField
) and a parent ID (keyed by parentIdField
). Based on this information, the list
of nodes is integrated into the tree structure.nodes
- list of nodes to link into the tree.public TreeNode[] getParents(TreeNode node)
root foo barCalling
tree.getParents(bar)
would return: [foo, root]
. Note that the returned array will
contain references to the nodes, not the names.node
- node in questionpublic TreeNode findById(java.lang.String id)
id
- ID of the node to return.public TreeNode find(java.lang.String fieldNameOrPath)
com.smartgwt.client..List#find
). node[fieldName]
matches the second argument. So for example, given this tree: foo zoo bar moo barAssuming your
pathDelim
is the default /
and foo
is the name of the root node, then
tree.find("foo/moo/bar")
would return the bar
node under the moo
node.
tree.find("name", "bar")
would return the first bar
node because it is the
first one in the list whose name
(default value of nameProperty
) property matches the value bar
. The two argument usage is generally more
interesting when your tree nodes have some custom unique property that you wish to search on. For example if
your tree nodes had a unique field called "UID", their serialized form would look something like this: { name: "foo", children: [...], UID:"someUniqueId"}You could then call
tree.find("UID",
"someUniqueId")
to find that node. Note that the value doesn't have to be a string - it can be any
valid JS value, but since this data generally comes from the server, the typical types are string, number,
and boolean. tree.find({color: "green", shape: "circle"})
would return the first node in
the tree where both properties matched. tree.find("foo/zoo/bar")
is equivalent to
tree.find("foo/zoo/bar/")
fieldNameOrPath
- Either the path to the node to be found, or the name of
a field which should match the value passed as a second
parameterpublic TreeNode find(java.lang.String fieldNameOrPath, java.lang.Object value)
find
in class RecordList
fieldNameOrPath
- Either the path to the node to be found, or the name of
a field which should match the value passed as a second
parametervalue
- If specified, this is the desired value for the
appropriate fieldfind(String)
public TreeNode find(java.lang.String propertyName, java.util.Date value)
find
in class RecordList
fieldNameOrPath
- Either the path to the node to be found, or the name of
a field which should match the value passed as a second
parametervalue
- If specified, this is the desired value for the
appropriate fieldfind(String)
public TreeNode[] getChildren(TreeNode node)
node
- The node whose children you want to fetch.public TreeNode[] getFolders(TreeNode node)
node
- node in questionpublic TreeNode[] getLeaves(TreeNode node)
node
- node in questionpublic TreeNode[] getDescendants()
find(java.lang.String)
in combination with getChildren(com.smartgwt.client.widgets.tree.TreeNode)
will be much faster. public TreeNode[] getDescendants(TreeNode node)
find(java.lang.String)
in combination with getChildren(com.smartgwt.client.widgets.tree.TreeNode)
will be much faster. node
- node in question (the root node is asumed if none specified)public TreeNode[] getDescendantFolders()
getDescendants()
, except leaf nodes are not part of the returned list.
Like getDescendants()
, this method can be very slow for large
trees. Generally, find(java.lang.String)
in combination with getFolders(com.smartgwt.client.widgets.tree.TreeNode)
be much faster. public TreeNode[] getDescendantFolders(TreeNode node)
getDescendants()
, except leaf nodes are not part of the returned list.
Like getDescendants()
, this method can be very slow for large
trees. Generally, find(java.lang.String)
in combination with getFolders(com.smartgwt.client.widgets.tree.TreeNode)
be much faster. node
- node in question (the root node is assumed if none specified)public TreeNode[] getDescendantLeaves()
getDescendants()
, except folders are not part of the returned list.
Folders are still recursed into, just not returned. Like getDescendants()
,
this method can be very slow for large trees. Generally, find(java.lang.String)
in combination with getLeaves(com.smartgwt.client.widgets.tree.TreeNode)
be much faster. public TreeNode[] getDescendantLeaves(TreeNode node)
getDescendants()
, except folders are not part of the returned list.
Folders are still recursed into, just not returned. Like getDescendants()
,
this method can be very slow for large trees. Generally, find(java.lang.String)
in combination with getLeaves(com.smartgwt.client.widgets.tree.TreeNode)
be much faster. node
- node in question (the root node is assumed if none specified)public TreeNode add(TreeNode node, TreeNode parent)
node
- node to addparent
- Parent of the node being added. You can pass in
either the TreeNode
itself, or a path to
the node (as a String), in which case a
find(java.lang.String)
is performed to find
the node.public TreeNode add(TreeNode node, java.lang.String parentPath)
node
- node to addparentPath
- Parent of the node being added. You can pass in either the TreeNode
itself, or a path to the node (as a String), in which case a
find(java.lang.String)
is performed to find the node.public TreeNode add(TreeNode node, TreeNode parent, int position)
node
- node to addparent
- Parent of the node being added. You can pass in
either the TreeNode
itself, or a path to
the node (as a String), in which case a
find(java.lang.String)
is performed to find
the node.position
- Position of the new node in the children list. If not
specified, the node will be added at the end of the list.public TreeNode[] addList(TreeNode[] nodeList, TreeNode parent)
nodeList
- The list of nodes to addparent
- Parent of the node being added. You can pass in
either the TreeNode
itself, or a path to
the node (as a String), in which case a
find(java.lang.String)
is performed to find
the node.public TreeNode[] addList(TreeNode[] nodeList, java.lang.String parentPath)
nodeList
- The list of nodes to addparentPath
- Parent of the node being added. You can pass in
either the TreeNode
itself, or a path to
the node (as a String), in which case a
find(java.lang.String)
is performed to find
the node.public TreeNode[] addList(TreeNode[] nodeList, TreeNode parent, int position)
nodeList
- The list of nodes to addparent
- Parent of the node being added. You can pass in
either the TreeNode
itself, or a path to
the node (as a String), in which case a
find(java.lang.String)
is performed to find
the node.position
- Position of the new node in the children list. If not
specified, the node will be added at the end of the list.public TreeNode[] addList(TreeNode[] nodeList, java.lang.String parentPath, int position)
nodeList
- The list of nodes to addparentPath
- Parent of the node being added. You can pass in
either the TreeNode
itself, or a path to
the node (as a String), in which case a
find(java.lang.String)
is performed to find
the node.position
- Position of the new node in the children list. If not
specified, the node will be added at the end of the list.public java.lang.Boolean removeList(TreeNode[] nodeList)
nodeList
- list of nodes to removepublic void openFolders(TreeNode[] nodeList)
nodeList
- List of nodes or node paths.public void closeFolders(TreeNode[] nodeList)
nodeList
- List of nodes or node paths.public TreeNode[] getOpenList(TreeNode node)
node
- node in questionpublic static TreeNode nodeForRecord(ListGridRecord record)
record
- the recordpublic void openFolder(TreeNode node)
node
- node to openpublic TreeNode[] getAllNodes()