com.metamatrix.toolbox.ui.widget.tree
Class DefaultTreeView

java.lang.Object
  extended by com.metamatrix.toolbox.ui.widget.tree.DefaultTreeView
All Implemented Interfaces:
PropertiedObjectView, UserTransactionFactory, TreeView, java.util.Comparator

public class DefaultTreeView
extends java.lang.Object
implements java.util.Comparator, TreeView

This is the default TreeView used by DefaultTreeModel.

Since:
2.0
Version:
2.0
Author:
John P. A. Verhaeg

Constructor Summary
DefaultTreeView()
          Creates a DefaultTreeView with an empty DefaultTreeNode as a root node.
DefaultTreeView(DefaultTreeNode root)
          Creates a DefaultTreeView with an empty DefaultTreeNode as a root node.
DefaultTreeView(java.lang.Object value)
          Creates a DefaultTreeView with an empty DefaultTreeNode as a root node.
 
Method Summary
 boolean allowsChild(TreeNode parent, TreeNode potentialChild)
          Determine whether the specified parent TreeNode may contain the specified child node.
 boolean allowsChildren(TreeNode node)
          Determine whether the specified TreeNode may contain children.
 int compare(java.lang.Object firstNode, java.lang.Object secondNode)
           
 UserTransaction createReadTransaction()
          Create a new instance of a UserTransaction that may be used to read information.
 UserTransaction createWriteTransaction()
          Create a new instance of a UserTransaction that may be used to write and/or update information.
 UserTransaction createWriteTransaction(java.lang.Object source)
          Create a new instance of a UserTransaction that may be used to write and/or update information.
 java.lang.String getAbsolutePath(TreeNode node)
           
 DefaultTreeNode getChild(DefaultTreeNode parent, int index)
           
 int getChildCount(TreeNode parent)
           
 int getChildIndex(DefaultTreeNode parent, DefaultTreeNode child)
           
 java.util.List getChildren(TreeNode parent)
          Obtain the set of entries that are considered the children of the specified TreeNode.
 java.util.Comparator getComparator()
          Set the comparator that provides the order for children returned from this view.
 TreeNodeFilter getFilter()
          Set the filter that limits the set of TreeNode instances returned from this view.
 TreeNode getHome()
          Obtain the TreeNode that represents the home for the underlying system.
 java.util.Set getMarked()
          Return the set of marked nodes for this view.
 TreeNode getParent(TreeNode child)
          Determine the parent TreeNode for the specified entry, or null if the specified entry is a root.
 java.lang.String getPath(TreeNode node)
          Obtain the abstract path for this TreeNode.
 PropertiedObjectEditor getPropertiedObjectEditor()
          Return the propertied object editor for this view.
 java.util.List getPropertyDefinitions()
          Get the definitions of the properties for the TreeNode instances returned from this view.
 DefaultTreeNode getRoot()
           
 java.util.List getRoots()
          Returns all root partitians on this TreeNode system.
 java.lang.String getSeparator()
          Not implemented.
 char getSeparatorChar()
          Obtain the character that is used to separate names in a path sequence for the abstract path.
 TreeNodeEditor getTreeNodeEditor()
          Return the tree node editor for this view.
protected  void initializeDefaultTreeView()
           
 boolean isAncestorOf(TreeNode ancestor, TreeNode descendent)
          Determine whether the specified node is a descendent of the given ancestor node.
 boolean isHidden(TreeNode node)
          Determine whether the specified TreeNode is hidden.
 boolean isMarked(TreeNode node)
          Return the marked state of the specified entry.
 boolean isParentOf(TreeNode parent, TreeNode child)
          Determine whether the specified node is a child of the given parent node.
 boolean isRoot(TreeNode node)
          Determine whether the specified TreeNode is a root of the underlying system.
 java.util.Iterator iterator()
          Obtain an iterator for this whole view, which navigates the view's nodes using pre-order rules (i.e., it visits a node before its children).
 java.util.Iterator iterator(TreeNode startingPoint)
          Obtain an iterator for the view starting at the specified node.
 void setComparator(java.util.Comparator comparator)
          Set the comparator that should be used to order the children.
 void setFilter(TreeNodeFilter filter)
          Set the filter that limits the set of TreeNode instances returned from this view.
 void setMarked(TreeNode node, boolean isMarked)
          Set the marked state of the specified entry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

DefaultTreeView

public DefaultTreeView()
Creates a DefaultTreeView with an empty DefaultTreeNode as a root node.

Since:
2.0

DefaultTreeView

public DefaultTreeView(DefaultTreeNode root)
Creates a DefaultTreeView with an empty DefaultTreeNode as a root node.

Since:
2.0

DefaultTreeView

public DefaultTreeView(java.lang.Object value)
Creates a DefaultTreeView with an empty DefaultTreeNode as a root node.

Since:
2.0
Method Detail

allowsChildren

