diff options
author | Andre Fischer <af@openoffice.org> | 2002-08-06 10:44:49 +0000 |
---|---|---|
committer | Andre Fischer <af@openoffice.org> | 2002-08-06 10:44:49 +0000 |
commit | 4798e06ce40969d160bc000b2d5e43767be1ee72 (patch) | |
tree | 1b868d4ae282db127e72ac5bdcd03b037cfc7a7a /toolkit/test/accessibility/TopWindowListener.java | |
parent | #100622# Added default constructor. (diff) | |
download | core-4798e06ce40969d160bc000b2d5e43767be1ee72.tar.gz core-4798e06ce40969d160bc000b2d5e43767be1ee72.zip |
#100622# Initial revision.
Diffstat (limited to 'toolkit/test/accessibility/TopWindowListener.java')
-rw-r--r-- | toolkit/test/accessibility/TopWindowListener.java | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/toolkit/test/accessibility/TopWindowListener.java b/toolkit/test/accessibility/TopWindowListener.java new file mode 100644 index 000000000000..1d92f4d224b9 --- /dev/null +++ b/toolkit/test/accessibility/TopWindowListener.java @@ -0,0 +1,102 @@ +import com.sun.star.awt.XTopWindowListener; +import com.sun.star.awt.XWindow; +import drafts.com.sun.star.awt.XExtendedToolkit; +import drafts.com.sun.star.accessibility.XAccessible; +import com.sun.star.uno.XInterface; +import com.sun.star.uno.UnoRuntime; + +/** Listen for top window events and create or delete children of the tree + model accordingly. +*/ +class TopWindowListener + implements XTopWindowListener +{ + TopWindowListener (AccessibilityTreeModel aModel, SimpleOffice aOffice) + { + maModel = aModel; + maOffice = aOffice; + } + + // XTopWindowListener + public void windowOpened (final com.sun.star.lang.EventObject aEvent) throws RuntimeException + { + System.out.println ("Top window opened: " + aEvent.Source); + if (maModel != null) + { + Object aObject = maModel.getRoot(); + if (aObject instanceof VectorNode) + { + VectorNode aRoot = (VectorNode) aObject; + InformationWriter aIW = new InformationWriter(); + aIW.showInterfaces ((XInterface)aEvent.Source); + XWindow xWindow = (XWindow) UnoRuntime.queryInterface( + XWindow.class, aEvent.Source); + if (xWindow == null) + System.out.println ("event source is no XWindow"); + else + { + XAccessible xAccessible = maOffice.getAccessibleObject(xWindow); + if (xAccessible == null) + System.out.println ("event source is no XAccessible"); + else + { + XAccessible xRoot = maOffice.getAccessibleRoot (xAccessible); + aRoot.addChild ( + AccessibilityTreeModel.createDefaultNode (xRoot, aRoot)); + } + } + } + } + XExtendedToolkit xToolkit = maOffice.getExtendedToolkit(); + if (xToolkit != null) + { + int nTopWindowCount = xToolkit.getTopWindowCount(); + for (int i=0; i<nTopWindowCount; i++) + { + try + { + System.out.println (i + " : " + xToolkit.getTopWindow (i)); + } + catch (Exception e) + { + System.out.println ("caught exception; " + e); + } + } + } + } + public void windowClosing (final com.sun.star.lang.EventObject aEvent) throws RuntimeException + { + System.out.println ("Top window closing: " + aEvent); + } + public void windowClosed (final com.sun.star.lang.EventObject aEvent) throws RuntimeException + { + System.out.println ("Top window closed: " + aEvent); + } + public void windowMinimized (final com.sun.star.lang.EventObject aEvent) throws RuntimeException + { + System.out.println ("Top window minimized: " + aEvent); + } + public void windowNormalized (final com.sun.star.lang.EventObject aEvent) throws RuntimeException + { + System.out.println ("Top window normalized: " + aEvent); + } + public void windowActivated (final com.sun.star.lang.EventObject aEvent) throws RuntimeException + { + System.out.println ("Top window actived: " + aEvent); + } + public void windowDeactivated (final com.sun.star.lang.EventObject aEvent) throws RuntimeException + { + System.out.println ("Top window deactived: " + aEvent); + } + + // XEventListener + public void disposing (com.sun.star.lang.EventObject aEvent) + { + System.out.println ("broadcaster disposed"); + } + + private AccessibilityTreeModel + maModel; + private SimpleOffice + maOffice; +} |