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:
- ErrorEvent
- PropertyChangeEvent
- TreeModelEvent
- WorkingEvent
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(JTable.createScrollPaneForTable(tree));
- See Also:
- AS400TreePane
-
AS400TreeModel()
- Constructs an AS400TreeModel object.
-
AS400TreeModel(VNode)
- Constructs an AS400TreeModel object.
-
addErrorListener(ErrorListener)
- Adds a listener to be notified when an error occurs.
-
addPropertyChangeListener(PropertyChangeListener)
- Adds a listener to be notified when the value of any
bound property changes.
-
addTreeModelListener(TreeModelListener)
- Adds a listener to be notified when the contents of
the tree change.
-
addVetoableChangeListener(VetoableChangeListener)
- Adds a listener to be notified when the value of any
constrained property changes.
-
addWorkingListener(WorkingListener)
- Adds a listener to be notified when work starts and stops
on potentially long-running operations.
-
getChild(Object, int)
- Returns a child of the parent.
-
getChildCount(Object)
- Returns the number of children of the parent.
-
getIndexOfChild(Object, Object)
- Returns the index of a child in the parent.
-
getPath(Object)
- Returns the path from the root to get to this object in the tree
hierarchy.
-
getRoot()
- Returns the root, or the AS/400 resource, from which all information for the model is gathered.
-
isLeaf(Object)
- Indicates if the object is a leaf in the tree.
-
load()
- Loads the information from the AS/400.
-
removeErrorListener(ErrorListener)
- Removes an error listener.
-
removePropertyChangeListener(PropertyChangeListener)
- Removes a property change listener.
-
removeTreeModelListener(TreeModelListener)
- Removes a tree model listener.
-
removeVetoableChangeListener(VetoableChangeListener)
- Removes a vetoable change listener.
-
removeWorkingListener(WorkingListener)
- Removes a working listener.
-
setRoot(Object)
- Sets the root, or the AS/400 resource, from which all information
for the model is gathered.
-
valueForPathChanged(TreePath, Object)
- Notifies the object that the value for the item identified by path
has changed.
AS400TreeModel
public AS400TreeModel()
- Constructs an AS400TreeModel object.
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.
addErrorListener
public void addErrorListener(ErrorListener listener)
- Adds a listener to be notified when an error occurs.
- Parameters:
- listener - The listener.
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener listener)
- Adds a listener to be notified when the value of any
bound property changes.
- Parameters:
- listener - The listener.
addTreeModelListener
public void addTreeModelListener(TreeModelListener listener)
- Adds a listener to be notified when the contents of
the tree change.
- Parameters:
- listener - The listener.
addVetoableChangeListener
public void addVetoableChangeListener(VetoableChangeListener listener)
- Adds a listener to be notified when the value of any
constrained property changes.
- Parameters:
- listener - The listener.
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.
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.
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.
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.
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.
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.
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.
load
public void load()
- Loads the information from the AS/400.
removeErrorListener
public void removeErrorListener(ErrorListener listener)
- Removes an error listener.
- Parameters:
- listener - The listener.
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener listener)
- Removes a property change listener.
- Parameters:
- listener - The listener.
removeTreeModelListener
public void removeTreeModelListener(TreeModelListener listener)
- Removes a tree model listener.
- Parameters:
- listener - The listener.
removeVetoableChangeListener
public void removeVetoableChangeListener(VetoableChangeListener listener)
- Removes a vetoable change listener.
- Parameters:
- listener - The listener.
removeWorkingListener
public void removeWorkingListener(WorkingListener listener)
- Removes a working listener.
- Parameters:
- listener - The listener.
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.
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