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