2 import com
.sun
.star
.uno
.UnoRuntime
;
3 import com
.sun
.star
.accessibility
.XAccessible
;
4 import com
.sun
.star
.accessibility
.XAccessibleContext
;
5 import com
.sun
.star
.accessibility
.XAccessibleSelection
;
6 import com
.sun
.star
.lang
.IndexOutOfBoundsException
;
10 import java
.util
.Vector
;
11 import java
.awt
.event
.ActionListener
;
12 import java
.awt
.event
.ActionEvent
;
16 class AccessibleSelectionHandler
19 public NodeHandler
createHandler( XAccessibleContext xContext
)
21 XAccessibleSelection xSelection
=
22 (XAccessibleSelection
) UnoRuntime
.queryInterface(
23 XAccessibleSelection
.class, xContext
);
24 return (xSelection
== null) ?
null :
25 new AccessibleSelectionHandler(xSelection
);
28 public AccessibleSelectionHandler()
32 public AccessibleSelectionHandler( XAccessibleSelection xSelection
)
34 if (xSelection
!= null)
35 maChildList
.setSize( 2 );
38 public AccessibleTreeNode
createChild( AccessibleTreeNode aParent
,
41 AccessibleTreeNode aChild
= null;
43 if( aParent
instanceof AccTreeNode
)
45 XAccessibleSelection xSelection
=
46 ((AccTreeNode
)aParent
).getSelection();
47 if( xSelection
!= null )
52 aChild
= new StringNode(
53 "getSelectedAccessibleChildCount: " +
54 xSelection
.getSelectedAccessibleChildCount(),
60 new VectorNode( "Selected Children", aParent
);
62 int nCount
= ((AccTreeNode
)aParent
).getContext().
63 getAccessibleChildCount();
66 for( int i
= 0; i
< nCount
; i
++ )
70 if( xSelection
.isAccessibleChildSelected( i
) )
72 XAccessible xSelChild
= xSelection
.
73 getSelectedAccessibleChild(nSelected
);
75 ((AccTreeNode
)aParent
).
76 getContext().getAccessibleChild( i
);
77 aVNode
.addChild( new StringNode(
79 xNChild
.getAccessibleContext().
80 getAccessibleDescription() + " (" +
81 (xSelChild
.equals(xNChild
) ?
"OK" : "XXX") +
85 catch (com
.sun
.star
.lang
.DisposedException e
)
87 aVNode
.addChild( new StringNode(
88 i
+ ": caught DisposedException while creating",
94 catch( IndexOutOfBoundsException e
)
96 aChild
= new StringNode( "IndexOutOfBounds",
102 aChild
= new StringNode( "ERROR", aParent
);
112 public String
[] getActions (AccessibleTreeNode aNode
)
114 if( aNode
instanceof AccTreeNode
)
116 XAccessibleSelection xSelection
=
117 ((AccTreeNode
)aNode
).getSelection();
118 if( xSelection
!= null )
120 return new String
[] { "Select..." };
123 return new String
[0];
126 public void performAction (AccessibleTreeNode aNode
, int nIndex
)
128 new SelectionDialog( (AccTreeNode
)aNode
).show();