jdk/src/share/classes/sun/awt/EventQueueDelegate.java
author denis
Wed, 27 Mar 2013 16:19:51 +0400
changeset 16705 1caaa379eded
parent 5506 202f599c92aa
permissions -rw-r--r--
7075105: WIN: Provide a way to format HTML on drop Reviewed-by: uta, serb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1293
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1294
diff changeset
     2
 * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
1293
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
     4
 *
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1294
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
1293
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1294
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
1293
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    10
 *
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    15
 * accompanied this code).
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    16
 *
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1294
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1294
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1294
diff changeset
    23
 * questions.
1293
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    24
 */
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    25
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    26
package sun.awt;
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    27
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    28
import java.awt.AWTEvent;
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    29
import java.awt.EventQueue;
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    30
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    31
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    32
public class EventQueueDelegate {
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    33
    private static final Object EVENT_QUEUE_DELEGATE_KEY =
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    34
        new StringBuilder("EventQueueDelegate.Delegate");
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    35
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    36
    public static void setDelegate(Delegate delegate) {
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    37
        AppContext.getAppContext().put(EVENT_QUEUE_DELEGATE_KEY, delegate);
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    38
    }
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    39
    public static Delegate getDelegate() {
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    40
        return
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    41
          (Delegate) AppContext.getAppContext().get(EVENT_QUEUE_DELEGATE_KEY);
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    42
    }
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    43
    public interface Delegate {
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    44
        /**
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    45
         * This method allows for changing {@code EventQueue} events order.
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    46
         *
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    47
         * @param eventQueue current {@code EventQueue}
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    48
         * @return next {@code event} for the {@code EventDispatchThread}
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    49
         */
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    50
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    51
        public AWTEvent getNextEvent(EventQueue eventQueue) throws InterruptedException;
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    52
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    53
        /**
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    54
         * Notifies delegate before EventQueue.dispatch method.
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    55
         *
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    56
         * Note: this method may mutate the event
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    57
         *
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    58
         * @param event  to be dispatched by {@code dispatch} method
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    59
         * @return handle to be passed to {@code afterDispatch} method
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    60
         */
1294
16088ec1b9e7 6699328: NullPointerException in EventQueue.dispatchEvent when applet is closed, only reprise/scenario applet
idk
parents: 1293
diff changeset
    61
        public Object beforeDispatch(AWTEvent event) throws InterruptedException;
1293
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    62
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    63
        /**
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    64
         * Notifies delegate after EventQueue.dispatch method.
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    65
         *
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    66
         * @param event {@code event} dispatched by the {@code dispatch} method
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    67
         * @param handle object which came from {@code beforeDispatch} method
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    68
         */
1294
16088ec1b9e7 6699328: NullPointerException in EventQueue.dispatchEvent when applet is closed, only reprise/scenario applet
idk
parents: 1293
diff changeset
    69
        public void afterDispatch(AWTEvent event, Object handle) throws InterruptedException;
1293
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    70
    }
ef349b440fc9 6638195: need API for EventQueueDelegate
idk
parents:
diff changeset
    71
}