1 import javax.swing.JOptionPane;
2 import com.sun.star.accessibility.XAccessibleAction;
3 
4 /**
5     Base class for all tree nodes.
6  */
7 class AccessibleActionNode
8     extends StringNode
9 {
10     public AccessibleActionNode (String aDisplayObject,
11         AccessibleTreeNode aParent,
12         int nActionIndex)
13     {
14         super (aDisplayObject, aParent);
15         mnActionIndex = nActionIndex;
16     }
17 
18     public String[] getActions ()
19     {
20         return new String[] {"Perform Action"};
21     }
22 
23     /** perform action */
24     public void performAction (int nIndex)
25     {
26         if (nIndex != 0)
27             return;
28         boolean bResult = false;
29         if (getParent() instanceof AccTreeNode)
30             try
31             {
32                 bResult = AccessibleActionHandler.getAction(
33                     (AccTreeNode)getParent()).doAccessibleAction (
34                         mnActionIndex);
35             }
36         catch (com.sun.star.lang.IndexOutOfBoundsException e)
37         {
38         }
39 
40         JOptionPane.showMessageDialog (null,
41             "performed action " + mnActionIndex
42             + (bResult?" with":" without") + " success",
43             "Action " + mnActionIndex,
44             JOptionPane.INFORMATION_MESSAGE);
45     }
46 
47     private int mnActionIndex;
48 }
49