1*1b0aaa91SAndrew Rist /**************************************************************
2*1b0aaa91SAndrew Rist  *
3*1b0aaa91SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*1b0aaa91SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*1b0aaa91SAndrew Rist  * distributed with this work for additional information
6*1b0aaa91SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*1b0aaa91SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*1b0aaa91SAndrew Rist  * "License"); you may not use this file except in compliance
9*1b0aaa91SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*1b0aaa91SAndrew Rist  *
11*1b0aaa91SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*1b0aaa91SAndrew Rist  *
13*1b0aaa91SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*1b0aaa91SAndrew Rist  * software distributed under the License is distributed on an
15*1b0aaa91SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*1b0aaa91SAndrew Rist  * KIND, either express or implied.  See the License for the
17*1b0aaa91SAndrew Rist  * specific language governing permissions and limitations
18*1b0aaa91SAndrew Rist  * under the License.
19*1b0aaa91SAndrew Rist  *
20*1b0aaa91SAndrew Rist  *************************************************************/
21*1b0aaa91SAndrew Rist 
22cdf0e10cSrcweir import java.util.Vector;
23cdf0e10cSrcweir import com.sun.star.lang.IndexOutOfBoundsException;
24cdf0e10cSrcweir 
25cdf0e10cSrcweir /**
26cdf0e10cSrcweir     Base class for all tree nodes.
27cdf0e10cSrcweir  */
28cdf0e10cSrcweir class AccessibleTreeNode
29cdf0e10cSrcweir {
30cdf0e10cSrcweir     /// The parent node.  It is null for the root node.
31cdf0e10cSrcweir     protected AccessibleTreeNode maParent;
32cdf0e10cSrcweir 
33cdf0e10cSrcweir     /// The object to be displayed.
34cdf0e10cSrcweir     private Object maDisplayObject;
35cdf0e10cSrcweir 
AccessibleTreeNode(Object aDisplayObject, AccessibleTreeNode aParent)36cdf0e10cSrcweir     public AccessibleTreeNode (Object aDisplayObject, AccessibleTreeNode aParent)
37cdf0e10cSrcweir     {
38cdf0e10cSrcweir         maDisplayObject = aDisplayObject;
39cdf0e10cSrcweir         maParent = aParent;
40cdf0e10cSrcweir     }
41cdf0e10cSrcweir 
update()42cdf0e10cSrcweir     public void update ()
43cdf0e10cSrcweir     {
44cdf0e10cSrcweir         // Empty
45cdf0e10cSrcweir     }
46cdf0e10cSrcweir 
getParent()47cdf0e10cSrcweir     public AccessibleTreeNode getParent ()
48cdf0e10cSrcweir     {
49cdf0e10cSrcweir         return maParent;
50cdf0e10cSrcweir     }
51cdf0e10cSrcweir 
getDisplayObject()52cdf0e10cSrcweir     public Object getDisplayObject ()
53cdf0e10cSrcweir     {
54cdf0e10cSrcweir         return maDisplayObject;
55cdf0e10cSrcweir     }
56cdf0e10cSrcweir 
getChildCount()57cdf0e10cSrcweir     public int getChildCount ()
58cdf0e10cSrcweir     {
59cdf0e10cSrcweir         return 0;
60cdf0e10cSrcweir     }
61cdf0e10cSrcweir 
getChild(int nIndex)62cdf0e10cSrcweir     public AccessibleTreeNode getChild (int nIndex)
63cdf0e10cSrcweir         throws IndexOutOfBoundsException
64cdf0e10cSrcweir     {
65cdf0e10cSrcweir         throw new IndexOutOfBoundsException();
66cdf0e10cSrcweir     }
67cdf0e10cSrcweir 
getChildNoCreate(int nIndex)68cdf0e10cSrcweir     public AccessibleTreeNode getChildNoCreate (int nIndex)
69cdf0e10cSrcweir         throws IndexOutOfBoundsException
70cdf0e10cSrcweir     {
71cdf0e10cSrcweir         throw new IndexOutOfBoundsException();
72cdf0e10cSrcweir     }
73cdf0e10cSrcweir 
removeChild(int nIndex)74cdf0e10cSrcweir     public boolean removeChild (int nIndex)
75cdf0e10cSrcweir         throws IndexOutOfBoundsException
76cdf0e10cSrcweir     {
77cdf0e10cSrcweir         throw new IndexOutOfBoundsException();
78cdf0e10cSrcweir     }
79cdf0e10cSrcweir 
indexOf(AccessibleTreeNode aNode)80cdf0e10cSrcweir     public int indexOf (AccessibleTreeNode aNode)
81cdf0e10cSrcweir     {
82cdf0e10cSrcweir         return -1;
83cdf0e10cSrcweir     }
84cdf0e10cSrcweir 
85cdf0e10cSrcweir     /** Create a path to this node by first asking the parent for its path
86cdf0e10cSrcweir         and then appending this object.
87cdf0e10cSrcweir     */
createPath(java.util.Vector aPath)88cdf0e10cSrcweir     public void createPath (java.util.Vector aPath)
89cdf0e10cSrcweir     {
90cdf0e10cSrcweir         if (maParent != null)
91cdf0e10cSrcweir             maParent.createPath (aPath);
92cdf0e10cSrcweir         aPath.add (this);
93cdf0e10cSrcweir     }
94cdf0e10cSrcweir 
createPath()95cdf0e10cSrcweir     public Object[] createPath ()
96cdf0e10cSrcweir     {
97cdf0e10cSrcweir         Vector aPath = new Vector (1);
98cdf0e10cSrcweir         createPath (aPath);
99cdf0e10cSrcweir         return aPath.toArray();
100cdf0e10cSrcweir     }
101cdf0e10cSrcweir 
isLeaf()102cdf0e10cSrcweir     public boolean isLeaf()
103cdf0e10cSrcweir     {
104cdf0e10cSrcweir         return true;
105cdf0e10cSrcweir     }
106cdf0e10cSrcweir 
toString()107cdf0e10cSrcweir     public String toString()
108cdf0e10cSrcweir     {
109cdf0e10cSrcweir         return maDisplayObject.toString();
110cdf0e10cSrcweir     }
111cdf0e10cSrcweir 
112cdf0e10cSrcweir     /** get names of suported actions */
getActions()113cdf0e10cSrcweir     public String[] getActions ()
114cdf0e10cSrcweir     {
115cdf0e10cSrcweir         return new String[] {};
116cdf0e10cSrcweir     }
117cdf0e10cSrcweir 
118cdf0e10cSrcweir     /** perform action */
performAction(int nIndex)119cdf0e10cSrcweir     public void performAction (int nIndex)
120cdf0e10cSrcweir     {
121cdf0e10cSrcweir     }
122cdf0e10cSrcweir }
123