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