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