2
|
1 |
/*
|
5506
|
2 |
* Copyright (c) 1997, 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 |
/**
|
|
27 |
* An EventQueue subclass which adds selective tracing of events as they
|
|
28 |
* are posted to an EventQueue. Tracing is globally enabled and disabled
|
|
29 |
* by the AWT.TraceEventPosting property in awt.properties. <P>
|
|
30 |
*
|
|
31 |
* The optional AWT.NoTraceIDs property defines a list of AWTEvent IDs
|
|
32 |
* which should not be traced, such as MouseEvent.MOUSE_MOVED or PaintEvents.
|
|
33 |
* This list is declared by specifying the decimal value of each event's ID,
|
|
34 |
* separated by commas.
|
|
35 |
*
|
|
36 |
* @author Thomas Ball
|
|
37 |
*/
|
|
38 |
|
|
39 |
package sun.awt;
|
|
40 |
|
|
41 |
import java.awt.EventQueue;
|
|
42 |
import java.awt.AWTEvent;
|
|
43 |
import java.awt.Toolkit;
|
|
44 |
import java.util.StringTokenizer;
|
|
45 |
|
|
46 |
public class TracedEventQueue extends EventQueue {
|
|
47 |
|
|
48 |
// Determines whether any event tracing is enabled.
|
|
49 |
static boolean trace = false;
|
|
50 |
|
|
51 |
// The list of event IDs to ignore when tracing.
|
|
52 |
static int suppressedIDs[] = null;
|
|
53 |
|
|
54 |
static {
|
|
55 |
String s = Toolkit.getProperty("AWT.IgnoreEventIDs", "");
|
|
56 |
if (s.length() > 0) {
|
|
57 |
StringTokenizer st = new StringTokenizer(s, ",");
|
|
58 |
int nIDs = st.countTokens();
|
|
59 |
suppressedIDs = new int[nIDs];
|
|
60 |
for (int i = 0; i < nIDs; i++) {
|
|
61 |
String idString = st.nextToken();
|
|
62 |
try {
|
|
63 |
suppressedIDs[i] = Integer.parseInt(idString);
|
|
64 |
} catch (NumberFormatException e) {
|
|
65 |
System.err.println("Bad ID listed in AWT.IgnoreEventIDs " +
|
|
66 |
"in awt.properties: \"" +
|
|
67 |
idString + "\" -- skipped");
|
|
68 |
suppressedIDs[i] = 0;
|
|
69 |
}
|
|
70 |
}
|
|
71 |
} else {
|
|
72 |
suppressedIDs = new int[0];
|
|
73 |
}
|
|
74 |
}
|
|
75 |
|
|
76 |
public void postEvent(AWTEvent theEvent) {
|
|
77 |
boolean printEvent = true;
|
|
78 |
int id = theEvent.getID();
|
|
79 |
for (int i = 0; i < suppressedIDs.length; i++) {
|
|
80 |
if (id == suppressedIDs[i]) {
|
|
81 |
printEvent = false;
|
|
82 |
break;
|
|
83 |
}
|
|
84 |
}
|
|
85 |
if (printEvent) {
|
|
86 |
System.out.println(Thread.currentThread().getName() +
|
|
87 |
": " + theEvent);
|
|
88 |
}
|
|
89 |
super.postEvent(theEvent);
|
|
90 |
}
|
|
91 |
}
|