author | darcy |
Tue, 24 Sep 2019 18:25:54 -0700 | |
changeset 58309 | c6f8b2c3dc66 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
5506 | 2 |
* Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package java.awt; |
|
27 |
||
28 |
import sun.awt.AppContext; |
|
29 |
import sun.awt.SunToolkit; |
|
30 |
||
31 |
/** |
|
32 |
* A wrapping tag for a nested AWTEvent which indicates that the event was |
|
33 |
* sent from another AppContext. The destination AppContext should handle the |
|
34 |
* event even if it is currently blocked waiting for a SequencedEvent or |
|
35 |
* another SentEvent to be handled. |
|
36 |
* |
|
37 |
* @author David Mendenhall |
|
38 |
*/ |
|
39 |
class SentEvent extends AWTEvent implements ActiveEvent { |
|
40 |
/* |
|
41 |
* serialVersionUID |
|
42 |
*/ |
|
43 |
private static final long serialVersionUID = -383615247028828931L; |
|
44 |
||
45 |
static final int ID = |
|
46 |
java.awt.event.FocusEvent.FOCUS_LAST + 2; |
|
47 |
||
48 |
boolean dispatched; |
|
49 |
private AWTEvent nested; |
|
58309
c6f8b2c3dc66
8231334: Suppress warnings on non-serializable instance fields in client libs serializable classes
darcy
parents:
47216
diff
changeset
|
50 |
@SuppressWarnings("serial") // Not statically typed as Serializable |
2 | 51 |
private AppContext toNotify; |
52 |
||
53 |
SentEvent() { |
|
54 |
this(null); |
|
55 |
} |
|
56 |
SentEvent(AWTEvent nested) { |
|
57 |
this(nested, null); |
|
58 |
} |
|
59 |
SentEvent(AWTEvent nested, AppContext toNotify) { |
|
60 |
super((nested != null) |
|
61 |
? nested.getSource() |
|
62 |
: Toolkit.getDefaultToolkit(), |
|
63 |
ID); |
|
64 |
this.nested = nested; |
|
65 |
this.toNotify = toNotify; |
|
66 |
} |
|
67 |
||
68 |
public void dispatch() { |
|
69 |
try { |
|
70 |
if (nested != null) { |
|
71 |
Toolkit.getEventQueue().dispatchEvent(nested); |
|
72 |
} |
|
73 |
} finally { |
|
74 |
dispatched = true; |
|
75 |
if (toNotify != null) { |
|
76 |
SunToolkit.postEvent(toNotify, new SentEvent()); |
|
77 |
} |
|
78 |
synchronized (this) { |
|
79 |
notifyAll(); |
|
80 |
} |
|
81 |
} |
|
82 |
} |
|
83 |
final void dispose() { |
|
84 |
dispatched = true; |
|
85 |
if (toNotify != null) { |
|
86 |
SunToolkit.postEvent(toNotify, new SentEvent()); |
|
87 |
} |
|
88 |
synchronized (this) { |
|
89 |
notifyAll(); |
|
90 |
} |
|
91 |
} |
|
92 |
} |