1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 import com.sun.star.awt.XTopWindowListener;
23 import com.sun.star.lang.EventObject;
24 
25 class QueuedTopWindowListener
26     implements XTopWindowListener
27 {
QueuedTopWindowListener(TopWindowListener aListener)28     public QueuedTopWindowListener (TopWindowListener aListener)
29     {
30         maListener = aListener;
31     }
32 
windowOpened(final com.sun.star.lang.EventObject aEvent)33     public void windowOpened (final com.sun.star.lang.EventObject aEvent) throws RuntimeException
34     {
35         EventQueue.Instance().addEvent (new Runnable()
36             {
37                 public void run()
38                 {
39                     QueuedTopWindowListener.this.maListener.windowOpened (aEvent);
40                 }
41             }
42             );
43     }
44 
45 
46 
47 
windowClosing(final com.sun.star.lang.EventObject aEvent)48     public void windowClosing (final com.sun.star.lang.EventObject aEvent) throws RuntimeException
49     {
50         // Ignored.
51     }
52 
53 
54 
55 
windowClosed(final com.sun.star.lang.EventObject aEvent)56     public void windowClosed (final com.sun.star.lang.EventObject aEvent) throws RuntimeException
57     {
58         EventQueue.Instance().addEvent (new Runnable()
59             {
60                 public void run()
61                 {
62                     QueuedTopWindowListener.this.maListener.windowClosed (aEvent);
63                 }
64             }
65             );
66     }
67 
68 
69 
70 
windowMinimized(final com.sun.star.lang.EventObject aEvent)71     public void windowMinimized (final com.sun.star.lang.EventObject aEvent)
72         throws RuntimeException
73     {
74 		System.out.println ("QueuedTopWindowListener: Top window minimized: " + aEvent);
75     }
76 
windowNormalized(final com.sun.star.lang.EventObject aEvent)77     public void windowNormalized (final com.sun.star.lang.EventObject aEvent)
78         throws RuntimeException
79     {
80 		System.out.println ("QueuedTopWindowListener: Top window normalized: " + aEvent);
81     }
82 
windowActivated(final com.sun.star.lang.EventObject aEvent)83     public void windowActivated (final com.sun.star.lang.EventObject aEvent)
84         throws RuntimeException
85     {
86 		System.out.println ("QueuedTopWindowListener: Top window activated: " + aEvent);
87     }
88 
windowDeactivated(final com.sun.star.lang.EventObject aEvent)89     public void windowDeactivated (final com.sun.star.lang.EventObject aEvent)
90         throws RuntimeException
91     {
92 		System.out.println ("QueuedTopWindowListener: Top window deactived: " + aEvent);
93     }
94 
disposing( final EventObject aEvent)95     public void disposing( final EventObject aEvent)
96     {
97         EventQueue.Instance().addDisposingEvent (new Runnable()
98             {
99                 public void run()
100                 {
101                     if (QueuedTopWindowListener.this.maListener != null)
102                         QueuedTopWindowListener.this.maListener.disposing (aEvent);
103                 }
104             }
105             );
106     }
107 
108     private TopWindowListener maListener;
109 }
110