bump product version to 7.2.5.1
[LibreOffice.git] / toolkit / test / accessibility / NodeHandler.java
blob69cff2c13edf6c65167d3692b9eb138890d1ee0d
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 import java.util.Vector;
22 /**
23 * Map an arbitrary object into parts of a tree node.
25 abstract class NodeHandler
27 /** This vector is used as cache for the child objects.
29 protected Vector<AccessibleTreeNode> maChildList;
32 public abstract NodeHandler createHandler (
33 com.sun.star.accessibility.XAccessibleContext xContext);
35 public NodeHandler ()
37 maChildList = new Vector<AccessibleTreeNode> ();
40 /** return the number of children this object has */
41 public int getChildCount()
43 synchronized (maChildList)
45 return maChildList.size();
49 /**
50 * return a child object. Complex
51 * children have to be AccTreeNode instances.
52 * @see AccTreeNode
54 public AccessibleTreeNode getChild (AccessibleTreeNode aParent, int nIndex)
56 synchronized (maChildList)
58 AccessibleTreeNode aChild = maChildList.get(nIndex);
59 if (aChild == null)
61 aChild = createChild (aParent, nIndex);
62 if (aChild == null)
63 aChild = new StringNode ("could not create child", aParent);
64 maChildList.set (nIndex, aChild);
66 return aChild;
70 public AccessibleTreeNode getChildNoCreate (int nIndex)
72 synchronized (maChildList)
74 return maChildList.get(nIndex);
78 /** Remove the specified child from the list of children.
80 public boolean removeChild (int nIndex)
82 try
84 synchronized (maChildList)
86 System.out.println (" removing child at position " + nIndex + ": "
87 + maChildList.get (nIndex));
88 maChildList.remove (nIndex);
91 catch (Exception e)
93 return false;
95 return true;
98 public int indexOf (AccessibleTreeNode aNode)
100 synchronized (maChildList)
102 return maChildList.indexOf (aNode);
106 /** Create a child object for the specified data. This method is called
107 usually from getChild and put there into the cache.
109 public abstract AccessibleTreeNode createChild (
110 AccessibleTreeNode aParent, int nIndex);
113 // The following methods support editing of children and actions.
114 // They have default implementations for no actions and read-only.
117 /** get names of supported actions */
118 public String[] getActions (AccessibleTreeNode aNode)
120 return new String[] {};
123 /** perform action */
124 public void performAction (AccessibleTreeNode aNode, int nIndex)
128 /** Update all children.
130 public void update (AccessibleTreeNode aNode)