public boolean allowsChildren(TreeNode node)
Description copied from interface: TreeView
Determine whether the specified TreeNode may contain children.

Specified by:
allowsChildren in interface TreeView
Parameters:
node - the TreeNode instance that is to be checked; may not be null
Returns:
true if the entry can contain children, or false otherwise.
Since:
2.0

allowsChild

public boolean allowsChild(TreeNode parent,
                           TreeNode potentialChild)
Description copied from interface: TreeView
Determine whether the specified parent TreeNode may contain the specified child node.

Specified by:
allowsChild in interface TreeView
Parameters:
parent - the TreeNode instance that is to be the parent; may not be null
potentialChild - the TreeNode instance that is to be the child; may not be null
Returns:
true if potentialChild can be placed as a child of parent, or false otherwise.
Since:
2.0

compare

public int compare(java.lang.Object firstNode,
                   java.lang.Object secondNode)
Specified by:
compare in interface java.util.Comparator
Since:
2.0

createReadTransaction

public UserTransaction createReadTransaction()
Description copied from interface: UserTransactionFactory
Create a new instance of a UserTransaction that may be used to read information. Read transactions do not have a source object associated with them (since they never directly modify data).

The returned transaction object will not be bound to an underlying system transaction until begin() is called on the returned object.

Specified by:
createReadTransaction in interface UserTransactionFactory
Returns:
the new transaction object
Since:
2.0

createWriteTransaction

public UserTransaction createWriteTransaction()
Description copied from interface: UserTransactionFactory
Create a new instance of a UserTransaction that may be used to write and/or update information. The transaction will not have a source object associated with it.

The returned transaction object will not be bound to an underlying system transaction until begin() is called on the returned object.

Specified by:
createWriteTransaction in interface UserTransactionFactory
Returns:
the new transaction object
Since:
2.0

createWriteTransaction

public UserTransaction createWriteTransaction(java.lang.Object source)
Description copied from interface: UserTransactionFactory
Create a new instance of a UserTransaction that may be used to write and/or update information. The source object will be used for all events that are fired as a result of or as a product of this transaction.

The returned transaction object will not be bound to an underlying system transaction until begin() is called on the returned object.

Specified by:
createWriteTransaction in interface UserTransactionFactory
Parameters:
source - the object that is considered to be the source of the transaction; may be null
Returns:
the new transaction object
Since:
2.0

getAbsolutePath

public java.lang.String getAbsolutePath(TreeNode node)
Since:
2.0

getChild

public DefaultTreeNode getChild(DefaultTreeNode parent,
                                int index)
Since:
2.0

getChildCount

public int getChildCount(TreeNode parent)
Since:
2.0

getChildIndex

public int getChildIndex(DefaultTreeNode parent,
                         DefaultTreeNode child)
Since:
2.0

getChildren

public java.util.List getChildren(TreeNode parent)
Description copied from interface: TreeView
Obtain the set of entries that are considered the children of the specified TreeNode.

Specified by:
getChildren in interface TreeView
Parameters:
parent - the TreeNode instance for which the child entries are to be obtained; may not be null
Returns:
the unmodifiable list of TreeNode instances that are considered the children of the specified entry; never null but possibly empty
Since:
2.0

iterator

public java.util.Iterator iterator()
Description copied from interface: TreeView
Obtain an iterator for this whole view, which navigates the view's nodes using pre-order rules (i.e., it visits a node before its children).

Specified by:
iterator in interface TreeView
Returns:
the iterator that traverses the nodes in this view; never null
Since:
2.0

iterator

public java.util.Iterator iterator(TreeNode startingPoint)
Description copied from interface: TreeView
Obtain an iterator for the view starting at the specified node. This implementation currently navigates the subtree using pre-order rules (i.e., it visits a node before its children).

Specified by:
iterator in interface TreeView
Parameters:
startingPoint - the root of the subtree over which the iterator is to navigate; may not be null
Returns:
the iterator that traverses the nodes in the subtree starting at the specified node; never null
Since:
2.0

getComparator

public java.util.Comparator getComparator()
Description copied from interface: TreeView
Set the comparator that provides the order for children returned from this view.

Specified by:
getComparator in interface TreeView
Returns:
the current comparator; never null
Since:
2.0

getPropertiedObjectEditor

public PropertiedObjectEditor getPropertiedObjectEditor()
Description copied from interface: PropertiedObjectView
Return the propertied object editor for this view.

Specified by:
getPropertiedObjectEditor in interface PropertiedObjectView
Returns:
the PropertiedObjectEditor instance
Since:
2.0

getFilter

public TreeNodeFilter getFilter()
Description copied from interface: TreeView
Set the filter that limits the set of TreeNode instances returned from this view.

Specified by:
getFilter in interface TreeView
Returns:
the current filter; never null
Since:
2.0

getHome

public TreeNode getHome()
Description copied from interface: TreeView
Obtain the TreeNode that represents the home for the underlying system. If the underlying system does not support a home entry concept, null is returned.

