1 import java
.util
.Vector
;
5 * Map an arbitrary object into parts of a tree node.
7 abstract class NodeHandler
9 /** This vector is used as cache for the child objects.
11 protected Vector maChildList
;
14 public abstract NodeHandler
createHandler (
15 com
.sun
.star
.accessibility
.XAccessibleContext xContext
);
19 maChildList
= new Vector ();
22 /** Clear the cache of child objects.
26 synchronized (maChildList
)
28 maChildList
= new Vector ();
32 /** This factory method creates an individual handler for the specified
33 object that may hold information to accelerate the access to its children.
35 // public abstract NodeHandler createHandler (Object aObject);
37 /** return the number of children this object has */
38 public int getChildCount(Object aObject
)
40 synchronized (maChildList
)
42 return maChildList
.size();
47 * return a child object. Complex
48 * children have to be AccTreeNode instances.
51 public AccessibleTreeNode
getChild (AccessibleTreeNode aParent
, int nIndex
)
53 synchronized (maChildList
)
55 AccessibleTreeNode aChild
= (AccessibleTreeNode
)maChildList
.get(nIndex
);
58 aChild
= createChild (aParent
, nIndex
);
60 aChild
= new StringNode ("could not create child", aParent
);
61 maChildList
.setElementAt (aChild
, nIndex
);
67 public AccessibleTreeNode
getChildNoCreate (AccessibleTreeNode aParent
, int nIndex
)
69 synchronized (maChildList
)
71 return (AccessibleTreeNode
)maChildList
.get(nIndex
);
75 /** Remove the specified child from the list of children.
77 public boolean removeChild (AccessibleTreeNode aNode
, int nIndex
)
81 synchronized (maChildList
)
83 System
.out
.println (" removing child at position " + nIndex
+ ": "
84 + maChildList
.elementAt (nIndex
));
85 maChildList
.remove (nIndex
);
95 public int indexOf (AccessibleTreeNode aNode
)
97 synchronized (maChildList
)
99 return maChildList
.indexOf (aNode
);
103 /** Create a child object for the specified data. This method is called
104 usually from getChild and put there into the cache.
106 public abstract AccessibleTreeNode
createChild (
107 AccessibleTreeNode aParent
, int nIndex
);
110 // The following methods support editing of children and actions.
111 // They have default implementations for no actions and read-only.
114 /** May this child be changed? */
115 public boolean isChildEditable (AccessibleTreeNode aNode
, int nIndex
)
120 /** change this child's value */
121 // public void setChild(Object aObject, int nIndex) { }
124 /** get names of suported actions */
125 public String
[] getActions (AccessibleTreeNode aNode
)
127 return new String
[] {};
130 /** perform action */
131 public void performAction (AccessibleTreeNode aNode
, int nIndex
)
135 /** Update all children.
137 public void update (AccessibleTreeNode aNode
)