| 1 | /* Copyright (C) 2000 Free Software Foundation
|
|---|
| 2 |
|
|---|
| 3 | This file is part of libjava.
|
|---|
| 4 |
|
|---|
| 5 | This software is copyrighted work licensed under the terms of the
|
|---|
| 6 | Libjava License. Please consult the file "LIBJAVA_LICENSE" for
|
|---|
| 7 | details. */
|
|---|
| 8 |
|
|---|
| 9 | package java.awt.event;
|
|---|
| 10 | import java.awt.*;
|
|---|
| 11 |
|
|---|
| 12 | /**
|
|---|
| 13 | * @author Tom Tromey <[email protected]>
|
|---|
| 14 | * @date April 8, 2000
|
|---|
| 15 | */
|
|---|
| 16 |
|
|---|
| 17 | /* Status: Believed to be complete and correct. */
|
|---|
| 18 |
|
|---|
| 19 | public class InvocationEvent extends AWTEvent implements ActiveEvent
|
|---|
| 20 | {
|
|---|
| 21 | public static final int INVOCATION_DEFAULT = 1200;
|
|---|
| 22 | public static final int INVOCATION_FIRST = 1200;
|
|---|
| 23 | public static final int INVOCATION_LAST = 1200;
|
|---|
| 24 |
|
|---|
| 25 | protected InvocationEvent (Object source, int id, Runnable runnable,
|
|---|
| 26 | Object notifier, boolean catchExceptions)
|
|---|
| 27 | {
|
|---|
| 28 | super (source, id);
|
|---|
| 29 | this.runnable = runnable;
|
|---|
| 30 | this.notifier = notifier;
|
|---|
| 31 | this.catchExceptions = catchExceptions;
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | public InvocationEvent (Object source, Runnable runnable)
|
|---|
| 35 | {
|
|---|
| 36 | super (source, INVOCATION_DEFAULT);
|
|---|
| 37 | this.runnable = runnable;
|
|---|
| 38 | }
|
|---|
| 39 |
|
|---|
| 40 | public InvocationEvent(Object source, Runnable runnable, Object notifier,
|
|---|
| 41 | boolean catchExceptions)
|
|---|
| 42 | {
|
|---|
| 43 | super (source, INVOCATION_DEFAULT);
|
|---|
| 44 | this.runnable = runnable;
|
|---|
| 45 | this.notifier = notifier;
|
|---|
| 46 | this.catchExceptions = catchExceptions;
|
|---|
| 47 | }
|
|---|
| 48 |
|
|---|
| 49 | public void dispatch ()
|
|---|
| 50 | {
|
|---|
| 51 | Exception e = null;
|
|---|
| 52 | if (catchExceptions)
|
|---|
| 53 | try
|
|---|
| 54 | {
|
|---|
| 55 | runnable.run ();
|
|---|
| 56 | }
|
|---|
| 57 | catch (Exception x)
|
|---|
| 58 | {
|
|---|
| 59 | exception = x;
|
|---|
| 60 | }
|
|---|
| 61 | else
|
|---|
| 62 | runnable.run ();
|
|---|
| 63 |
|
|---|
| 64 | if (notifier != null)
|
|---|
| 65 | {
|
|---|
| 66 | synchronized (notifier)
|
|---|
| 67 | {
|
|---|
| 68 | notifier.notifyAll ();
|
|---|
| 69 | }
|
|---|
| 70 | }
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | public Exception getException ()
|
|---|
| 74 | {
|
|---|
| 75 | return exception;
|
|---|
| 76 | }
|
|---|
| 77 |
|
|---|
| 78 | public String paramString ()
|
|---|
| 79 | {
|
|---|
| 80 | String r;
|
|---|
| 81 | if (id == INVOCATION_DEFAULT)
|
|---|
| 82 | r = "INVOCATION_DEFAULT";
|
|---|
| 83 | else
|
|---|
| 84 | r = "unknown type";
|
|---|
| 85 |
|
|---|
| 86 | r += ",runnable=" + runnable + ",notifier=" + notifier +
|
|---|
| 87 | ",catchExceptions=" + catchExceptions;
|
|---|
| 88 | return r;
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 | protected boolean catchExceptions;
|
|---|
| 92 | protected Object notifier;
|
|---|
| 93 | protected Runnable runnable;
|
|---|
| 94 |
|
|---|
| 95 | private Exception exception;
|
|---|
| 96 | }
|
|---|