0N/A/*
2362N/A * Copyright (c) 1997, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A/**
0N/A * An EventQueue subclass which adds selective tracing of events as they
0N/A * are posted to an EventQueue. Tracing is globally enabled and disabled
0N/A * by the AWT.TraceEventPosting property in awt.properties. <P>
0N/A *
0N/A * The optional AWT.NoTraceIDs property defines a list of AWTEvent IDs
0N/A * which should not be traced, such as MouseEvent.MOUSE_MOVED or PaintEvents.
0N/A * This list is declared by specifying the decimal value of each event's ID,
0N/A * separated by commas.
0N/A *
0N/A * @author Thomas Ball
0N/A */
0N/A
0N/Apackage sun.awt;
0N/A
0N/Aimport java.awt.EventQueue;
0N/Aimport java.awt.AWTEvent;
0N/Aimport java.awt.Toolkit;
0N/Aimport java.util.StringTokenizer;
0N/A
0N/Apublic class TracedEventQueue extends EventQueue {
0N/A
0N/A // Determines whether any event tracing is enabled.
0N/A static boolean trace = false;
0N/A
0N/A // The list of event IDs to ignore when tracing.
0N/A static int suppressedIDs[] = null;
0N/A
0N/A static {
0N/A String s = Toolkit.getProperty("AWT.IgnoreEventIDs", "");
0N/A if (s.length() > 0) {
0N/A StringTokenizer st = new StringTokenizer(s, ",");
0N/A int nIDs = st.countTokens();
0N/A suppressedIDs = new int[nIDs];
0N/A for (int i = 0; i < nIDs; i++) {
0N/A String idString = st.nextToken();
0N/A try {
0N/A suppressedIDs[i] = Integer.parseInt(idString);
0N/A } catch (NumberFormatException e) {
0N/A System.err.println("Bad ID listed in AWT.IgnoreEventIDs " +
0N/A "in awt.properties: \"" +
0N/A idString + "\" -- skipped");
0N/A suppressedIDs[i] = 0;
0N/A }
0N/A }
0N/A } else {
0N/A suppressedIDs = new int[0];
0N/A }
0N/A }
0N/A
0N/A public void postEvent(AWTEvent theEvent) {
0N/A boolean printEvent = true;
0N/A int id = theEvent.getID();
0N/A for (int i = 0; i < suppressedIDs.length; i++) {
0N/A if (id == suppressedIDs[i]) {
0N/A printEvent = false;
0N/A break;
0N/A }
0N/A }
0N/A if (printEvent) {
0N/A System.out.println(Thread.currentThread().getName() +
0N/A ": " + theEvent);
0N/A }
0N/A super.postEvent(theEvent);
0N/A }
0N/A}