src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/GUIInitializedMulticaster.java
author dholmes
Sun, 08 Jul 2018 20:00:46 -0400
changeset 51005 0083d474b0e1
parent 47216 71c04702a3d5
permissions -rw-r--r--
8205966: [testbug] New Nestmates JDI test times out with Xcomp on sparc Reviewed-by: mikael, sspitsyn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29883
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
     1
/*
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
     2
 * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
     4
 *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    10
 *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    15
 * accompanied this code).
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    16
 *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    20
 *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    23
 * questions.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    24
 */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    25
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    26
package com.sun.java.accessibility.util;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    27
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    28
import java.awt.*;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    29
import java.util.EventListener;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    30
import javax.accessibility.*;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    31
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    32
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    33
/**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    34
 * The GUIInitializedMulticaster class is used to maintain a list of
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    35
 * GUIInitializedListener classes.  It is intended to be used primarily
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    36
 * for internal support in the EventQueueMonitor class, and is not intended
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    37
 * to be used by classes outside the Java Accessibility Utility package.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    38
 *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    39
 * @see EventQueueMonitor
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    40
 * @see EventQueueMonitor#addGUIInitializedListener
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    41
 * @see EventQueueMonitor#removeGUIInitializedListener
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    42
 *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    43
 */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    44
class GUIInitializedMulticaster
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    45
    extends AWTEventMulticaster implements GUIInitializedListener
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    46
{
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    47
    protected GUIInitializedMulticaster(EventListener a, EventListener b) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    48
        super(a, b);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    49
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    50
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    51
    public void guiInitialized() {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    52
        ((GUIInitializedListener)a).guiInitialized();
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    53
        ((GUIInitializedListener)b).guiInitialized();
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    54
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    55
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    56
    public static GUIInitializedListener add(GUIInitializedListener a, GUIInitializedListener b) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    57
        return (GUIInitializedListener)addInternal(a, b);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    58
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    59
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    60
    public static GUIInitializedListener remove(GUIInitializedListener l, GUIInitializedListener oldl) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    61
        return (GUIInitializedListener)removeInternal(l, oldl);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    62
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    63
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    64
    protected static EventListener addInternal(EventListener a, EventListener b) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    65
        if (a == null)  return b;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    66
        if (b == null)  return a;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    67
        return new GUIInitializedMulticaster(a, b);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    68
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    69
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    70
    protected static EventListener removeInternal(EventListener l, EventListener oldl) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    71
        if (l == oldl || l == null) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    72
            return null;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    73
        } else if (l instanceof GUIInitializedMulticaster) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    74
            return ((GUIInitializedMulticaster)l).remove(oldl);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    75
        } else {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    76
            return l;           // it's not here
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    77
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    78
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    79
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    80
}