Specified by:
getHome in interface TreeView
Returns:
the entry that represents the home, or null if no home concept is supported.
Since:
2.0

getParent

public TreeNode getParent(TreeNode child)
Description copied from interface: TreeView
Determine the parent TreeNode for the specified entry, or null if the specified entry is a root.

Specified by:
getParent in interface TreeView
Parameters:
child - the TreeNode instance for which the parent is to be obtained; may not be null
Returns:
the parent entry, or null if there is no parent
Since:
2.0

getPath

public java.lang.String getPath(TreeNode node)
Description copied from interface: TreeView
Obtain the abstract path for this TreeNode.

Specified by:
getPath in interface TreeView
Returns:
the string that represents the abstract path of this entry; never null
Since:
2.0

getPropertyDefinitions

public java.util.List getPropertyDefinitions()
Description copied from interface: TreeView
Get the definitions of the properties for the TreeNode instances returned from this view.

Specified by:
getPropertyDefinitions in interface TreeView
Returns:
the unmodifiable list of PropertyDefinition instances; never null
Since:
2.0

getRoot

public DefaultTreeNode getRoot()
Since:
2.0

getRoots

public java.util.List getRoots()
Description copied from interface: TreeView
Returns all root partitians on this TreeNode system.

Specified by:
getRoots in interface TreeView
Returns:
the unmodifiable list of TreeNode instances that represent the roots
Since:
2.0

getSeparator

public java.lang.String getSeparator()
Not implemented.

Specified by:
getSeparator in interface TreeView
Returns:
the string containing the charater used to delimit names in the abstract path; never null
Since:
2.0

getSeparatorChar

public char getSeparatorChar()
Description copied from interface: TreeView
Obtain the character that is used to separate names in a path sequence for the abstract path. This character is completely dependent upon the implementation.

Specified by:
getSeparatorChar in interface TreeView
Returns:
the charater used to delimit names in the abstract path.
Since:
2.0

getTreeNodeEditor

public TreeNodeEditor getTreeNodeEditor()
Description copied from interface: TreeView
Return the tree node editor for this view.

Specified by:
getTreeNodeEditor in interface TreeView
Returns:
the TreeNodeEditor instance
Since:
2.0

initializeDefaultTreeView

protected void initializeDefaultTreeView()
Since:
2.0

isAncestorOf

public boolean isAncestorOf(TreeNode ancestor,
                            TreeNode descendent)
Description copied from interface: TreeView
Determine whether the specified node is a descendent of the given ancestor node.

Specified by:
isAncestorOf in interface TreeView
Returns:
true if the node is a descendent of the given ancestor node.
Since:
2.0

isHidden

public boolean isHidden(TreeNode node)
Description copied from interface: TreeView
Determine whether the specified TreeNode is hidden.

Specified by:
isHidden in interface TreeView
Parameters:
node - the TreeNode instance that is to be checked; may not be null
Returns:
true if the entry is hidden, or false otherwise.
Since:
2.0

isMarked

public boolean isMarked(TreeNode node)
Description copied from interface: TreeView
Return the marked state of the specified entry.

Specified by:
isMarked in interface TreeView
Returns:
the marked state of the entry.
Since:
2.0

isParentOf

public boolean isParentOf(TreeNode parent,
                          TreeNode child)
Description copied from interface: TreeView
Determine whether the specified node is a child of the given parent node.

Specified by:
isParentOf in interface TreeView
Returns:
true if the node is a child of the given parent node.
Since:
2.0

isRoot

public boolean isRoot(TreeNode node)
Description copied from interface: TreeView
Determine whether the specified TreeNode is a root of the underlying system.

Specified by:
isRoot in interface TreeView
Parameters:
node - the TreeNode instance that is to be checked; may not be null
Returns:
true if the entry is a root, or false otherwise.
Since:
2.0

setComparator

public void setComparator(java.util.Comparator comparator)
Description copied from interface: TreeView
Set the comparator that should be used to order the children.

Specified by:
setComparator in interface TreeView
Parameters:
comparator - the comparator, or null if entry name sorting should be used.
Since:
2.0

setFilter

public void setFilter(TreeNodeFilter filter)
Description copied from interface: TreeView
Set the filter that limits the set of TreeNode instances returned from this view.

Specified by:
setFilter in interface TreeView
Parameters:
filter - the filter, or null if the default "pass-through" filter should be used.
Since:
2.0

setMarked

public void setMarked(TreeNode node,
                      boolean isMarked)
Description copied from interface: TreeView
Set the marked state of the specified entry.

Specified by:
setMarked in interface TreeView
Since:
2.0

getMarked

public java.util.Set getMarked()
Return the set of marked nodes for this view.

Specified by:
getMarked in interface TreeView
Parameters:
the - unmodifiable set of marked nodes; never null


Copyright © 2009. All Rights Reserved.