xref: /AOO41X/main/toolkit/test/accessibility/AccessibleTreeNode.java (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir import java.util.Vector;
2*cdf0e10cSrcweir import com.sun.star.lang.IndexOutOfBoundsException;
3*cdf0e10cSrcweir 
4*cdf0e10cSrcweir /**
5*cdf0e10cSrcweir     Base class for all tree nodes.
6*cdf0e10cSrcweir  */
7*cdf0e10cSrcweir class AccessibleTreeNode
8*cdf0e10cSrcweir {
9*cdf0e10cSrcweir     /// The parent node.  It is null for the root node.
10*cdf0e10cSrcweir     protected AccessibleTreeNode maParent;
11*cdf0e10cSrcweir 
12*cdf0e10cSrcweir     /// The object to be displayed.
13*cdf0e10cSrcweir     private Object maDisplayObject;
14*cdf0e10cSrcweir 
15*cdf0e10cSrcweir     public AccessibleTreeNode (Object aDisplayObject, AccessibleTreeNode aParent)
16*cdf0e10cSrcweir     {
17*cdf0e10cSrcweir         maDisplayObject = aDisplayObject;
18*cdf0e10cSrcweir         maParent = aParent;
19*cdf0e10cSrcweir     }
20*cdf0e10cSrcweir 
21*cdf0e10cSrcweir     public void update ()
22*cdf0e10cSrcweir     {
23*cdf0e10cSrcweir         // Empty
24*cdf0e10cSrcweir     }
25*cdf0e10cSrcweir 
26*cdf0e10cSrcweir     public AccessibleTreeNode getParent ()
27*cdf0e10cSrcweir     {
28*cdf0e10cSrcweir         return maParent;
29*cdf0e10cSrcweir     }
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir     public Object getDisplayObject ()
32*cdf0e10cSrcweir     {
33*cdf0e10cSrcweir         return maDisplayObject;
34*cdf0e10cSrcweir     }
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir     public int getChildCount ()
37*cdf0e10cSrcweir     {
38*cdf0e10cSrcweir         return 0;
39*cdf0e10cSrcweir     }
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir     public AccessibleTreeNode getChild (int nIndex)
42*cdf0e10cSrcweir         throws IndexOutOfBoundsException
43*cdf0e10cSrcweir     {
44*cdf0e10cSrcweir         throw new IndexOutOfBoundsException();
45*cdf0e10cSrcweir     }
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir     public AccessibleTreeNode getChildNoCreate (int nIndex)
48*cdf0e10cSrcweir         throws IndexOutOfBoundsException
49*cdf0e10cSrcweir     {
50*cdf0e10cSrcweir         throw new IndexOutOfBoundsException();
51*cdf0e10cSrcweir     }
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir     public boolean removeChild (int nIndex)
54*cdf0e10cSrcweir         throws IndexOutOfBoundsException
55*cdf0e10cSrcweir     {
56*cdf0e10cSrcweir         throw new IndexOutOfBoundsException();
57*cdf0e10cSrcweir     }
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir     public int indexOf (AccessibleTreeNode aNode)
60*cdf0e10cSrcweir     {
61*cdf0e10cSrcweir         return -1;
62*cdf0e10cSrcweir     }
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir     /** Create a path to this node by first asking the parent for its path
65*cdf0e10cSrcweir         and then appending this object.
66*cdf0e10cSrcweir     */
67*cdf0e10cSrcweir     public void createPath (java.util.Vector aPath)
68*cdf0e10cSrcweir     {
69*cdf0e10cSrcweir         if (maParent != null)
70*cdf0e10cSrcweir             maParent.createPath (aPath);
71*cdf0e10cSrcweir         aPath.add (this);
72*cdf0e10cSrcweir     }
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir     public Object[] createPath ()
75*cdf0e10cSrcweir     {
76*cdf0e10cSrcweir         Vector aPath = new Vector (1);
77*cdf0e10cSrcweir         createPath (aPath);
78*cdf0e10cSrcweir         return aPath.toArray();
79*cdf0e10cSrcweir     }
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir     public boolean isLeaf()
82*cdf0e10cSrcweir     {
83*cdf0e10cSrcweir         return true;
84*cdf0e10cSrcweir     }
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir     public String toString()
87*cdf0e10cSrcweir     {
88*cdf0e10cSrcweir         return maDisplayObject.toString();
89*cdf0e10cSrcweir     }
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir     /** get names of suported actions */
92*cdf0e10cSrcweir     public String[] getActions ()
93*cdf0e10cSrcweir     {
94*cdf0e10cSrcweir         return new String[] {};
95*cdf0e10cSrcweir     }
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir     /** perform action */
98*cdf0e10cSrcweir     public void performAction (int nIndex)
99*cdf0e10cSrcweir     {
100*cdf0e10cSrcweir     }
101*cdf0e10cSrcweir }
102