All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.as400.vaccess.AS400TreeModel

java.lang.Object
   |
   +----com.ibm.as400.vaccess.AS400TreeModel

public class AS400TreeModel
extends Object
implements TreeModel, Serializable
The AS400TreeModel class implements an underlying model for a tree, where all information for the tree is gathered from the hierarchy of objects rooted at an AS/400 resource. You must explicitly call load() to load the information from the AS/400.

Use this class if you want to customize the graphical user interface that presents a tree. If you do not need to customize the interface, then use AS400TreePane instead.

Most errors are reported as ErrorEvents rather than throwing exceptions. Users should listen for ErrorEvents in order to diagnose and recover from error conditions.

AS400TreeModel objects generate the following events:

The following example creates a tree model filled with the list of printers on an AS/400. It then presents the tree in a JTree object.

//Set up the tree model and JTree.
AS400 system = new AS400 ("MySystem", "Userid", "Password");
VPrinters printers = new VPrinters (system);
AS400TreeModel treeModel = new AS400TreeModel (printers);
treeModel.load ();
JTree tree = new JTree (treeModel);

// Add the JTree to a frame. JFrame frame = new JFrame ("My Window"); frame.getContentPane().add(new JScrollPane(tree));

See Also:
AS400TreePane

Constructor Index

 o AS400TreeModel()
Constructs an AS400TreeModel object.
 o AS400TreeModel(VNode)
Constructs an AS400TreeModel object.

Method Index

 o addErrorListener(ErrorListener)
Adds a listener to be notified when an error occurs.
 o addPropertyChangeListener(PropertyChangeListener)
Adds a listener to be notified when the value of any bound property changes.
 o addTreeModelListener(TreeModelListener)
Adds a listener to be notified when the contents of the tree change.
 o addVetoableChangeListener(VetoableChangeListener)
Adds a listener to be notified when the value of any constrained property changes.
 o addWorkingListener(WorkingListener)
Adds a listener to be notified when work starts and stops on potentially long-running operations.
 o getChild(Object, int)
Returns a child of the parent.
 o getChildCount(Object)
Returns the number of children of the parent.
 o getIndexOfChild(Object, Object)
Returns the index of a child in the parent.
 o getPath(Object)
Returns the path from the root to get to this object in the tree hierarchy.
 o getRoot()
Returns the root, or the AS/400 resource, from which all information for the model is gathered.
 o isLeaf(Object)
Indicates if the object is a leaf in the tree.
 o load()
Loads the information from the AS/400.
 o removeErrorListener(ErrorListener)
Removes an error listener.
 o removePropertyChangeListener(PropertyChangeListener)
Removes a property change listener.
 o removeTreeModelListener(TreeModelListener)
Removes a tree model listener.
 o removeVetoableChangeListener(VetoableChangeListener)
Removes a vetoable change listener.
 o removeWorkingListener(WorkingListener)
Removes a working listener.
 o setRoot(Object)
Sets the root, or the AS/400 resource, from which all information for the model is gathered.
 o valueForPathChanged(TreePath, Object)
Notifies the object that the value for the item identified by path has changed.

Constructors

 o AS400TreeModel
 public AS400TreeModel()
Constructs an AS400TreeModel object.

 o AS400TreeModel
 public AS400TreeModel(VNode root)
Constructs an AS400TreeModel object.

Parameters:
root - The root, or the AS/400 resource, from which all information for the model is gathered.

Methods

 o addErrorListener
 public void addErrorListener(ErrorListener listener)
Adds a listener to be notified when an error occurs.

Parameters:
listener - The listener.
 o addPropertyChangeListener
 public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a listener to be notified when the value of any bound property changes.

Parameters:
listener - The listener.
 o addTreeModelListener
 public void addTreeModelListener(TreeModelListener listener)
Adds a listener to be notified when the contents of the tree change.

Parameters:
listener - The listener.
 o addVetoableChangeListener
 public void addVetoableChangeListener(VetoableChangeListener listener)
Adds a listener to be notified when the value of any constrained property changes.

Parameters:
listener - The listener.
 o addWorkingListener
 public void addWorkingListener(WorkingListener listener)
Adds a listener to be notified when work starts and stops on potentially long-running operations.

Parameters:
listener - The listener.
 o getChild
 public Object getChild(Object parent,
                        int index)
Returns a child of the parent.

Parameters:
parent - The parent.
index - The index of the child.
Returns:
The child. It will be null if the parent is not a valid object or if the index is not valid for the parent.
 o getChildCount
 public int getChildCount(Object parent)
Returns the number of children of the parent.

Parameters:
parent - The parent.
Returns:
The number of children of the parent, or 0 if the parent is not a valid object.
 o getIndexOfChild
 public int getIndexOfChild(Object parent,
                            Object child)
Returns the index of a child in the parent.

Parameters:
parent - The parent.
child - The child.
Returns:
The index of the child in the parent. It will be -1 if the parent or child are not valid objects or if the child is not in the parent.
 o getPath
 public TreePath getPath(Object object)
Returns the path from the root to get to this object in the tree hierarchy. The last element in the path will be this object.

Parameters:
object - The object.
Returns:
The path, or null if the object is not a valid object.
 o getRoot
 public Object getRoot()
Returns the root, or the AS/400 resource, from which all information for the model is gathered.

Returns:
The root, or the AS/400 resource, from which all information for the model is gathered. It will be null if none has been set.
 o isLeaf
 public boolean isLeaf(Object object)
Indicates if the object is a leaf in the tree.

Parameters:
object - The object.
Returns:
true if the object is a leaf or the object is not a valid object; false if the object is not a leaf.
 o load
 public void load()
Loads the information from the AS/400.

 o removeErrorListener
 public void removeErrorListener(ErrorListener listener)
Removes an error listener.

Parameters:
listener - The listener.
 o removePropertyChangeListener
 public void removePropertyChangeListener(PropertyChangeListener listener)
Removes a property change listener.

Parameters:
listener - The listener.
 o removeTreeModelListener
 public void removeTreeModelListener(TreeModelListener listener)
Removes a tree model listener.

Parameters:
listener - The listener.
 o removeVetoableChangeListener
 public void removeVetoableChangeListener(VetoableChangeListener listener)
Removes a vetoable change listener.

Parameters:
listener - The listener.
 o removeWorkingListener
 public void removeWorkingListener(WorkingListener listener)
Removes a working listener.

Parameters:
listener - The listener.
 o setRoot
 public void setRoot(Object root) throws PropertyVetoException
Sets the root, or the AS/400 resource, from which all information for the model is gathered. It will not take effect until load() is done.

Parameters:
root - The root, or the AS/400 resource, from which all information for the model is gathered. This must be a VNode.
Throws: PropertyVetoException
If the change is vetoed.
 o valueForPathChanged
 public void valueForPathChanged(TreePath path,
                                 Object value)
Notifies the object that the value for the item identified by path has changed.

Parameters:
path - The path of the item containing the new value.
value - The new value.

All Packages  Class Hierarchy  This Package  Previous  Next  Index