# HG changeset patch # User asaha # Date 1433388537 25200 # Node ID ec8f5229c8e9213e77e4d736cebb1392c78f6e43 # Parent e5171238515c362d787a3dad487220c62ba5b100# Parent b2c55ff77112321472ec97c3a6931a999837d183 Merge diff -r e5171238515c -r ec8f5229c8e9 .hgtags --- a/.hgtags Fri May 29 10:15:38 2015 -0700 +++ b/.hgtags Wed Jun 03 20:28:57 2015 -0700 @@ -439,3 +439,4 @@ a006fa0a9e8f18dee6daf8984bd11625c4c4860c jdk8u60-b15 6ed3821c212a93ffc6bfcc292ef7aca3b7165139 jdk8u60-b16 c30db4c968f63dce1bf2f9df240fb75a8f27f922 jdk8u60-b17 +57336c319de8a141d0bcd04265ce36734fb51380 jdk8u60-b18 diff -r e5171238515c -r ec8f5229c8e9 make/CompileJavaClasses.gmk --- a/make/CompileJavaClasses.gmk Fri May 29 10:15:38 2015 -0700 +++ b/make/CompileJavaClasses.gmk Wed Jun 03 20:28:57 2015 -0700 @@ -70,10 +70,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows) # AccessBridge is compiled separately below. EXFILES += AccessBridge.java \ - AccessBridgeLoader.java \ - com/sun/java/accessibility/util/java/awt/ChoiceTranslator.java - # This seems to never be built - EXCLUDES += com/sun/java/accessibility/extensions + AccessBridgeLoader.java endif ifneq ($(OPENJDK_TARGET_OS), solaris) diff -r e5171238515c -r ec8f5229c8e9 make/CreateJars.gmk --- a/make/CreateJars.gmk Fri May 29 10:15:38 2015 -0700 +++ b/make/CreateJars.gmk Wed Jun 03 20:28:57 2015 -0700 @@ -650,17 +650,8 @@ ########################################################################################## - ifeq ($(OPENJDK_TARGET_OS), windows) - - $(eval $(call SetupArchive,BUILD_JACCESS_JAR, , \ - SRCS := $(JDK_OUTPUTDIR)/classes, \ - INCLUDES := com/sun/java/accessibility/util, \ - JAR := $(IMAGES_OUTPUTDIR)/lib/ext/jaccess.jar, \ - SKIP_METAINF := true)) - - JARS += $(IMAGES_OUTPUTDIR)/lib/ext/jaccess.jar - - ifeq ($(OPENJDK_TARGET_CPU_BITS), 32) +ifeq ($(OPENJDK_TARGET_OS), windows) + ifeq ($(OPENJDK_TARGET_CPU_BITS), 32) $(eval $(call SetupArchive,BUILD_ACCESSBRIDGE_32_JAR, , \ SRCS := $(JDK_OUTPUTDIR)/classes_ab/32bit, \ INCLUDES := com/sun/java/accessibility, \ @@ -675,7 +666,7 @@ JARS += $(IMAGES_OUTPUTDIR)/lib/ext/access-bridge-32.jar \ $(IMAGES_OUTPUTDIR)/lib/ext/access-bridge.jar - else + else $(eval $(call SetupArchive,BUILD_ACCESSBRIDGE_64_JAR, , \ SRCS := $(JDK_OUTPUTDIR)/classes_ab/64bit, \ INCLUDES := com/sun/java/accessibility, \ @@ -683,8 +674,16 @@ SKIP_METAINF := true)) JARS += $(IMAGES_OUTPUTDIR)/lib/ext/access-bridge-64.jar - endif endif +endif + +$(eval $(call SetupArchive,BUILD_JACCESS_JAR, , \ + SRCS := $(JDK_OUTPUTDIR)/classes, \ + INCLUDES := com/sun/java/accessibility/util, \ + JAR := $(IMAGES_OUTPUTDIR)/lib/ext/jaccess.jar, \ + SKIP_METAINF := true)) + +JARS += $(IMAGES_OUTPUTDIR)/lib/ext/jaccess.jar ########################################################################################## diff -r e5171238515c -r ec8f5229c8e9 src/macosx/classes/sun/lwawt/macosx/CAccessibility.java --- a/src/macosx/classes/sun/lwawt/macosx/CAccessibility.java Fri May 29 10:15:38 2015 -0700 +++ b/src/macosx/classes/sun/lwawt/macosx/CAccessibility.java Wed Jun 03 20:28:57 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -630,7 +630,7 @@ if (!allowIgnored) { final AccessibleRole role = context.getAccessibleRole(); - if (role != null && ignoredRoles.contains(roleKey(role))) { + if (role != null && ignoredRoles != null && ignoredRoles.contains(roleKey(role))) { // Get the child's unignored children. _addChildren(child, whichChildren, false, childrenAndRoles); } else { diff -r e5171238515c -r ec8f5229c8e9 src/macosx/javavm/export/jawt_md.h --- a/src/macosx/javavm/export/jawt_md.h Fri May 29 10:15:38 2015 -0700 +++ b/src/macosx/javavm/export/jawt_md.h Wed Jun 03 20:28:57 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/beans/decoder/ArrayElementHandler.java --- a/src/share/classes/com/sun/beans/decoder/ArrayElementHandler.java Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/beans/decoder/ArrayElementHandler.java Wed Jun 03 20:28:57 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2013 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/java/accessibility/util/AWTEventMonitor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/java/accessibility/util/AWTEventMonitor.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,1495 @@ +/* + * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.java.accessibility.util; + +import java.util.*; +import java.awt.*; +import java.awt.event.*; +import javax.accessibility.*; +import javax.swing.*; +import javax.swing.event.*; +import sun.security.util.SecurityConstants.AWT; + +/** + *

The {@code AWTEventMonitor} implements a suite of listeners that are + * conditionally installed on every AWT component instance in the Java + * Virtual Machine. The events captured by these listeners are made + * available through a unified set of listeners supported by {@code AWTEventMonitor}. + * With this, all the individual events on each of the AWT component + * instances are funneled into one set of listeners broken down by category + * (see {@link EventID} for the categories). + *

This class depends upon {@link EventQueueMonitor}, which provides the base + * level support for capturing the top-level containers as they are created. + */ + +@jdk.Exported +public class AWTEventMonitor { + + static private boolean runningOnJDK1_4 = false; + + /** + * The current component with keyboard focus. + * + * @see #getComponentWithFocus + * + * @deprecated This field is unused; to get the component with focus use the + * getComponentWithFocus method. + */ + @Deprecated + static protected Component componentWithFocus = null; + + static private Component componentWithFocus_private = null; + + // Low-level listeners + /** + * The current list of registered ComponentListener classes. + * + * @see #addComponentListener + * @see #removeComponentListener + * + * @deprecated This field is unused. + */ + @Deprecated + static protected ComponentListener componentListener = null; + + static private ComponentListener componentListener_private = null; + + /** + * The current list of registered ContainerListener classes. + * + * @see #addContainerListener + * @see #removeContainerListener + * + * @deprecated This field is unused. + */ + @Deprecated + static protected ContainerListener containerListener = null; + + static private ContainerListener containerListener_private = null; + + /** + * The current list of registered FocusListener classes. + * + * @see #addFocusListener + * @see #removeFocusListener + * + * @deprecated This field is unused. + */ + @Deprecated + static protected FocusListener focusListener = null; + + static private FocusListener focusListener_private = null; + + /** + * The current list of registered KeyListener classes. + * + * @see #addKeyListener + * @see #removeKeyListener + * + * @deprecated This field is unused. + */ + @Deprecated + static protected KeyListener keyListener = null; + + static private KeyListener keyListener_private = null; + + /** + * The current list of registered MouseListener classes. + * + * @see #addMouseListener + * @see #removeMouseListener + * + * @deprecated This field is unused. + */ + @Deprecated + static protected MouseListener mouseListener = null; + + static private MouseListener mouseListener_private = null; + + /** + * The current list of registered MouseMotionListener classes. + * + * @see #addMouseMotionListener + * @see #removeMouseMotionListener + * + * @deprecated This field is unused. + */ + @Deprecated + static protected MouseMotionListener mouseMotionListener = null; + + static private MouseMotionListener mouseMotionListener_private = null; + + /** + * The current list of registered WindowListener classes. + * + * @see #addWindowListener + * @see #removeWindowListener + * + * @deprecated This field is unused. + */ + @Deprecated + static protected WindowListener windowListener = null; + + static private WindowListener windowListener_private = null; + + + // Semantic listeners + /** + * The current list of registered ActionListener classes. + * + * @see #addActionListener + * @see #removeActionListener + * + * @deprecated This field is unused. + */ + @Deprecated + static protected ActionListener actionListener = null; + + static private ActionListener actionListener_private = null; + + /** + * The current list of registered AdjustmentListener classes. + * + * @see #addAdjustmentListener + * @see #removeAdjustmentListener + * + * @deprecated This field is unused. + */ + @Deprecated + static protected AdjustmentListener adjustmentListener = null; + + static private AdjustmentListener adjustmentListener_private = null; + + /** + * The current list of registered ItemListener classes. + * + * @see #addItemListener + * @see #removeItemListener + * + * @deprecated This field is unused. + */ + @Deprecated + static protected ItemListener itemListener = null; + + static private ItemListener itemListener_private = null; + + /** + * The current list of registered TextListener classes. + * + * @see #addTextListener + * @see #removeTextListener + * + * @deprecated This field is unused. + */ + @Deprecated + static protected TextListener textListener = null; + + static private TextListener textListener_private = null; + + + /** + * The actual listener that is installed on the component instances. + * This listener calls the other registered listeners when an event + * occurs. By doing things this way, the actual number of listeners + * installed on a component instance is drastically reduced. + * + * @deprecated This field is unused. + */ + @Deprecated + static protected AWTEventsListener awtListener = new AWTEventsListener(); + + static private final AWTEventsListener awtListener_private = new AWTEventsListener(); + + /** + * Returns the component that currently has keyboard focus. The return + * value can be null. + * + * @return the component that has keyboard focus + */ + static public Component getComponentWithFocus() { + return componentWithFocus_private; + } + + /* + * Check permissions + */ + static private void checkInstallPermission() { + SecurityManager security = System.getSecurityManager(); + if (security != null) { + security.checkPermission(AWT.ALL_AWT_EVENTS_PERMISSION); + } + } + + /** + * Adds the specified listener to receive all {@link EventID#COMPONENT COMPONENT} + * events on each component instance in the Java Virtual Machine as they occur. + *

Note: this listener is automatically added to all component + * instances created after this method is called. In addition, it + * is only added to component instances that support this listener type. + * + * @param l the listener to add + * @see #removeComponentListener + */ + static public void addComponentListener(ComponentListener l) { + if (componentListener_private == null) { + checkInstallPermission(); + awtListener_private.installListeners(EventID.COMPONENT); + } + componentListener_private = AWTEventMulticaster.add(componentListener_private, l); + } + + /** + * Removes the specified listener so it no longer receives + * {@link EventID#COMPONENT COMPONENT} events when they occur. + * + * @param l the listener to remove + * @see #addComponentListener + */ + static public void removeComponentListener(ComponentListener l) { + componentListener_private = AWTEventMulticaster.remove(componentListener_private, l); + if (componentListener_private == null) { + awtListener_private.removeListeners(EventID.COMPONENT); + } + } + + /** + * Adds the specified listener to receive all {@link EventID#CONTAINER CONTAINER} + * events on each component instance in the Java Virtual Machine as they occur. + *

Note: this listener is automatically added to all component + * instances created after this method is called. In addition, it + * is only added to component instances that support this listener type. + * + * @param l the listener to add + * @see #removeContainerListener + */ + static public void addContainerListener(ContainerListener l) { + containerListener_private = AWTEventMulticaster.add(containerListener_private, l); + } + + /** + * Removes the specified listener so it no longer receives + * {@link EventID#CONTAINER CONTAINER} events when they occur. + * + * @param l the listener to remove + * @see #addContainerListener + */ + static public void removeContainerListener(ContainerListener l) { + containerListener_private = AWTEventMulticaster.remove(containerListener_private, l); + } + + /** + * Adds the specified listener to receive all {@link EventID#FOCUS FOCUS} events + * on each component instance in the Java Virtual Machine when they occur. + *

Note: this listener is automatically added to all component + * instances created after this method is called. In addition, it + * is only added to component instances that support this listener type. + * + * @param l the listener to add + * @see #removeFocusListener + */ + static public void addFocusListener(FocusListener l) { + focusListener_private = AWTEventMulticaster.add(focusListener_private, l); + } + + /** + * Removes the specified listener so it no longer receives {@link EventID#FOCUS FOCUS} + * events when they occur. + * + * @param l the listener to remove + * @see #addFocusListener + */ + static public void removeFocusListener(FocusListener l) { + focusListener_private = AWTEventMulticaster.remove(focusListener_private, l); + } + + /** + * Adds the specified listener to receive all {@link EventID#KEY KEY} events on each + * component instance in the Java Virtual Machine when they occur. + *

Note: this listener is automatically added to all component + * instances created after this method is called. In addition, it + * is only added to component instances that support this listener type. + * + * @param l the listener to add + * @see #removeKeyListener + */ + static public void addKeyListener(KeyListener l) { + if (keyListener_private == null) { + checkInstallPermission(); + awtListener_private.installListeners(EventID.KEY); + } + keyListener_private = AWTEventMulticaster.add(keyListener_private, l); + } + + /** + * Removes the specified listener so it no longer receives {@link EventID#KEY KEY} + * events when they occur. + * + * @param l the listener to remove + * @see #addKeyListener + */ + static public void removeKeyListener(KeyListener l) { + keyListener_private = AWTEventMulticaster.remove(keyListener_private, l); + if (keyListener_private == null) { + awtListener_private.removeListeners(EventID.KEY); + } + } + + /** + * Adds the specified listener to receive all {@link EventID#MOUSE MOUSE} events + * on each component instance in the Java Virtual Machine when they occur. + *

Note: this listener is automatically added to all component + * instances created after this method is called. In addition, it + * is only added to component instances that support this listener type. + * + * @param l the listener to add + * @see #removeMouseListener + */ + static public void addMouseListener(MouseListener l) { + if (mouseListener_private == null) { + checkInstallPermission(); + awtListener_private.installListeners(EventID.MOUSE); + } + mouseListener_private = AWTEventMulticaster.add(mouseListener_private, l); + } + + /** + * Removes the specified listener so it no longer receives + * {@link EventID#MOUSE MOUSE} events when they occur. + * + * @param l the listener to remove + * @see #addMouseListener + */ + static public void removeMouseListener(MouseListener l) { + mouseListener_private = AWTEventMulticaster.remove(mouseListener_private, l); + if (mouseListener_private == null) { + awtListener_private.removeListeners(EventID.MOUSE); + } + } + + /** + * Adds the specified listener to receive all mouse {@link EventID#MOTION MOTION} + * events on each component instance in the Java Virtual Machine when they occur. + *

Note: this listener is automatically added to all component + * instances created after this method is called. In addition, it + * is only added to component instances that support this listener type. + * + * @param l the listener to add + * @see #removeMouseMotionListener + */ + static public void addMouseMotionListener(MouseMotionListener l) { + if (mouseMotionListener_private == null) { + checkInstallPermission(); + awtListener_private.installListeners(EventID.MOTION); + } + mouseMotionListener_private = AWTEventMulticaster.add(mouseMotionListener_private, l); + } + + /** + * Removes the specified listener so it no longer receives + * {@link EventID#MOTION MOTION} events when they occur. + * + * @param l the listener to remove + * @see #addMouseMotionListener + */ + static public void removeMouseMotionListener(MouseMotionListener l) { + mouseMotionListener_private = AWTEventMulticaster.remove(mouseMotionListener_private, l); + if (mouseMotionListener_private == null) { + awtListener_private.removeListeners(EventID.MOTION); + } + } + + /** + * Adds the specified listener to receive all {@link EventID#WINDOW WINDOW} + * events on each component instance in the Java Virtual Machine when they occur. + *

Note: this listener is automatically added to all component + * instances created after this method is called. In addition, it + * is only added to component instances that support this listener type. + * + * @param l the listener to add + * @see #removeWindowListener + */ + static public void addWindowListener(WindowListener l) { + if (windowListener_private == null) { + checkInstallPermission(); + awtListener_private.installListeners(EventID.WINDOW); + } + windowListener_private = AWTEventMulticaster.add(windowListener_private, l); + } + + /** + * Removes the specified listener so it no longer receives + * {@link EventID#WINDOW WINDOW} events when they occur. + * + * @param l the listener to remove + * @see #addWindowListener + */ + static public void removeWindowListener(WindowListener l) { + windowListener_private = AWTEventMulticaster.remove(windowListener_private, l); + if (windowListener_private == null) { + awtListener_private.removeListeners(EventID.WINDOW); + } + } + + /** + * Adds the specified listener to receive all {@link EventID#ACTION ACTION} + * events on each component instance in the Java Virtual Machine when they occur. + *

Note: This listener is automatically added to all component + * instances created after this method is called. In addition, it + * is only added to component instances that support this listener type. + * + * @param l the listener to add + * @see #removeActionListener + */ + static public void addActionListener(ActionListener l) { + if (actionListener_private == null) { + checkInstallPermission(); + awtListener_private.installListeners(EventID.ACTION); + } + actionListener_private = AWTEventMulticaster.add(actionListener_private, l); + } + + /** + * Removes the specified listener so it no longer receives + * {@link EventID#ACTION ACTION} events when they occur. + * + * @param l the listener to remove + * @see #addActionListener + */ + static public void removeActionListener(ActionListener l) { + actionListener_private = AWTEventMulticaster.remove(actionListener_private, l); + if (actionListener_private == null) { + awtListener_private.removeListeners(EventID.ACTION); + } + } + + /** + * Adds the specified listener to receive all + * {@link EventID#ADJUSTMENT ADJUSTMENT} events on each component instance + * in the Java Virtual Machine when they occur. + *

Note: this listener is automatically added to all component + * instances created after this method is called. In addition, it + * is only added to component instances that support this listener type. + * + * @param l the listener to add + * @see #removeAdjustmentListener + */ + static public void addAdjustmentListener(AdjustmentListener l) { + if (adjustmentListener_private == null) { + checkInstallPermission(); + awtListener_private.installListeners(EventID.ADJUSTMENT); + } + adjustmentListener_private = AWTEventMulticaster.add(adjustmentListener_private, l); + } + + /** + * Removes the specified listener so it no longer receives + * {@link EventID#ADJUSTMENT ADJUSTMENT} events when they occur. + * + * @param l the listener to remove + * @see #addAdjustmentListener + */ + static public void removeAdjustmentListener(AdjustmentListener l) { + adjustmentListener_private = AWTEventMulticaster.remove(adjustmentListener_private, l); + if (adjustmentListener_private == null) { + awtListener_private.removeListeners(EventID.ADJUSTMENT); + } + } + + /** + * Adds the specified listener to receive all {@link EventID#ITEM ITEM} events + * on each component instance in the Java Virtual Machine when they occur. + *

Note: this listener is automatically added to all component + * instances created after this method is called. In addition, it + * is only added to component instances that support this listener type. + * + * @param l the listener to add + * @see #removeItemListener + */ + static public void addItemListener(ItemListener l) { + if (itemListener_private == null) { + checkInstallPermission(); + awtListener_private.installListeners(EventID.ITEM); + } + itemListener_private = AWTEventMulticaster.add(itemListener_private, l); + } + + /** + * Removes the specified listener so it no longer receives {@link EventID#ITEM ITEM} + * events when they occur. + * + * @param l the listener to remove + * @see #addItemListener + */ + static public void removeItemListener(ItemListener l) { + itemListener_private = AWTEventMulticaster.remove(itemListener_private, l); + if (itemListener_private == null) { + awtListener_private.removeListeners(EventID.ITEM); + } + } + + /** + * Adds the specified listener to receive all {@link EventID#TEXT TEXT} events + * on each component instance in the Java Virtual Machine when they occur. + *

Note: this listener is automatically added to all component + * instances created after this method is called. In addition, it + * is only added to component instances that support this listener type. + * + * @param l the listener to add + * @see #removeTextListener + */ + static public void addTextListener(TextListener l) { + if (textListener_private == null) { + checkInstallPermission(); + awtListener_private.installListeners(EventID.TEXT); + } + textListener_private = AWTEventMulticaster.add(textListener_private, l); + } + + /** + * Removes the specified listener so it no longer receives {@link EventID#TEXT TEXT} + * events when they occur. + * + * @param l the listener to remove + * @see #addTextListener + */ + static public void removeTextListener(TextListener l) { + textListener_private = AWTEventMulticaster.remove(textListener_private, l); + if (textListener_private == null) { + awtListener_private.removeListeners(EventID.TEXT); + } + } + + + /** + * AWTEventsListener is the class that does all the work for AWTEventMonitor. + * It is not intended for use by any other class except AWTEventMonitor. + * + */ + + static class AWTEventsListener implements TopLevelWindowListener, + ActionListener, AdjustmentListener, ComponentListener, + ContainerListener, FocusListener, ItemListener, KeyListener, + MouseListener, MouseMotionListener, TextListener, WindowListener, + ChangeListener { + + /** + * internal variables for Action introspection + */ + private java.lang.Class actionListeners[]; + private java.lang.reflect.Method removeActionMethod; + private java.lang.reflect.Method addActionMethod; + private java.lang.Object actionArgs[]; + + /** + * internal variables for Item introspection + */ + private java.lang.Class itemListeners[]; + private java.lang.reflect.Method removeItemMethod; + private java.lang.reflect.Method addItemMethod; + private java.lang.Object itemArgs[]; + + /** + * internal variables for Text introspection + */ + private java.lang.Class textListeners[]; + private java.lang.reflect.Method removeTextMethod; + private java.lang.reflect.Method addTextMethod; + private java.lang.Object textArgs[]; + + /** + * internal variables for Window introspection + */ + private java.lang.Class windowListeners[]; + private java.lang.reflect.Method removeWindowMethod; + private java.lang.reflect.Method addWindowMethod; + private java.lang.Object windowArgs[]; + + /** + * Create a new instance of this class and install it on each component + * instance in the virtual machine that supports any of the currently + * registered listeners in AWTEventMonitor. Also registers itself + * as a TopLevelWindowListener with EventQueueMonitor so it can + * automatically add new listeners to new components. + * + * @see EventQueueMonitor + * @see AWTEventMonitor + */ + public AWTEventsListener() { + String version = System.getProperty("java.version"); + if (version != null) { + runningOnJDK1_4 = (version.compareTo("1.4") >= 0); + } + initializeIntrospection(); + installListeners(); + if (runningOnJDK1_4) { + MenuSelectionManager.defaultManager().addChangeListener(this); + } + EventQueueMonitor.addTopLevelWindowListener(this); + } + + /** + * Set up all of the variables needed for introspection + */ + private boolean initializeIntrospection() { + try { + actionListeners = new java.lang.Class[1]; + actionArgs = new java.lang.Object[1]; + actionListeners[0] = Class.forName("java.awt.event.ActionListener"); + actionArgs[0] = this; + + itemListeners = new java.lang.Class[1]; + itemArgs = new java.lang.Object[1]; + itemListeners[0] = Class.forName("java.awt.event.ItemListener"); + itemArgs[0] = this; + + textListeners = new java.lang.Class[1]; + textArgs = new java.lang.Object[1]; + textListeners[0] = Class.forName("java.awt.event.TextListener"); + textArgs[0] = this; + + windowListeners = new java.lang.Class[1]; + windowArgs = new java.lang.Object[1]; + windowListeners[0] = Class.forName("java.awt.event.WindowListener"); + windowArgs[0] = this; + + return true; + } catch (ClassNotFoundException e) { + System.out.println("EXCEPTION - Class 'java.awt.event.*' not in CLASSPATH"); + return false; + } + } + + /** + * Installs all currently registered listeners on all components based + * upon the current topLevelWindows cached by EventQueueMonitor. + * @see EventQueueMonitor + * @see AWTEventMonitor + */ + protected void installListeners() { + Window topLevelWindows[] = EventQueueMonitor.getTopLevelWindows(); + if (topLevelWindows != null) { + for (int i = 0; i < topLevelWindows.length; i++) { + installListeners(topLevelWindows[i]); + } + } + } + + /** + * Installs listeners for the given event ID on all components based + * upon the current topLevelWindows cached by EventQueueMonitor. + * @see EventID + * @param eventID the event ID + */ + protected void installListeners(int eventID) { + Window topLevelWindows[] = EventQueueMonitor.getTopLevelWindows(); + if (topLevelWindows != null) { + for (int i = 0; i < topLevelWindows.length; i++) { + installListeners(topLevelWindows[i], eventID); + } + } + } + + /** + * Installs all currently registered listeners to just the component. + * @param c the component to add listeners to + */ + protected void installListeners(Component c) { + + // Container and focus listeners are always installed for our own use. + // + installListeners(c,EventID.CONTAINER); + installListeners(c,EventID.FOCUS); + + // conditionally install low-level listeners + // + if (AWTEventMonitor.componentListener_private != null) { + installListeners(c,EventID.COMPONENT); + } + if (AWTEventMonitor.keyListener_private != null) { + installListeners(c,EventID.KEY); + } + if (AWTEventMonitor.mouseListener_private != null) { + installListeners(c,EventID.MOUSE); + } + if (AWTEventMonitor.mouseMotionListener_private != null) { + installListeners(c,EventID.MOTION); + } + if (AWTEventMonitor.windowListener_private != null) { + installListeners(c,EventID.WINDOW); + } + + // conditionally install Semantic listeners + // + if (AWTEventMonitor.actionListener_private != null) { + installListeners(c,EventID.ACTION); + } + if (AWTEventMonitor.adjustmentListener_private != null) { + installListeners(c,EventID.ADJUSTMENT); + } + if (AWTEventMonitor.itemListener_private != null) { + installListeners(c,EventID.ITEM); + } + if (AWTEventMonitor.textListener_private != null) { + installListeners(c,EventID.TEXT); + } + } + + public void stateChanged(ChangeEvent e) { + processFocusGained(); + } + + private void processFocusGained() { + Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); + if (focusOwner == null) { + return; + } + MenuSelectionManager.defaultManager().removeChangeListener(this); + MenuSelectionManager.defaultManager().addChangeListener(this); + + // Only menus and popup selections are handled by the JRootPane. + if (focusOwner instanceof JRootPane) { + MenuElement [] path = + MenuSelectionManager.defaultManager().getSelectedPath(); + if (path.length > 1) { + Component penult = path[path.length-2].getComponent(); + Component last = path[path.length-1].getComponent(); + + if (last instanceof JPopupMenu || + last instanceof JMenu) { + // This is a popup with nothing in the popup + // selected. The menu itself is selected. + componentWithFocus_private = last; + } else if (penult instanceof JPopupMenu) { + // This is a popup with an item selected + componentWithFocus_private = penult; + } + } + } else { + // The focus owner has the selection. + componentWithFocus_private = focusOwner; + } + } + + /** + * Installs the given listener on the component and any of its children. + * As a precaution, it always attempts to remove itself as a listener + * first so it's always guaranteed to have installed itself just once. + * @param c the component to add listeners to + * @param eventID the eventID to add listeners for + * @see EventID + */ + protected void installListeners(Component c, int eventID) { + + // install the appropriate listener hook into this component + // + switch (eventID) { + + case EventID.ACTION: + try { + removeActionMethod = c.getClass().getMethod( + "removeActionListener", actionListeners); + addActionMethod = c.getClass().getMethod( + "addActionListener", actionListeners); + try { + removeActionMethod.invoke(c, actionArgs); + addActionMethod.invoke(c, actionArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + case EventID.ADJUSTMENT: + if (c instanceof Adjustable) { + ((Adjustable) c).removeAdjustmentListener(this); + ((Adjustable) c).addAdjustmentListener(this); + } + break; + + case EventID.COMPONENT: + c.removeComponentListener(this); + c.addComponentListener(this); + break; + + case EventID.CONTAINER: + if (c instanceof Container) { + ((Container) c).removeContainerListener(this); + ((Container) c).addContainerListener(this); + } + break; + + case EventID.FOCUS: + c.removeFocusListener(this); + c.addFocusListener(this); + + if (runningOnJDK1_4) { + processFocusGained(); + + } else { // not runningOnJDK1_4 + if ((c != componentWithFocus_private) && c.hasFocus()) { + componentWithFocus_private = c; + } + } + break; + + case EventID.ITEM: + try { + removeItemMethod = c.getClass().getMethod( + "removeItemListener", itemListeners); + addItemMethod = c.getClass().getMethod( + "addItemListener", itemListeners); + try { + removeItemMethod.invoke(c, itemArgs); + addItemMethod.invoke(c, itemArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + // [PK] CheckboxMenuItem isn't a component but it does + // implement Interface ItemSelectable!! + // if (c instanceof CheckboxMenuItem) { + // ((CheckboxMenuItem) c).removeItemListener(this); + // ((CheckboxMenuItem) c).addItemListener(this); + break; + + case EventID.KEY: + c.removeKeyListener(this); + c.addKeyListener(this); + break; + + case EventID.MOUSE: + c.removeMouseListener(this); + c.addMouseListener(this); + break; + + case EventID.MOTION: + c.removeMouseMotionListener(this); + c.addMouseMotionListener(this); + break; + + case EventID.TEXT: + try { + removeTextMethod = c.getClass().getMethod( + "removeTextListener", textListeners); + addTextMethod = c.getClass().getMethod( + "addTextListener", textListeners); + try { + removeTextMethod.invoke(c, textArgs); + addTextMethod.invoke(c, textArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + case EventID.WINDOW: + try { + removeWindowMethod = c.getClass().getMethod( + "removeWindowListener", windowListeners); + addWindowMethod = c.getClass().getMethod( + "addWindowListener", windowListeners); + try { + removeWindowMethod.invoke(c, windowArgs); + addWindowMethod.invoke(c, windowArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + // Don't bother recursing the children if this isn't going to + // accomplish anything. + // + default: + return; + } + + // if this component is a container, recurse through children + // + if (c instanceof Container) { + int count = ((Container) c).getComponentCount(); + for (int i = 0; i < count; i++) { + installListeners(((Container) c).getComponent(i), eventID); + } + } + } + + /** + * Removes all listeners for the given event ID on all components based + * upon the topLevelWindows cached by EventQueueMonitor. + * @param eventID the event ID + * @see EventID + */ + protected void removeListeners(int eventID) { + Window topLevelWindows[] = EventQueueMonitor.getTopLevelWindows(); + if (topLevelWindows != null) { + for (int i = 0; i < topLevelWindows.length; i++) { + removeListeners(topLevelWindows[i], eventID); + } + } + } + + /** + * Removes all listeners for the given component and all its children. + * @param c the component + */ + protected void removeListeners(Component c) { + + // conditionally remove low-level listeners + // + if (AWTEventMonitor.componentListener_private != null) { + removeListeners(c,EventID.COMPONENT); + } + if (AWTEventMonitor.keyListener_private != null) { + removeListeners(c,EventID.KEY); + } + if (AWTEventMonitor.mouseListener_private != null) { + removeListeners(c,EventID.MOUSE); + } + if (AWTEventMonitor.mouseMotionListener_private != null) { + removeListeners(c,EventID.MOTION); + } + if (AWTEventMonitor.windowListener_private != null) { + removeListeners(c,EventID.WINDOW); + } + + // Remove semantic listeners + // + if (AWTEventMonitor.actionListener_private != null) { + removeListeners(c,EventID.ACTION); + } + if (AWTEventMonitor.adjustmentListener_private != null) { + removeListeners(c,EventID.ADJUSTMENT); + } + if (AWTEventMonitor.itemListener_private != null) { + removeListeners(c,EventID.ITEM); + } + if (AWTEventMonitor.textListener_private != null) { + removeListeners(c,EventID.TEXT); + } + } + + /** + * Removes all listeners for the event ID from the component and all + * of its children. + * @param c the component to remove listeners from + * @see EventID + */ + protected void removeListeners(Component c, int eventID) { + + // remove the appropriate listener hook into this component + // + switch (eventID) { + + case EventID.ACTION: + try { + removeActionMethod = c.getClass().getMethod( + "removeActionListener", + actionListeners); + try { + removeActionMethod.invoke(c, actionArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + case EventID.ADJUSTMENT: + if (c instanceof Adjustable) { + ((Adjustable) c).removeAdjustmentListener(this); + } + break; + + case EventID.COMPONENT: + c.removeComponentListener(this); + break; + + // Never remove these because we're always interested in them + // for our own use. + //case EventID.CONTAINER: + // if (c instanceof Container) { + // ((Container) c).removeContainerListener(this); + // } + // break; + // + //case EventID.FOCUS: + // c.removeFocusListener(this); + // break; + + case EventID.ITEM: + try { + removeItemMethod = c.getClass().getMethod( + "removeItemListener", itemListeners); + try { + removeItemMethod.invoke(c, itemArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + // [PK] CheckboxMenuItem isn't a component but it does + // implement Interface ItemSelectable!! + // if (c instanceof CheckboxMenuItem) { + // ((CheckboxMenuItem) c).removeItemListener(this); + break; + + case EventID.KEY: + c.removeKeyListener(this); + break; + + case EventID.MOUSE: + c.removeMouseListener(this); + break; + + case EventID.MOTION: + c.removeMouseMotionListener(this); + break; + + case EventID.TEXT: + try { + removeTextMethod = c.getClass().getMethod( + "removeTextListener", textListeners); + try { + removeTextMethod.invoke(c, textArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + case EventID.WINDOW: + try { + removeWindowMethod = c.getClass().getMethod( + "removeWindowListener", windowListeners); + try { + removeWindowMethod.invoke(c, windowArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + default: + return; + } + + if (c instanceof Container) { + int count = ((Container) c).getComponentCount(); + for (int i = 0; i < count; i++) { + removeListeners(((Container) c).getComponent(i), eventID); + } + } + } + + /********************************************************************/ + /* */ + /* Listener Interface Methods */ + /* */ + /********************************************************************/ + + /* TopLevelWindow Methods ***************************************/ + + /** + * Called when top level window is created. + * @see EventQueueMonitor + * @see EventQueueMonitor#addTopLevelWindowListener + */ + public void topLevelWindowCreated(Window w) { + installListeners(w); + } + + /** + * Called when top level window is destroyed. + * @see EventQueueMonitor + * @see EventQueueMonitor#addTopLevelWindowListener + */ + public void topLevelWindowDestroyed(Window w) { + } + + /* ActionListener Methods ***************************************/ + + /** + * Called when an action is performed. + * @see AWTEventMonitor#addActionListener + */ + public void actionPerformed(ActionEvent e) { + if (AWTEventMonitor.actionListener_private != null) { + AWTEventMonitor.actionListener_private.actionPerformed(e); + } + } + + /* AdjustmentListener Methods ***********************************/ + + /** + * Called when an adjustment is made. + * @see AWTEventMonitor#addAdjustmentListener + */ + public void adjustmentValueChanged(AdjustmentEvent e) { + if (AWTEventMonitor.adjustmentListener_private != null) { + AWTEventMonitor.adjustmentListener_private.adjustmentValueChanged(e); + } + } + + /* ComponentListener Methods ************************************/ + + /** + * Called when a component is hidden. + * @see AWTEventMonitor#addComponentListener + */ + public void componentHidden(ComponentEvent e) { + if (AWTEventMonitor.componentListener_private != null) { + AWTEventMonitor.componentListener_private.componentHidden(e); + } + } + + /** + * Called when a component is moved. + * @see AWTEventMonitor#addComponentListener + */ + public void componentMoved(ComponentEvent e) { + if (AWTEventMonitor.componentListener_private != null) { + AWTEventMonitor.componentListener_private.componentMoved(e); + } + } + + /** + * Called when a component is resized. + * @see AWTEventMonitor#addComponentListener + */ + public void componentResized(ComponentEvent e) { + if (AWTEventMonitor.componentListener_private != null) { + AWTEventMonitor.componentListener_private.componentResized(e); + } + } + + /** + * Called when a component is shown. + * @see AWTEventMonitor#addComponentListener + */ + public void componentShown(ComponentEvent e) { + if (AWTEventMonitor.componentListener_private != null) { + AWTEventMonitor.componentListener_private.componentShown(e); + } + } + + /* ContainerListener Methods ************************************/ + + /** + * Called when a component is added to a container. + * @see AWTEventMonitor#addContainerListener + */ + public void componentAdded(ContainerEvent e) { + installListeners(e.getChild()); + if (AWTEventMonitor.containerListener_private != null) { + AWTEventMonitor.containerListener_private.componentAdded(e); + } + } + + /** + * Called when a component is removed from a container. + * @see AWTEventMonitor#addContainerListener + */ + public void componentRemoved(ContainerEvent e) { + removeListeners(e.getChild()); + if (AWTEventMonitor.containerListener_private != null) { + AWTEventMonitor.containerListener_private.componentRemoved(e); + } + } + + /* FocusListener Methods ****************************************/ + + /** + * Called when a component gains keyboard focus. + * @see AWTEventMonitor#addFocusListener + */ + public void focusGained(FocusEvent e) { + AWTEventMonitor.componentWithFocus_private = (Component) e.getSource(); + if (AWTEventMonitor.focusListener_private != null) { + AWTEventMonitor.focusListener_private.focusGained(e); + } + } + + /** + * Called when a component loses keyboard focus. + * @see AWTEventMonitor#addFocusListener + */ + public void focusLost(FocusEvent e) { + AWTEventMonitor.componentWithFocus_private = null; + if (AWTEventMonitor.focusListener_private != null) { + AWTEventMonitor.focusListener_private.focusLost(e); + } + } + + /* ItemListener Methods *****************************************/ + + /** + * Called when an item's state changes. + * @see AWTEventMonitor#addItemListener + */ + public void itemStateChanged(ItemEvent e) { + if (AWTEventMonitor.itemListener_private != null) { + AWTEventMonitor.itemListener_private.itemStateChanged(e); + } + } + + /* KeyListener Methods ******************************************/ + + /** + * Called when a key is pressed. + * @see AWTEventMonitor#addKeyListener + */ + public void keyPressed(KeyEvent e) { + if (AWTEventMonitor.keyListener_private != null) { + AWTEventMonitor.keyListener_private.keyPressed(e); + } + } + + /** + * Called when a key is typed. + * @see AWTEventMonitor#addKeyListener + */ + public void keyReleased(KeyEvent e) { + if (AWTEventMonitor.keyListener_private != null) { + AWTEventMonitor.keyListener_private.keyReleased(e); + } + } + + /** + * Called when a key is released. + * @see AWTEventMonitor#addKeyListener + */ + public void keyTyped(KeyEvent e) { + if (AWTEventMonitor.keyListener_private != null) { + AWTEventMonitor.keyListener_private.keyTyped(e); + } + } + + /* MouseListener Methods ****************************************/ + + /** + * Called when the mouse is clicked. + * @see AWTEventMonitor#addMouseListener + */ + public void mouseClicked(MouseEvent e) { + if (AWTEventMonitor.mouseListener_private != null) { + AWTEventMonitor.mouseListener_private.mouseClicked(e); + } + } + + /** + * Called when the mouse enters a component. + * @see AWTEventMonitor#addMouseListener + */ + public void mouseEntered(MouseEvent e) { + if (AWTEventMonitor.mouseListener_private != null) { + AWTEventMonitor.mouseListener_private.mouseEntered(e); + } + } + + /** + * Called when the mouse leaves a component. + * @see AWTEventMonitor#addMouseListener + */ + public void mouseExited(MouseEvent e) { + if (AWTEventMonitor.mouseListener_private != null) { + AWTEventMonitor.mouseListener_private.mouseExited(e); + } + } + + /** + * Called when the mouse is pressed. + * @see AWTEventMonitor#addMouseListener + */ + public void mousePressed(MouseEvent e) { + if (AWTEventMonitor.mouseListener_private != null) { + AWTEventMonitor.mouseListener_private.mousePressed(e); + } + } + + /** + * Called when the mouse is released. + * @see AWTEventMonitor#addMouseListener + */ + public void mouseReleased(MouseEvent e) { + if (AWTEventMonitor.mouseListener_private != null) { + AWTEventMonitor.mouseListener_private.mouseReleased(e); + } + } + + /* MouseMotionListener Methods **********************************/ + + /** + * Called when the mouse is dragged. + * @see AWTEventMonitor#addMouseMotionListener + */ + public void mouseDragged(MouseEvent e) { + if (AWTEventMonitor.mouseMotionListener_private != null) { + AWTEventMonitor.mouseMotionListener_private.mouseDragged(e); + } + } + + /** + * Called when the mouse is moved. + * @see AWTEventMonitor#addMouseMotionListener + */ + public void mouseMoved(MouseEvent e) { + if (AWTEventMonitor.mouseMotionListener_private != null) { + AWTEventMonitor.mouseMotionListener_private.mouseMoved(e); + } + } + + /* TextListener Methods *****************************************/ + + /** + * Called when a component's text value changed. + * @see AWTEventMonitor#addTextListener + */ + public void textValueChanged(TextEvent e) { + if (AWTEventMonitor.textListener_private != null) { + AWTEventMonitor.textListener_private.textValueChanged(e); + } + } + + /* WindowListener Methods ***************************************/ + + /** + * Called when a window is opened. + * @see AWTEventMonitor#addWindowListener + */ + public void windowOpened(WindowEvent e) { + if (AWTEventMonitor.windowListener_private != null) { + AWTEventMonitor.windowListener_private.windowOpened(e); + } + } + + /** + * Called when a window is in the process of closing. + * @see AWTEventMonitor#addWindowListener + */ + public void windowClosing(WindowEvent e) { + if (AWTEventMonitor.windowListener_private != null) { + AWTEventMonitor.windowListener_private.windowClosing(e); + } + } + + /** + * Called when a window is closed. + * @see AWTEventMonitor#addWindowListener + */ + public void windowClosed(WindowEvent e) { + if (AWTEventMonitor.windowListener_private != null) { + AWTEventMonitor.windowListener_private.windowClosed(e); + } + } + + /** + * Called when a window is iconified. + * @see AWTEventMonitor#addWindowListener + */ + public void windowIconified(WindowEvent e) { + if (AWTEventMonitor.windowListener_private != null) { + AWTEventMonitor.windowListener_private.windowIconified(e); + } + } + + /** + * Called when a window is deiconified. + * @see AWTEventMonitor#addWindowListener + */ + public void windowDeiconified(WindowEvent e) { + if (AWTEventMonitor.windowListener_private != null) { + AWTEventMonitor.windowListener_private.windowDeiconified(e); + } + } + + /** + * Called when a window is activated. + * @see AWTEventMonitor#addWindowListener + */ + public void windowActivated(WindowEvent e) { + if (AWTEventMonitor.windowListener_private != null) { + AWTEventMonitor.windowListener_private.windowActivated(e); + } + } + + /** + * Called when a window is deactivated. + * @see AWTEventMonitor#addWindowListener + */ + public void windowDeactivated(WindowEvent e) { + if (AWTEventMonitor.windowListener_private != null) { + AWTEventMonitor.windowListener_private.windowDeactivated(e); + } + } + } +} diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/java/accessibility/util/AccessibilityEventMonitor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/java/accessibility/util/AccessibilityEventMonitor.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,376 @@ +/* + * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.java.accessibility.util; + +import java.util.*; +import java.beans.*; +import java.awt.*; +import java.awt.event.*; +import javax.accessibility.*; + +/** + *

{@code AccessibilityEventMonitor} implements a PropertyChange listener + * on every UI object that implements interface {@code Accessible} in the Java + * Virtual Machine. The events captured by these listeners are made available + * through listeners supported by {@code AccessibilityEventMonitor}. + * With this, all the individual events on each of the UI object + * instances are funneled into one set of PropertyChange listeners. + *

This class depends upon {@link EventQueueMonitor}, which provides the base + * level support for capturing the top-level containers as they are created. + * + */ + +@jdk.Exported +public class AccessibilityEventMonitor { + + // listeners + /** + * The current list of registered {@link java.beans.PropertyChangeListener + * PropertyChangeListener} classes. + * + * @see #addPropertyChangeListener + * @see #removePropertyChangeListener + */ + static protected final AccessibilityListenerList listenerList = + new AccessibilityListenerList(); + + + /** + * The actual listener that is installed on the component instances. + * This listener calls the other registered listeners when an event + * occurs. By doing things this way, the actual number of listeners + * installed on a component instance is drastically reduced. + */ + static protected final AccessibilityEventListener accessibilityListener = + new AccessibilityEventListener(); + + /** + * Adds the specified listener to receive all PropertyChange events on + * each UI object instance in the Java Virtual Machine as they occur. + *

Note: This listener is automatically added to all component + * instances created after this method is called. In addition, it + * is only added to UI object instances that support this listener type. + * + * @param l the listener to add + * + * @see #removePropertyChangeListener + */ + static public void addPropertyChangeListener(PropertyChangeListener l) { + if (listenerList.getListenerCount(PropertyChangeListener.class) == 0) { + accessibilityListener.installListeners(); + } + listenerList.add(PropertyChangeListener.class, l); + } + + /** + * Removes the specified listener so it no longer receives PropertyChange + * events when they occur. + * @see #addPropertyChangeListener + * @param l the listener to remove + */ + static public void removePropertyChangeListener(PropertyChangeListener l) { + listenerList.remove(PropertyChangeListener.class, l); + if (listenerList.getListenerCount(PropertyChangeListener.class) == 0) { + accessibilityListener.removeListeners(); + } + } + + + /** + * AccessibilityEventListener is the class that does all the work for + * AccessibilityEventMonitor. It is not intended for use by any other + * class except AccessibilityEventMonitor. + * + */ + + static class AccessibilityEventListener implements TopLevelWindowListener, + PropertyChangeListener { + + /** + * Create a new instance of this class and install it on each component + * instance in the virtual machine that supports any of the currently + * registered listeners in AccessibilityEventMonitor. Also registers + * itself as a TopLevelWindowListener with EventQueueMonitor so it can + * automatically add new listeners to new components. + * @see EventQueueMonitor + * @see AccessibilityEventMonitor + */ + public AccessibilityEventListener() { + EventQueueMonitor.addTopLevelWindowListener(this); + } + + /** + * Installs PropertyChange listeners on all Accessible objects based + * upon the current topLevelWindows cached by EventQueueMonitor. + * @see EventQueueMonitor + * @see AWTEventMonitor + */ + protected void installListeners() { + Window topLevelWindows[] = EventQueueMonitor.getTopLevelWindows(); + if (topLevelWindows != null) { + for (int i = 0; i < topLevelWindows.length; i++) { + if (topLevelWindows[i] instanceof Accessible) { + installListeners((Accessible) topLevelWindows[i]); + } + } + } + } + + /** + * Installs PropertyChange listeners to the Accessible object, and it's + * children (so long as the object isn't of TRANSIENT state). + * @param a the Accessible object to add listeners to + */ + protected void installListeners(Accessible a) { + installListeners(a.getAccessibleContext()); + } + + /** + * Installs PropertyChange listeners to the AccessibleContext object, + * and it's * children (so long as the object isn't of TRANSIENT state). + * @param a the Accessible object to add listeners to + */ + private void installListeners(AccessibleContext ac) { + + if (ac != null) { + AccessibleStateSet states = ac.getAccessibleStateSet(); + if (!states.contains(AccessibleState.TRANSIENT)) { + ac.addPropertyChangeListener(this); + /* + * Don't add listeners to transient children. Components + * with transient children should return an AccessibleStateSet + * containing AccessibleState.MANAGES_DESCENDANTS. Components + * may not explicitly return the MANAGES_DESCENDANTS state. + * In this case, don't add listeners to the children of + * lists, tables and trees. + */ + AccessibleStateSet set = ac.getAccessibleStateSet(); + if (set.contains(_AccessibleState.MANAGES_DESCENDANTS)) { + return; + } + AccessibleRole role = ac.getAccessibleRole(); + if (role == AccessibleRole.LIST || + role == AccessibleRole.TREE) { + return; + } + if (role == AccessibleRole.TABLE) { + // handle Oracle tables containing tables + Accessible child = ac.getAccessibleChild(0); + if (child != null) { + AccessibleContext ac2 = child.getAccessibleContext(); + if (ac2 != null) { + role = ac2.getAccessibleRole(); + if (role != null && role != AccessibleRole.TABLE) { + return; + } + } + } + } + int count = ac.getAccessibleChildrenCount(); + for (int i = 0; i < count; i++) { + Accessible child = ac.getAccessibleChild(i); + if (child != null) { + installListeners(child); + } + } + } + } + } + + /** + * Removes PropertyChange listeners on all Accessible objects based + * upon the topLevelWindows cached by EventQueueMonitor. + * @param eventID the event ID + * @see EventID + */ + protected void removeListeners() { + Window topLevelWindows[] = EventQueueMonitor.getTopLevelWindows(); + if (topLevelWindows != null) { + for (int i = 0; i < topLevelWindows.length; i++) { + if (topLevelWindows[i] instanceof Accessible) { + removeListeners((Accessible) topLevelWindows[i]); + } + } + } + } + + /** + * Removes PropertyChange listeners for the given Accessible object, + * it's children (so long as the object isn't of TRANSIENT state). + * @param a the Accessible object to remove listeners from + */ + protected void removeListeners(Accessible a) { + removeListeners(a.getAccessibleContext()); + } + + /** + * Removes PropertyChange listeners for the given AccessibleContext + * object, it's children (so long as the object isn't of TRANSIENT + * state). + * @param a the Accessible object to remove listeners from + */ + private void removeListeners(AccessibleContext ac) { + + + if (ac != null) { + // Listeners are not added to transient components. + AccessibleStateSet states = ac.getAccessibleStateSet(); + if (!states.contains(AccessibleState.TRANSIENT)) { + ac.removePropertyChangeListener(this); + /* + * Listeners are not added to transient children. Components + * with transient children should return an AccessibleStateSet + * containing AccessibleState.MANAGES_DESCENDANTS. Components + * may not explicitly return the MANAGES_DESCENDANTS state. + * In this case, don't remove listeners from the children of + * lists, tables and trees. + */ + if (states.contains(_AccessibleState.MANAGES_DESCENDANTS)) { + return; + } + AccessibleRole role = ac.getAccessibleRole(); + if (role == AccessibleRole.LIST || + role == AccessibleRole.TABLE || + role == AccessibleRole.TREE) { + return; + } + int count = ac.getAccessibleChildrenCount(); + for (int i = 0; i < count; i++) { + Accessible child = ac.getAccessibleChild(i); + if (child != null) { + removeListeners(child); + } + } + } + } + } + + /********************************************************************/ + /* */ + /* Listener Interface Methods */ + /* */ + /********************************************************************/ + + /* TopLevelWindow Methods ***************************************/ + + /** + * Called when top level window is created. + * @see EventQueueMonitor + * @see EventQueueMonitor#addTopLevelWindowListener + */ + public void topLevelWindowCreated(Window w) { + if (w instanceof Accessible) { + installListeners((Accessible) w); + } + } + + /** + * Called when top level window is destroyed. + * @see EventQueueMonitor + * @see EventQueueMonitor#addTopLevelWindowListener + */ + public void topLevelWindowDestroyed(Window w) { + if (w instanceof Accessible) { + removeListeners((Accessible) w); + } + } + + + /* PropertyChangeListener Methods **************************************/ + + public void propertyChange(PropertyChangeEvent e) { + // propogate the event + Object[] listeners = + AccessibilityEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==PropertyChangeListener.class) { + ((PropertyChangeListener)listeners[i+1]).propertyChange(e); + } + } + + // handle childbirth/death + String name = e.getPropertyName(); + if (name.compareTo(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY) == 0) { + Object oldValue = e.getOldValue(); + Object newValue = e.getNewValue(); + + if ((oldValue == null) ^ (newValue == null)) { // one null, not both + if (oldValue != null) { + // this Accessible is a child that's going away + if (oldValue instanceof Accessible) { + Accessible a = (Accessible) oldValue; + removeListeners(a.getAccessibleContext()); + } else if (oldValue instanceof AccessibleContext) { + removeListeners((AccessibleContext) oldValue); + } + } else if (newValue != null) { + // this Accessible is a child was just born + if (newValue instanceof Accessible) { + Accessible a = (Accessible) newValue; + installListeners(a.getAccessibleContext()); + } else if (newValue instanceof AccessibleContext) { + installListeners((AccessibleContext) newValue); + } + } + } else { + System.out.println("ERROR in usage of PropertyChangeEvents for: " + e.toString()); + } + } + } + } +} + +/* + * workaround for no public AccessibleState constructor + */ +class _AccessibleState extends AccessibleState { + /** + * Indicates this object is responsible for managing its + * subcomponents. This is typically used for trees and tables + * that have a large number of subcomponents and where the + * objects are created only when needed and otherwise remain virtual. + * The application should not manage the subcomponents directly. + */ + public static final _AccessibleState MANAGES_DESCENDANTS + = new _AccessibleState ("managesDescendants"); + + /** + * Creates a new AccessibleState using the given locale independent key. + * This should not be a public method. Instead, it is used to create + * the constants in this file to make it a strongly typed enumeration. + * Subclasses of this class should enforce similar policy. + *

+ * The key String should be a locale independent key for the state. + * It is not intended to be used as the actual String to display + * to the user. To get the localized string, use toDisplayString. + * + * @param key the locale independent name of the state. + * @see AccessibleBundle#toDisplayString + */ + protected _AccessibleState(String key) { + super(key); + } +} diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/java/accessibility/util/AccessibilityListenerList.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/java/accessibility/util/AccessibilityListenerList.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.java.accessibility.util; + +import java.util.*; +import java.beans.*; +import java.awt.*; +import java.awt.event.*; +import javax.accessibility.*; + +/** + *

The {@code AccessibilityListenerList} is a copy of the Swing + * {@link javax.swing.event.EventListenerList EventListerList} class. + * + */ + +@jdk.Exported +public class AccessibilityListenerList { + /* A null array to be shared by all empty listener lists */ + private final static Object[] NULL_ARRAY = new Object[0]; + + /** + * The list of listener type, listener pairs + */ + protected transient Object[] listenerList = NULL_ARRAY; + + /** + * Passes back the event listener list as an array of listener type, listener pairs. + * Note that for performance reasons, this implementation passes back the actual + * data structure in which the listener data is stored internally. This method + * is guaranteed to pass back a non-null array, so that no null-checking + * is required in fire methods. A zero-length array of Object is returned if + * there are currently no listeners. + *

+ * Absolutely no modification of the data contained in this array should be + * made. If any such manipulation is necessary, it should be done on a copy + * of the array returned rather than the array itself. + * + * @return an array of listener type, listener pairs. + */ + public Object[] getListenerList() { + return listenerList; + } + + /** + * Returns the total number of listeners for this listener list. + * + * @return the total number of listeners for this listener list. + */ + public int getListenerCount() { + return listenerList.length/2; + } + + /** + * Return the total number of listeners of the supplied type + * for this listener list. + * + * @param t the type of the listener to be counted + * @return the number of listeners found + */ + public int getListenerCount(Class t) { + int count = 0; + Object[] lList = listenerList; + for (int i = 0; i < lList.length; i+=2) { + if (t == (Class)lList[i]) + count++; + } + return count; + } + + /** + * Add the listener as a listener of the specified type. + * + * @param t the type of the listener to be added + * @param l the listener to be added + */ + public synchronized void add(Class t, EventListener l) { + if (!t.isInstance(l)) { + throw new IllegalArgumentException("Listener " + l + + " is not of type " + t); + } + if (l ==null) { + throw new IllegalArgumentException("Listener " + l + + " is null"); + } + if (listenerList == NULL_ARRAY) { + // if this is the first listener added, + // initialize the lists + listenerList = new Object[] { t, l }; + } else { + // Otherwise copy the array and add the new listener + int i = listenerList.length; + Object[] tmp = new Object[i+2]; + System.arraycopy(listenerList, 0, tmp, 0, i); + + tmp[i] = t; + tmp[i+1] = l; + + listenerList = tmp; + } + } + + /** + * Remove the listener as a listener of the specified type. + * + * @param t the type of the listener to be removed + * @param l the listener to be removed + */ + public synchronized void remove(Class t, EventListener l) { + if (!t.isInstance(l)) { + throw new IllegalArgumentException("Listener " + l + + " is not of type " + t); + } + if (l ==null) { + throw new IllegalArgumentException("Listener " + l + + " is null"); + } + + // Is l on the list? + int index = -1; + for (int i = listenerList.length-2; i>=0; i-=2) { + if ((listenerList[i]==t) && (listenerList[i+1] == l)) { + index = i; + break; + } + } + + // If so, remove it + if (index != -1) { + Object[] tmp = new Object[listenerList.length-2]; + // Copy the list up to index + System.arraycopy(listenerList, 0, tmp, 0, index); + // Copy from two past the index, up to + // the end of tmp (which is two elements + // shorter than the old list) + if (index < tmp.length) + System.arraycopy(listenerList, index+2, tmp, index, + tmp.length - index); + // set the listener array to the new array or null + listenerList = (tmp.length == 0) ? NULL_ARRAY : tmp; + } + } + + /** + * Return a string representation of the {@code AccessibilityListenerList}. + * + * @return a string representation of the {@code AccessibilityListenerList}. + */ + public String toString() { + Object[] lList = listenerList; + String s = "EventListenerList: "; + s += lList.length/2 + " listeners: "; + for (int i = 0 ; i <= lList.length-2 ; i+=2) { + s += " type " + ((Class)lList[i]).getName(); + s += " listener " + lList[i+1]; + } + return s; + } +} diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/java/accessibility/util/EventID.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/java/accessibility/util/EventID.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,206 @@ +/* + * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.java.accessibility.util; + +/** + * EventID contains integer constants that map to event support in + * AWT and Swing. They are used by primarily by AWTEventMonitor, + * AWTEventsListener, SwingEventMonitor, and SwingEventListener, but + * can be freely used by any other class. + * + * @see AWTEventMonitor + * @see SwingEventMonitor + * + */ +@jdk.Exported +public class EventID { + + /** + * Maps to AWT Action support (i.e., ActionListener and ActionEvent) + */ + static public final int ACTION = 0; + + /** + * Maps to AWT Adjustment support (i.e., AdjustmentListener + * and AdjustmentEvent) + */ + static public final int ADJUSTMENT = 1; + + /** + * Maps to AWT Component support (i.e., ComponentListener + * and ComponentEvent) + */ + static public final int COMPONENT = 2; + + /** + * Maps to AWT Container support (i.e., ContainerListener + * and ContainerEvent) + */ + static public final int CONTAINER = 3; + + /** + * Maps to AWT Focus support (i.e., FocusListener and FocusEvent) + */ + static public final int FOCUS = 4; + + /** + * Maps to AWT Item support (i.e., ItemListener and ItemEvent) + */ + static public final int ITEM = 5; + + /** + * Maps to AWT Key support (i.e., KeyListener and KeyEvent) + */ + static public final int KEY = 6; + + /** + * Maps to AWT Mouse support (i.e., MouseListener and MouseEvent) + */ + static public final int MOUSE = 7; + + /** + * Maps to AWT MouseMotion support (i.e., MouseMotionListener + * and MouseMotionEvent) + */ + static public final int MOTION = 8; + + /** + * Maps to AWT Text support (i.e., TextListener and TextEvent) + */ + static public final int TEXT = 10; + + /** + * Maps to AWT Window support (i.e., WindowListener and WindowEvent) + */ + static public final int WINDOW = 11; + + /** + * Maps to Swing Ancestor support (i.e., AncestorListener and + * AncestorEvent) + */ + static public final int ANCESTOR = 12; + + /** + * Maps to Swing Text Caret support (i.e., CaretListener and + * CaretEvent) + */ + static public final int CARET = 13; + + /** + * Maps to Swing CellEditor support (i.e., CellEditorListener and + * CellEditorEvent) + */ + static public final int CELLEDITOR = 14; + + /** + * Maps to Swing Change support (i.e., ChangeListener and + * ChangeEvent) + */ + static public final int CHANGE = 15; + + /** + * Maps to Swing TableColumnModel support (i.e., + * TableColumnModelListener and TableColumnModelEvent) + */ + static public final int COLUMNMODEL = 16; + + /** + * Maps to Swing Document support (i.e., DocumentListener and + * DocumentEvent) + */ + static public final int DOCUMENT = 17; + + /** + * Maps to Swing ListData support (i.e., ListDataListener and + * ListDataEvent) + */ + static public final int LISTDATA = 18; + + /** + * Maps to Swing ListSelection support (i.e., ListSelectionListener and + * ListSelectionEvent) + */ + static public final int LISTSELECTION = 19; + + /** + * Maps to Swing Menu support (i.e., MenuListener and + * MenuEvent) + */ + static public final int MENU = 20; + + /** + * Maps to Swing PopupMenu support (i.e., PopupMenuListener and + * PopupMenuEvent) + */ + static public final int POPUPMENU = 21; + + /** + * Maps to Swing TableModel support (i.e., TableModelListener and + * TableModelEvent) + */ + static public final int TABLEMODEL = 22; + + /** + * Maps to Swing TreeExpansion support (i.e., TreeExpansionListener and + * TreeExpansionEvent) + */ + static public final int TREEEXPANSION = 23; + + /** + * Maps to Swing TreeModel support (i.e., TreeModelListener and + * TreeModelEvent) + */ + static public final int TREEMODEL = 24; + + /** + * Maps to Swing TreeSelection support (i.e., TreeSelectionListener and + * TreeSelectionEvent) + */ + static public final int TREESELECTION = 25; + + /** + * Maps to Swing UndoableEdit support (i.e., UndoableEditListener and + * UndoableEditEvent) + */ + static public final int UNDOABLEEDIT = 26; + + /** + * Maps to Beans PropertyChange support (i.e., PropertyChangeListener + * and PropertyChangeEvent) + */ + static public final int PROPERTYCHANGE = 27; + + /** + * Maps to Beans VetoableChange support (i.e., VetoableChangeListener + * and VetoableChangeEvent) + */ + static public final int VETOABLECHANGE = 28; + + /** + * Maps to Swing InternalFrame support (i.e., InternalFrameListener) + */ + static public final int INTERNALFRAME = 29; +} diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/java/accessibility/util/EventQueueMonitor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/java/accessibility/util/EventQueueMonitor.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,619 @@ +/* + * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.java.accessibility.util; + +import java.util.*; +import java.awt.*; +import java.awt.event.*; +import javax.accessibility.*; +import java.security.AccessController; +import java.security.PrivilegedAction; + +/** + * The {@code EventQueueMonitor} class provides key core functionality for Assistive + * Technologies (and other system-level technologies that need some of the same + * things that Assistive Technology needs). + * + * @see AWTEventMonitor + * @see SwingEventMonitor + */ +@jdk.Exported +public class EventQueueMonitor + implements AWTEventListener { + + // NOTE: All of the following properties are static. The reason + // for this is that there may be multiple EventQueue instances + // in use in the same VM. By making these properties static, + // we can guarantee we get the information from all of the + // EventQueue instances. + + // The stuff that is cached. + // + static Vector topLevelWindows = new Vector(); + static Window topLevelWindowWithFocus = null; + static Point currentMousePosition = null; + static Component currentMouseComponent = null; + + // Low-level listener interfaces + // + static GUIInitializedListener guiInitializedListener = null; + static TopLevelWindowListener topLevelWindowListener = null; + static MouseMotionListener mouseMotionListener = null; + + /** + * Class variable stating whether the assistive technologies have + * been loaded yet or not. The assistive technologies won't be + * loaded until the first event is posted to the EventQueue. This + * gives the toolkit a chance to do all the necessary initialization + * it needs to do. + */ + + /** + * Class variable stating whether the GUI subsystem has been initialized + * or not. + * + * @see #isGUIInitialized + */ + static boolean guiInitialized = false; + + /** + * Queue that holds events for later processing. + */ + static EventQueueMonitorItem componentEventQueue = null; + + /** + * Class that tells us what the component event dispatch thread is. + */ + static private ComponentEvtDispatchThread cedt = null; + + /** + * Handle the synchronization between the thing that populates the + * component event dispatch thread ({@link #queueComponentEvent}) + * and the thing that processes the events ({@link ComponentEvtDispatchThread}). + */ + static Object componentEventQueueLock = new Object(); + + /** + * Create a new {@code EventQueueMonitor} instance. Normally, this will + * be called only by the AWT Toolkit during initialization time. + * Assistive technologies should not create instances of + * EventQueueMonitor by themselves. Instead, they should either + * refer to it directly via the static methods in this class, e.g., + * {@link #getCurrentMousePosition} or obtain the instance by asking the + * Toolkit, e.g., {@link java.awt.Toolkit#getSystemEventQueue}. + */ + public EventQueueMonitor() { + if (cedt == null) { + cedt = new ComponentEvtDispatchThread("EventQueueMonitor-ComponentEvtDispatch"); + + cedt.setDaemon(true); + cedt.start(); + } + } + + /** + * Queue up a {@link java.awt.event.ComponentEvent ComponentEvent} for later + * processing by the {@link ComponentEvtDispatch} thread. + * + * @param e a {@code ComponentEvent} + */ + static void queueComponentEvent(ComponentEvent e) { + synchronized(componentEventQueueLock) { + EventQueueMonitorItem eqi = new EventQueueMonitorItem(e); + if (componentEventQueue == null) { + componentEventQueue = eqi; + } else { + EventQueueMonitorItem q = componentEventQueue; + while (true) { + if (q.next != null) { + q = q.next; + } else { + break; + } + } + q.next = eqi; + } + componentEventQueueLock.notifyAll(); + } + } + + /** + * Tell the {@code EventQueueMonitor} to start listening for events. + */ + public static void maybeInitialize() { + if (cedt == null) { + java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public Object run() { + try { + long eventMask = AWTEvent.WINDOW_EVENT_MASK | + AWTEvent.FOCUS_EVENT_MASK | + AWTEvent.MOUSE_MOTION_EVENT_MASK; + + Toolkit.getDefaultToolkit().addAWTEventListener(new EventQueueMonitor(), eventMask); + } catch (Exception e) { + } + return null; + } + } + ); + } + } + + /** + * Handle events as a result of registering a listener + * on the {@link java.awt.EventQueue EventQueue} in {@link #maybeInitialize}. + */ + public void eventDispatched(AWTEvent theEvent) { + processEvent(theEvent); + } + + /** + * Assisitive technologies that have + * registered a {@link GUIInitializedListener} will be notified. + * + * @see #addGUIInitializedListener + */ + static void maybeNotifyAssistiveTechnologies() { + + if (!guiInitialized) { + guiInitialized = true; + if (guiInitializedListener != null) { + guiInitializedListener.guiInitialized(); + } + } + + } + + /********************************************************************/ + /* */ + /* Package Private Methods */ + /* */ + /********************************************************************/ + + /** + * Add a Container to the list of top-level containers + * in the cache. This follows the object's hierarchy up the + * tree until it finds the top most parent. If the parent is + * not already in the list of Containers, it adds it to the list. + * + * @param c the Container + */ + static void addTopLevelWindow(Component c) { + Container parent; + + if (c == null) { + return; + } + + if (!(c instanceof Window)) { + addTopLevelWindow(c.getParent()); + return; + } + + if ((c instanceof Dialog) || (c instanceof Window)) { + parent = (Container) c; + } else { + parent = c.getParent(); + if (parent != null) { + addTopLevelWindow(parent); + return; + } + } + + if (parent == null) { + parent = (Container) c; + } + + // Because this method is static, do not make it synchronized because + // it can lock the whole class. Instead, just lock what needs to be + // locked. + // + synchronized (topLevelWindows) { + if ((parent != null) && !topLevelWindows.contains(parent)) { + topLevelWindows.addElement(parent); + if (topLevelWindowListener != null) { + topLevelWindowListener.topLevelWindowCreated((Window) parent); + } + } + } + } + + /** + * Removes a container from the list of top level containers in the cache. + * + * @param c the top level container to remove + */ + static void removeTopLevelWindow(Window w) { + + // Because this method is static, do not make it synchronized because + // it can lock the whole class. Instead, just lock what needs to be + // locked. + // + synchronized (topLevelWindows) { + if (topLevelWindows.contains(w)) { + topLevelWindows.removeElement(w); + if (topLevelWindowListener != null) { + topLevelWindowListener.topLevelWindowDestroyed(w); + } + } + } + } + + /** + * Update current mouse position. + * + * @param mouseEvent the MouseEvent that holds the new mouse position. + */ + static void updateCurrentMousePosition(MouseEvent mouseEvent) { + Point oldMousePos = currentMousePosition; + // Be careful here. The component in the event might be + // hidden by the time we process the event. + try { + Point eventPoint = mouseEvent.getPoint(); + currentMouseComponent = (Component) (mouseEvent.getSource()); + currentMousePosition = currentMouseComponent.getLocationOnScreen(); + currentMousePosition.translate(eventPoint.x,eventPoint.y); + } catch (Exception e) { + currentMousePosition = oldMousePos; + } + } + + /** + * Process the event. This maintains the event cache in addition + * to calling all the registered listeners. NOTE: The events that + * come through here are from peered Components. + * + * @param theEvent the AWTEvent + */ + static void processEvent(AWTEvent theEvent) { + switch (theEvent.getID()) { + case MouseEvent.MOUSE_MOVED: + case MouseEvent.MOUSE_DRAGGED: + case FocusEvent.FOCUS_GAINED: + case WindowEvent.WINDOW_DEACTIVATED: + queueComponentEvent((ComponentEvent) theEvent); + break; + + case WindowEvent.WINDOW_ACTIVATED: + // Dialogs fire WINDOW_ACTIVATED and FOCUS_GAINED events + // before WINDOW_OPENED so we need to add topLevelListeners + // for the dialog when it is first activated to get a + // focus gained event for the focus component in the dialog. + if (theEvent instanceof ComponentEvent) { + ComponentEvent ce = (ComponentEvent)theEvent; + if (ce.getComponent() instanceof Window) { + EventQueueMonitor.addTopLevelWindow(ce.getComponent()); + EventQueueMonitor.maybeNotifyAssistiveTechnologies(); + } else { + EventQueueMonitor.maybeNotifyAssistiveTechnologies(); + EventQueueMonitor.addTopLevelWindow(ce.getComponent()); + } + } + queueComponentEvent((ComponentEvent) theEvent); + break; + + // handle WINDOW_OPENED and WINDOW_CLOSED events synchronously + case WindowEvent.WINDOW_OPENED: + if (theEvent instanceof ComponentEvent) { + ComponentEvent ce = (ComponentEvent)theEvent; + if (ce.getComponent() instanceof Window) { + EventQueueMonitor.addTopLevelWindow(ce.getComponent()); + EventQueueMonitor.maybeNotifyAssistiveTechnologies(); + } else { + EventQueueMonitor.maybeNotifyAssistiveTechnologies(); + EventQueueMonitor.addTopLevelWindow(ce.getComponent()); + } + } + break; + case WindowEvent.WINDOW_CLOSED: + if (theEvent instanceof ComponentEvent) { + ComponentEvent ce = (ComponentEvent)theEvent; + EventQueueMonitor.removeTopLevelWindow((Window) (ce.getComponent())); + } + break; + + default: + break; + } + } + + /** + * Internal test + */ + static synchronized Component getShowingComponentAt(Container c, int x, int y) { + if (!c.contains(x, y)) { + return null; + } + int ncomponents = c.getComponentCount(); + for (int i = 0 ; i < ncomponents ; i++) { + Component comp = c.getComponent(i); + if (comp != null && comp.isShowing()) { + Point location = comp.getLocation(); + if (comp.contains(x - location.x, y - location.y)) { + return comp; + } + } + } + return c; + } + + /** + * Return the Component at the given Point on the screen in the + * given Container. + * + * @param c the Container to search + * @param p the Point in screen coordinates + * @return the Component at the given Point on the screen in the + * given Container -- can be null if no Component is at that Point + */ + static synchronized Component getComponentAt(Container c, Point p) { + if (!c.isShowing()) { + return null; + } + + Component comp; + Point containerLoc = c.getLocationOnScreen(); + Point containerPoint = new Point(p.x - containerLoc.x, + p.y - containerLoc.y); + + comp = getShowingComponentAt(c, containerPoint.x, containerPoint.y); + + if ((comp != c) && (comp instanceof Container)) { + return getComponentAt((Container)comp,p); + } else { + return comp; + } + } + + /** + * Obtain the {@link javax.accessibility.Accessible Accessible} object at the given point on the Screen. + * The return value may be null if an {@code Accessible} object cannot be + * found at the particular point. + * + * @param p the point to be accessed + * @return the {@code Accessible} at the specified point + */ + static public Accessible getAccessibleAt(Point p) { + Window w = getTopLevelWindowWithFocus(); + Window[] wins = getTopLevelWindows(); + Component c = null; + + // See if the point we're being asked about is the + // currentMousePosition. If so, start with the component + // that we know the currentMousePostion is over + // + if (currentMousePosition == null) { + return null; + } + if (currentMousePosition.equals(p)) { + if (currentMouseComponent instanceof Container) { + c = getComponentAt((Container) currentMouseComponent, p); + } + } + + // Try the window with focus next + // + if (c == null && w != null) { + c = getComponentAt(w,p); + } + + // Try the other windows next. [[[WDW: Stacking order???]]] + if (c == null) { + for (int i = 0; i < wins.length; i++) { + c = getComponentAt(wins[i],p); + if (c != null) { + break; + } + } + } + + if (c instanceof Accessible) { + AccessibleContext ac = ((Accessible) c).getAccessibleContext(); + if (ac != null) { + AccessibleComponent acmp = ac.getAccessibleComponent(); + if ((acmp != null) && (ac.getAccessibleChildrenCount() != 0)) { + Point location = acmp.getLocationOnScreen(); + location.move(p.x - location.x, p.y - location.y); + return acmp.getAccessibleAt(location); + } + } + return (Accessible) c; + } else { + return Translator.getAccessible(c); + } + } + + /********************************************************************/ + /* */ + /* Public Methods */ + /* */ + /********************************************************************/ + + /** + * Says whether the GUI subsystem has been initialized or not. + * If this returns true, the assistive technology can freely + * create GUI component instances. If the return value is false, + * the assistive technology should register a {@link GUIInitializedListener} + * and wait to create GUI component instances until the listener is + * called. + * + * @return true if the GUI subsystem has been initialized + * @see #addGUIInitializedListener + */ + static public boolean isGUIInitialized() { + maybeInitialize(); + return guiInitialized; + } + + /** + * Adds the specified listener to be notified when the GUI subsystem + * is initialized. Assistive technologies should get the results of + * {@link #isGUIInitialized} before calling this method. + * + * @param l the listener to add + * @see #isGUIInitialized + * @see #removeTopLevelWindowListener + */ + static public void addGUIInitializedListener(GUIInitializedListener l) { + maybeInitialize(); + guiInitializedListener = + GUIInitializedMulticaster.add(guiInitializedListener,l); + } + + /** + * Removes the specified listener to be notified when the GUI subsystem + * is initialized. + * + * @param l the listener to remove + * @see #addGUIInitializedListener + */ + static public void removeGUIInitializedListener(GUIInitializedListener l) { + guiInitializedListener = + GUIInitializedMulticaster.remove(guiInitializedListener,l); + } + + /** + * Adds the specified listener to be notified when a top level window + * is created or destroyed. + * + * @param l the listener to add + * @see #removeTopLevelWindowListener + */ + static public void addTopLevelWindowListener(TopLevelWindowListener l) { + topLevelWindowListener = + TopLevelWindowMulticaster.add(topLevelWindowListener,l); + } + + /** + * Removes the specified listener to be notified when a top level window + * is created or destroyed. + * + * @param l the listener to remove + * @see #addTopLevelWindowListener + */ + static public void removeTopLevelWindowListener(TopLevelWindowListener l) { + topLevelWindowListener = + TopLevelWindowMulticaster.remove(topLevelWindowListener,l); + } + + /** + * Return the last recorded position of the mouse in screen coordinates. + * + * @return the last recorded position of the mouse in screen coordinates + */ + static public Point getCurrentMousePosition() { + return currentMousePosition; + } + + /** + * Return the list of top level Windows in use in the Java Virtual Machine. + * + * @return an array of top level {@code Window}s in use in the Java Virtual Machine + */ + static public Window[] getTopLevelWindows() { + + // Because this method is static, do not make it synchronized because + // it can lock the whole class. Instead, just lock what needs to be + // locked. + // + synchronized (topLevelWindows) { + int count = topLevelWindows.size(); + if (count > 0) { + Window[] w = new Window[count]; + for (int i = 0; i < count; i++) { + w[i] = (Window)topLevelWindows.elementAt(i); + } + return w; + } else { + return new Window[0]; + } + } + } + + /** + * Return the top level {@code Window} that currently has keyboard focus. + * + * @return the top level {@code Window} that currently has keyboard focus + */ + static public Window getTopLevelWindowWithFocus() { + return topLevelWindowWithFocus; + } +} + +/** + * Handle all Component events in a separate thread. The reason for this is + * that WindowEvents tend to be used to do lots of processing on the Window + * hierarchy. As a result, it can frequently result in deadlock situations. + */ +class ComponentEvtDispatchThread extends Thread { + public ComponentEvtDispatchThread(String name) { + super(name); + } + public void run() { + ComponentEvent ce = null; + while (true) { + synchronized(EventQueueMonitor.componentEventQueueLock) { + while (EventQueueMonitor.componentEventQueue == null) { + try { + EventQueueMonitor.componentEventQueueLock.wait(); + } catch (InterruptedException e) { + } + } + ce = (ComponentEvent)EventQueueMonitor.componentEventQueue.event; + EventQueueMonitor.componentEventQueue = + EventQueueMonitor.componentEventQueue.next; + } + switch (ce.getID()) { + case MouseEvent.MOUSE_MOVED: + case MouseEvent.MOUSE_DRAGGED: + EventQueueMonitor.updateCurrentMousePosition((MouseEvent) ce); + break; + case WindowEvent.WINDOW_ACTIVATED: + EventQueueMonitor.maybeNotifyAssistiveTechnologies(); + EventQueueMonitor.topLevelWindowWithFocus = ((WindowEvent) ce).getWindow(); + break; + + default: + break; + } + } + } +} + +/** + * EventQueueMonitorItem is the basic type that handles the + * queue for queueComponentEvent and the ComponentEvtDispatchThread. + */ +class EventQueueMonitorItem { + AWTEvent event; + EventQueueMonitorItem next; + + EventQueueMonitorItem(AWTEvent evt) { + event = evt; + next = null; + } +} diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/java/accessibility/util/GUIInitializedListener.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/java/accessibility/util/GUIInitializedListener.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.java.accessibility.util; + +import java.awt.*; +import java.util.*; +import javax.accessibility.*; + +/** + * The {@code GUIInitializedListener} interface is used by the {@link EventQueueMonitor} + * class to notify an interested party when the GUI subsystem has been + * initialized. This is necessary because assistive technologies can + * be loaded before the GUI subsystem is initialized. As a result, + * assistive technologies should check the + * {@link EventQueueMonitor#isGUIInitialized isGUIInitialized} method + * of {@code EventQueueMonitor} before creating any GUI components. If the + * return value is true, assistive technologies can create GUI components + * following the same thread restrictions as any other application. If + * the return value is false, the assistive technology should register + * a {@code GUIInitializedListener} with the {@code EventQueueMonitor} to be notified + * when the GUI subsystem is initialized. + * + * @see EventQueueMonitor + * @see EventQueueMonitor#isGUIInitialized + * @see EventQueueMonitor#addGUIInitializedListener + * @see EventQueueMonitor#removeGUIInitializedListener + * + */ +@jdk.Exported +public interface GUIInitializedListener extends EventListener { + + /** + * Invoked when the GUI subsystem is initialized and it's OK for + * the assisitive technology to create instances of GUI objects. + */ + public void guiInitialized(); + +} diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/java/accessibility/util/GUIInitializedMulticaster.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/java/accessibility/util/GUIInitializedMulticaster.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.java.accessibility.util; + +import java.awt.*; +import java.util.EventListener; +import javax.accessibility.*; + + +/** + * The GUIInitializedMulticaster class is used to maintain a list of + * GUIInitializedListener classes. It is intended to be used primarily + * for internal support in the EventQueueMonitor class, and is not intended + * to be used by classes outside the Java Accessibility Utility package. + * + * @see EventQueueMonitor + * @see EventQueueMonitor#addGUIInitializedListener + * @see EventQueueMonitor#removeGUIInitializedListener + * + */ +@jdk.Exported(false) +public class GUIInitializedMulticaster + extends AWTEventMulticaster implements GUIInitializedListener +{ + protected GUIInitializedMulticaster(EventListener a, EventListener b) { + super(a, b); + } + + public void guiInitialized() { + ((GUIInitializedListener)a).guiInitialized(); + ((GUIInitializedListener)b).guiInitialized(); + } + + public static GUIInitializedListener add(GUIInitializedListener a, GUIInitializedListener b) { + return (GUIInitializedListener)addInternal(a, b); + } + + public static GUIInitializedListener remove(GUIInitializedListener l, GUIInitializedListener oldl) { + return (GUIInitializedListener)removeInternal(l, oldl); + } + + protected static EventListener addInternal(EventListener a, EventListener b) { + if (a == null) return b; + if (b == null) return a; + return new GUIInitializedMulticaster(a, b); + } + + protected static EventListener removeInternal(EventListener l, EventListener oldl) { + if (l == oldl || l == null) { + return null; + } else if (l instanceof GUIInitializedMulticaster) { + return ((GUIInitializedMulticaster)l).remove(oldl); + } else { + return l; // it's not here + } + } + +} diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/java/accessibility/util/SwingEventMonitor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/java/accessibility/util/SwingEventMonitor.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,2542 @@ +/* + * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.java.accessibility.util; + +import java.util.*; +import java.beans.*; +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.event.*; +import javax.swing.table.*; +import javax.swing.tree.*; +import javax.swing.text.*; +import javax.swing.undo.*; +import javax.accessibility.*; + + +/** + *

{@code SwingEventMonitor} extends {@link AWTEventMonitor} by adding a suite of + * listeners conditionally installed on every Swing component instance + * in the Java Virtual Machine. The events captured by these listeners + * are made available through a unified set of listeners supported by + * {@code SwingEventMonitor}. With this, all the individual events on each of the + * AWT and Swing component instances are funneled into one set of listeners + * broken down by category (see {@link EventID} for the categories). + *

This class depends upon {@link EventQueueMonitor}, which provides the base + * level support for capturing the top-level containers as they are created. + *

Because this class extends {@code AWTEventMonitor}, it is not + * necessary to use this class and {@code AWTEventMonitor} at the same time. + * If you want to monitor both AWT and Swing components, you should + * use just this class. + * + * @see AWTEventMonitor + * + */ +@jdk.Exported +public class SwingEventMonitor extends AWTEventMonitor { + + /** + * The master list of all listeners registered by other classes. + * This can only be publicly modified by calling the add or + * remove listener methods in this class. + */ + static protected final EventListenerList listenerList = new EventListenerList(); + + /** + * The actual listener that is installed on the component instances. + * This listener calls the other registered listeners when an event + * occurs. By doing things this way, the actual number of listeners + * installed on a component instance is drastically reduced. + */ + static protected final SwingEventListener swingListener = new SwingEventListener(); + + /** + * Adds the specified listener to receive all {@link EventID#ANCESTOR ANCESTOR} + * events on each component instance in the Java Virtual Machine as they occur. + *

Note: This listener is automatically added to all component + * instances created after this method is called. In addition, it + * is only added to component instances that support this listener type. + * + * @param l the listener to add + * @see #removeAncestorListener + */ + static public void addAncestorListener(AncestorListener l) { + if (listenerList.getListenerCount(AncestorListener.class) == 0) { + swingListener.installListeners(EventID.ANCESTOR); + } + listenerList.add(AncestorListener.class, l); + } + + /** + * Removes the specified listener so it no longer receives + * {@link EventID#ANCESTOR ANCESTOR} events when they occur. + * + * @param l the listener to remove + * @see #addAncestorListener + */ + static public void removeAncestorListener(AncestorListener l) { + listenerList.remove(AncestorListener.class, l); + if (listenerList.getListenerCount(AncestorListener.class) == 0) { + swingListener.removeListeners(EventID.ANCESTOR); + } + } + + /** + * Adds the specified listener to receive all {@link EventID#CARET CARET} events + * on each component instance in the Java Virtual Machine as they occur. + *

Note: This listener is automatically added to all component + * instances created after this method is called. In addition, it + * is only added to component instances that support this listener type. + * + * @param l the listener to add + * @see #removeCaretListener + */ + static public void addCaretListener(CaretListener l) { + if (listenerList.getListenerCount(CaretListener.class) == 0) { + swingListener.installListeners(EventID.CARET); + } + listenerList.add(CaretListener.class, l); + } + + /** + * Removes the specified listener so it no longer receives + * {@link EventID#CARET CARET} events when they occur. + * + * @param l the listener to remove + * @see #addCaretListener + */ + static public void removeCaretListener(CaretListener l) { + listenerList.remove(CaretListener.class, l); + if (listenerList.getListenerCount(CaretListener.class) == 0) { + swingListener.removeListeners(EventID.CARET); + } + } + + /** + * Adds the specified listener to receive all + * {@link EventID#CELLEDITOR CELLEDITOR} events on each + * component instance in the Java Virtual Machine as they occur. + *

Note: This listener is automatically added to all component + * instances created after this method is called. In addition, it + * is only added to component instances that support this listener type. + * + * @param l the listener to add + * @see #removeCellEditorListener + */ + static public void addCellEditorListener(CellEditorListener l) { + if (listenerList.getListenerCount(CellEditorListener.class) == 0) { + swingListener.installListeners(EventID.CELLEDITOR); + } + listenerList.add(CellEditorListener.class, l); + } + + /** + * Removes the specified listener so it no longer receives + * {@link EventID#CELLEDITOR CELLEDITOR} events when they occur. + * + * @param l the listener to remove + * @see #addCellEditorListener + */ + static public void removeCellEditorListener(CellEditorListener l) { + listenerList.remove(CellEditorListener.class, l); + if (listenerList.getListenerCount(CellEditorListener.class) == 0) { + swingListener.removeListeners(EventID.CELLEDITOR); + } + } + + /** + * Adds the specified listener to receive all {@link EventID#CHANGE CHANGE} + * events on each component instance in the Java Virtual Machine as they occur. + *

Note: This listener is automatically added to all component + * instances created after this method is called. In addition, it + * is only added to component instances that support this listener type. + * + * @param l the listener to add + * @see #removeChangeListener + */ + static public void addChangeListener(ChangeListener l) { + if (listenerList.getListenerCount(ChangeListener.class) == 0) { + swingListener.installListeners(EventID.CHANGE); + } + listenerList.add(ChangeListener.class, l); + } + + /** + * Removes the specified listener so it no longer receives + * {@link EventID#CHANGE CHANGE} events when they occur. + * + * @param l the listener to remove + * @see #addChangeListener + */ + static public void removeChangeListener(ChangeListener l) { + listenerList.remove(ChangeListener.class, l); + if (listenerList.getListenerCount(ChangeListener.class) == 0) { + swingListener.removeListeners(EventID.CHANGE); + } + } + + /** + * Adds the specified listener to receive all {@link EventID#COLUMNMODEL COLUMNMODEL} + * events on each component instance in the Java Virtual Machine as they occur. + *

Note: This listener is automatically added to all component + * instances created after this method is called. In addition, it + * is only added to component instances that support this listener type. + * + * @param l the listener to add + * @see #removeColumnModelListener + */ + static public void addColumnModelListener(TableColumnModelListener l) { + if (listenerList.getListenerCount(TableColumnModelListener.class) == 0) { + swingListener.installListeners(EventID.COLUMNMODEL); + } + listenerList.add(TableColumnModelListener.class, l); + } + + /** + * Removes the specified listener so it no longer receives + * {@link EventID#COLUMNMODEL COLUMNMODEL} events when they occur. + * + * @param l the listener to remove + * @see #addColumnModelListener + */ + static public void removeColumnModelListener(TableColumnModelListener l) { + listenerList.remove(TableColumnModelListener.class, l); + if (listenerList.getListenerCount(TableColumnModelListener.class) == 0) { + swingListener.removeListeners(EventID.COLUMNMODEL); + } + } + + /** + * Adds the specified listener to receive all {@link EventID#DOCUMENT DOCUMENT} + * events on each component instance in the Java Virtual Machine as they occur. + *

Note: This listener is automatically added to all component + * instances created after this method is called. In addition, it + * is only added to component instances that support this listener type. + * + * @param l the listener to add + * @see #removeDocumentListener + */ + static public void addDocumentListener(DocumentListener l) { + if (listenerList.getListenerCount(DocumentListener.class) == 0) { + swingListener.installListeners(EventID.DOCUMENT); + } + listenerList.add(DocumentListener.class, l); + } + + /** + * Removes the specified listener so it no longer receives + * {@link EventID#DOCUMENT DOCUMENT} events when they occur. + * + * @param l the listener to remove + * @see #addDocumentListener + */ + static public void removeDocumentListener(DocumentListener l) { + listenerList.remove(DocumentListener.class, l); + if (listenerList.getListenerCount(DocumentListener.class) == 0) { + swingListener.removeListeners(EventID.DOCUMENT); + } + } + + /** + * Adds the specified listener to receive all {@link EventID#LISTDATA LISTDATA} + * events on each component instance in the Java Virtual Machine as they occur. + *

Note: This listener is automatically added to all component + * instances created after this method is called. In addition, it + * is only added to component instances that support this listener type. + * + * @param l the listener to add + * @see #removeListDataListener + */ + static public void addListDataListener(ListDataListener l) { + if (listenerList.getListenerCount(ListDataListener.class) == 0) { + swingListener.installListeners(EventID.LISTDATA); + } + listenerList.add(ListDataListener.class, l); + } + + /** + * Removes the specified listener so it no longer receives + * {@link EventID#LISTDATA LISTDATA} events when they occur. + * + * @param l the listener to remove + * @see #addListDataListener + */ + static public void removeListDataListener(ListDataListener l) { + listenerList.remove(ListDataListener.class, l); + if (listenerList.getListenerCount(ListDataListener.class) == 0) { + swingListener.removeListeners(EventID.LISTDATA); + } + } + + /** + * Adds the specified listener to receive all {@link EventID#LISTSELECTION LISTSELECTION} + * events on each component instance in the Java Virtual Machine as they occur. + *

Note: This listener is automatically added to all component + * instances created after this method is called. In addition, it + * is only added to component instances that support this listener type. + * + * @param l the listener to add + * @see #removeListSelectionListener + */ + static public void addListSelectionListener(ListSelectionListener l) { + if (listenerList.getListenerCount(ListSelectionListener.class) == 0) { + swingListener.installListeners(EventID.LISTSELECTION); + } + listenerList.add(ListSelectionListener.class, l); + } + + /** + * Removes the specified listener so it no longer receives + * {@link EventID#LISTSELECTION LISTSELECTION} events when they occur. + * + * @param l the listener to remove + * @see #addListSelectionListener + */ + static public void removeListSelectionListener(ListSelectionListener l) { + listenerList.remove(ListSelectionListener.class, l); + if (listenerList.getListenerCount(ListSelectionListener.class) == 0) { + swingListener.removeListeners(EventID.LISTSELECTION); + } + } + + /** + * Adds the specified listener to receive all {@link EventID#MENU MENU} events + * on each component instance in the Java Virtual Machine as they occur. + *

Note: This listener is automatically added to all component + * instances created after this method is called. In addition, it + * is only added to component instances that support this listener type. + * + * @param l the listener to add + * @see #removeMenuListener + */ + static public void addMenuListener(MenuListener l) { + if (listenerList.getListenerCount(MenuListener.class) == 0) { + swingListener.installListeners(EventID.MENU); + } + listenerList.add(MenuListener.class, l); + } + + /** + * Removes the specified listener so it no longer receives + * {@link EventID#MENU MENU} events when they occur. + * + * @param l the listener to remove + * @see #addMenuListener + */ + static public void removeMenuListener(MenuListener l) { + listenerList.remove(MenuListener.class, l); + if (listenerList.getListenerCount(MenuListener.class) == 0) { + swingListener.removeListeners(EventID.MENU); + } + } + + /** + * Adds the specified listener to receive all {@link EventID#POPUPMENU POPUPMENU} + * events on each component instance in the Java Virtual Machine as they occur. + *

Note: This listener is automatically added to all component + * instances created after this method is called. In addition, it + * is only added to component instances that support this listener type. + * + * @param l the listener to add + * @see #removePopupMenuListener + */ + static public void addPopupMenuListener(PopupMenuListener l) { + if (listenerList.getListenerCount(PopupMenuListener.class) == 0) { + swingListener.installListeners(EventID.POPUPMENU); + } + listenerList.add(PopupMenuListener.class, l); + } + + /** + * Removes the specified listener so it no longer receives + * {@link EventID#POPUPMENU POPUPMENU} events when they occur. + * + * @param l the listener to remove + * @see #addPopupMenuListener + */ + static public void removePopupMenuListener(PopupMenuListener l) { + listenerList.remove(PopupMenuListener.class, l); + if (listenerList.getListenerCount(PopupMenuListener.class) == 0) { + swingListener.removeListeners(EventID.POPUPMENU); + } + } + + /** + * Adds the specified listener to receive all {@link EventID#TABLEMODEL TABLEMODEL} + * events on each component instance in the Java Virtual Machine as they occur. + *

Note: This listener is automatically added to all component + * instances created after this method is called. In addition, it + * is only added to component instances that support this listener type. + * + * @param l the listener to add + * @see #removeTableModelListener + */ + static public void addTableModelListener(TableModelListener l) { + if (listenerList.getListenerCount(TableModelListener.class) == 0) { + swingListener.installListeners(EventID.TABLEMODEL); + } + listenerList.add(TableModelListener.class, l); + } + + /** + * Removes the specified listener so it no longer receives + * {@link EventID#TABLEMODEL TABLEMODEL} events when they occur. + * + * @param l the listener to remove + * @see #addTableModelListener + */ + static public void removeTableModelListener(TableModelListener l) { + listenerList.remove(TableModelListener.class, l); + if (listenerList.getListenerCount(TableModelListener.class) == 0) { + swingListener.removeListeners(EventID.TABLEMODEL); + } + } + + /** + * Adds the specified listener to receive all {@link EventID#TREEEXPANSION TREEEXPANSION} + * events on each component instance in the Java Virtual Machine as they occur. + *

Note: This listener is automatically added to all component + * instances created after this method is called. In addition, it + * is only added to component instances that support this listener type. + * + * @param l the listener to add + * @see #removeTreeExpansionListener + */ + static public void addTreeExpansionListener(TreeExpansionListener l) { + if (listenerList.getListenerCount(TreeExpansionListener.class) == 0) { + swingListener.installListeners(EventID.TREEEXPANSION); + } + listenerList.add(TreeExpansionListener.class, l); + } + + /** + * Removes the specified listener so it no longer receives + * {@link EventID#TREEEXPANSION TREEEXPANSION} events when they occur. + * + * @param l the listener to remove + * @see #addTreeExpansionListener + */ + static public void removeTreeExpansionListener(TreeExpansionListener l) { + listenerList.remove(TreeExpansionListener.class, l); + if (listenerList.getListenerCount(TreeExpansionListener.class) == 0) { + swingListener.removeListeners(EventID.TREEEXPANSION); + } + } + + /** + * Adds the specified listener to receive all {@link EventID#TREEMODEL TREEMODEL} + * events on each component instance in the Java Virtual Machine as they occur. + *

Note: This listener is automatically added to all component + * instances created after this method is called. In addition, it + * is only added to component instances that support this listener type. + * + * @param l the listener to add + * @see #removeTreeModelListener + */ + static public void addTreeModelListener(TreeModelListener l) { + if (listenerList.getListenerCount(TreeModelListener.class) == 0) { + swingListener.installListeners(EventID.TREEMODEL); + } + listenerList.add(TreeModelListener.class, l); + } + + /** + * Removes the specified listener so it no longer receives + * {@link EventID#TREEMODEL TREEMODEL} events when they occur. + * + * @param l the listener to remove + * @see #addTreeModelListener + */ + static public void removeTreeModelListener(TreeModelListener l) { + listenerList.remove(TreeModelListener.class, l); + if (listenerList.getListenerCount(TreeModelListener.class) == 0) { + swingListener.removeListeners(EventID.TREEMODEL); + } + } + + /** + * Adds the specified listener to receive all {@link EventID#TREESELECTION TREESELECTION} + * events on each component instance in the Java Virtual Machine as they occur. + *

Note: This listener is automatically added to all component + * instances created after this method is called. In addition, it + * is only added to component instances that support this listener type. + * + * @param l the listener to add + * @see #removeTreeSelectionListener + */ + static public void addTreeSelectionListener(TreeSelectionListener l) { + if (listenerList.getListenerCount(TreeSelectionListener.class) == 0) { + swingListener.installListeners(EventID.TREESELECTION); + } + listenerList.add(TreeSelectionListener.class, l); + } + + /** + * Removes the specified listener so it no longer receives + * {@link EventID#TREESELECTION TREESELECTION} events when they occur. + * @see #addTreeSelectionListener + * @param l the listener to remove + */ + static public void removeTreeSelectionListener(TreeSelectionListener l) { + listenerList.remove(TreeSelectionListener.class, l); + if (listenerList.getListenerCount(TreeSelectionListener.class) == 0) { + swingListener.removeListeners(EventID.TREESELECTION); + } + } + + /** + * Adds the specified listener to receive all {@link EventID#UNDOABLEEDIT UNDOABLEEDIT} + * events on each component instance in the Java Virtual Machine as they occur. + *

Note: This listener is automatically added to all component + * instances created after this method is called. In addition, it + * is only added to component instances that support this listener type. + * + * @param l the listener to add + * @see #removeUndoableEditListener + */ + static public void addUndoableEditListener(UndoableEditListener l) { + if (listenerList.getListenerCount(UndoableEditListener.class) == 0) { + swingListener.installListeners(EventID.UNDOABLEEDIT); + } + listenerList.add(UndoableEditListener.class, l); + } + + /** + * Removes the specified listener so it no longer receives + * {@link EventID#UNDOABLEEDIT UNDOABLEEDIT} events when they occur. + * + * @param l the listener to remove + * @see #addUndoableEditListener + */ + static public void removeUndoableEditListener(UndoableEditListener l) { + listenerList.remove(UndoableEditListener.class, l); + if (listenerList.getListenerCount(UndoableEditListener.class) == 0) { + swingListener.removeListeners(EventID.UNDOABLEEDIT); + } + } + + /** + * Adds the specified listener to receive all {@link EventID#INTERNALFRAME INTERNALFRAME} + * events on each component instance in the Java Virtual Machine as they occur. + *

Note: This listener is automatically added to all component + * instances created after this method is called. In addition, it + * is only added to component instances that support this listener type. + * + * @param l the listener to add + * @see #removeInternalFrameListener + */ + static public void addInternalFrameListener(InternalFrameListener l) { + if (listenerList.getListenerCount(InternalFrameListener.class) == 0) { + swingListener.installListeners(EventID.INTERNALFRAME); + } + listenerList.add(InternalFrameListener.class, l); + } + + /** + * Removes the specified listener so it no longer receives + * {@link EventID#INTERNALFRAME INTERNALFRAME} events when they occur. + * + * @param l the listener to remove + * @see #addInternalFrameListener + */ + static public void removeInternalFrameListener(InternalFrameListener l) { + listenerList.remove(InternalFrameListener.class, l); + if (listenerList.getListenerCount(InternalFrameListener.class) == 0) { + swingListener.removeListeners(EventID.INTERNALFRAME); + } + } + + /** + * Adds the specified listener to receive all {@link EventID#PROPERTYCHANGE PROPERTYCHANGE} + * events on each component instance in the Java Virtual Machine as they occur. + *

Note: This listener is automatically added to all component + * instances created after this method is called. In addition, it + * is only added to component instances that support this listener type. + * + * @param l the listener to add + * @see #removePropertyChangeListener + */ + static public void addPropertyChangeListener(PropertyChangeListener l) { + if (listenerList.getListenerCount(PropertyChangeListener.class) == 0) { + swingListener.installListeners(EventID.PROPERTYCHANGE); + } + listenerList.add(PropertyChangeListener.class, l); + } + + /** + * Removes the specified listener so it no longer receives + * {@link EventID#PROPERTYCHANGE PROPERTYCHANGE} events when they occur. + * @see #addPropertyChangeListener + * @param l the listener to remove + */ + static public void removePropertyChangeListener(PropertyChangeListener l) { + listenerList.remove(PropertyChangeListener.class, l); + if (listenerList.getListenerCount(PropertyChangeListener.class) == 0) { + swingListener.removeListeners(EventID.PROPERTYCHANGE); + } + } + + /** + * Adds the specified listener to receive all {@link EventID#VETOABLECHANGE VETOABLECHANGE} + * events on each component instance in the Java Virtual Machine as they occur. + *

Note: This listener is automatically added to all component + * instances created after this method is called. In addition, it + * is only added to component instances that support this listener type. + * + * @param l the listener to add + * @see #removeVetoableChangeListener + */ + static public void addVetoableChangeListener(VetoableChangeListener l) { + if (listenerList.getListenerCount(VetoableChangeListener.class) == 0) { + swingListener.installListeners(EventID.VETOABLECHANGE); + } + listenerList.add(VetoableChangeListener.class, l); + } + + /** + * Removes the specified listener so it no longer receives + * {@link EventID#VETOABLECHANGE VETOABLECHANGE} events when they occur. + * + * @param l the listener to remove + * @see #addVetoableChangeListener + */ + static public void removeVetoableChangeListener(VetoableChangeListener l) { + listenerList.remove(VetoableChangeListener.class, l); + if (listenerList.getListenerCount(VetoableChangeListener.class) == 0) { + swingListener.removeListeners(EventID.VETOABLECHANGE); + } + } + + + /** + * SwingEventListener is the class that does all the work for + * SwingEventMonitor. It is not intended for use by any other class + * except SwingEventMonitor. + * + */ + static class SwingEventListener extends AWTEventsListener + implements AncestorListener, CaretListener, CellEditorListener, + ChangeListener, DocumentListener, ListDataListener, + ListSelectionListener, MenuListener, PopupMenuListener, + TableColumnModelListener, TableModelListener, TreeExpansionListener, + TreeModelListener, TreeSelectionListener, UndoableEditListener, + InternalFrameListener, + PropertyChangeListener, VetoableChangeListener { + + /** + * internal variables for Caret introspection + */ + private java.lang.Class caretListeners[]; + private java.lang.reflect.Method removeCaretMethod; + private java.lang.reflect.Method addCaretMethod; + private java.lang.Object caretArgs[]; + + /** + * internal variables for CellEditor introspection + */ + private java.lang.Class cellEditorListeners[]; + private java.lang.reflect.Method removeCellEditorMethod; + private java.lang.reflect.Method addCellEditorMethod; + private java.lang.Object cellEditorArgs[]; + private java.lang.reflect.Method getCellEditorMethod; + + /** + * internal variables for Change introspection + */ + private java.lang.Class changeListeners[]; + private java.lang.reflect.Method removeChangeMethod; + private java.lang.reflect.Method addChangeMethod; + private java.lang.Object changeArgs[]; + + /** + * internal variable for ColumnModel introspection + */ + private java.lang.reflect.Method getColumnModelMethod; + + /** + * internal variables for Document introspection + */ + private java.lang.Class documentListeners[]; + private java.lang.reflect.Method removeDocumentMethod; + private java.lang.reflect.Method addDocumentMethod; + private java.lang.Object documentArgs[]; + private java.lang.reflect.Method getDocumentMethod; + + /** + * internal variable for ListData, Table, and Tree introspection + */ + private java.lang.reflect.Method getModelMethod; + + /** + * internal variables for ListSelection introspection + */ + private java.lang.Class listSelectionListeners[]; + private java.lang.reflect.Method removeListSelectionMethod; + private java.lang.reflect.Method addListSelectionMethod; + private java.lang.Object listSelectionArgs[]; + private java.lang.reflect.Method getSelectionModelMethod; + + /** + * internal variables for Menu introspection + */ + private java.lang.Class menuListeners[]; + private java.lang.reflect.Method removeMenuMethod; + private java.lang.reflect.Method addMenuMethod; + private java.lang.Object menuArgs[]; + + /** + * internal variables for PopupMenu introspection + */ + private java.lang.Class popupMenuListeners[]; + private java.lang.reflect.Method removePopupMenuMethod; + private java.lang.reflect.Method addPopupMenuMethod; + private java.lang.Object popupMenuArgs[]; + private java.lang.reflect.Method getPopupMenuMethod; + + /** + * internal variables for TreeExpansion introspection + */ + private java.lang.Class treeExpansionListeners[]; + private java.lang.reflect.Method removeTreeExpansionMethod; + private java.lang.reflect.Method addTreeExpansionMethod; + private java.lang.Object treeExpansionArgs[]; + + /** + * internal variables for TreeSelection introspection + */ + private java.lang.Class treeSelectionListeners[]; + private java.lang.reflect.Method removeTreeSelectionMethod; + private java.lang.reflect.Method addTreeSelectionMethod; + private java.lang.Object treeSelectionArgs[]; + + /** + * internal variables for UndoableEdit introspection + */ + private java.lang.Class undoableEditListeners[]; + private java.lang.reflect.Method removeUndoableEditMethod; + private java.lang.reflect.Method addUndoableEditMethod; + private java.lang.Object undoableEditArgs[]; + + /** + * internal variables for InternalFrame introspection + */ + private java.lang.Class internalFrameListeners[]; + private java.lang.reflect.Method removeInternalFrameMethod; + private java.lang.reflect.Method addInternalFrameMethod; + private java.lang.Object internalFrameArgs[]; + + /** + * internal variables for PropertyChange introspection + */ + private java.lang.Class propertyChangeListeners[]; + private java.lang.reflect.Method removePropertyChangeMethod; + private java.lang.reflect.Method addPropertyChangeMethod; + private java.lang.Object propertyChangeArgs[]; + + /** + * internal variables for a variety of change introspections + */ + private java.lang.Class nullClass[]; + private java.lang.Object nullArgs[]; + + /** + * Create a new instance of this class and install it on each component + * instance in the virtual machine that supports any of the currently + * registered listeners in SwingEventMonitor. Also registers itself + * as a TopLevelWindowListener with EventQueueMonitor so it can + * automatically add new listeners to new components. + * @see EventQueueMonitor + * @see SwingEventMonitor + */ + public SwingEventListener() { + initializeIntrospection(); + installListeners(); + EventQueueMonitor.addTopLevelWindowListener(this); + } + + /** + * Set up all of the variables needed for introspection + */ + private boolean initializeIntrospection() { + try { + caretListeners = new java.lang.Class[1]; + caretArgs = new java.lang.Object[1]; + caretListeners[0] = Class.forName("javax.swing.event.CaretListener"); + caretArgs[0] = this; + + cellEditorListeners = new java.lang.Class[1]; + cellEditorArgs = new java.lang.Object[1]; + cellEditorListeners[0] = Class.forName("javax.swing.event.CellEditorListener"); + cellEditorArgs[0] = this; + + changeListeners = new java.lang.Class[1]; + changeArgs = new java.lang.Object[1]; + changeListeners[0] = Class.forName("javax.swing.event.ChangeListener"); + changeArgs[0] = this; + + documentListeners = new java.lang.Class[1]; + documentArgs = new java.lang.Object[1]; + documentListeners[0] = Class.forName("javax.swing.event.DocumentListener"); + documentArgs[0] = this; + + listSelectionListeners = new java.lang.Class[1]; + listSelectionArgs = new java.lang.Object[1]; + listSelectionListeners[0] = Class.forName("javax.swing.event.ListSelectionListener"); + listSelectionArgs[0] = this; + + menuListeners = new java.lang.Class[1]; + menuArgs = new java.lang.Object[1]; + menuListeners[0] = Class.forName("javax.swing.event.MenuListener"); + menuArgs[0] = this; + + popupMenuListeners = new java.lang.Class[1]; + popupMenuArgs = new java.lang.Object[1]; + popupMenuListeners[0] = Class.forName("javax.swing.event.PopupMenuListener"); + popupMenuArgs[0] = this; + + treeExpansionListeners = new java.lang.Class[1]; + treeExpansionArgs = new java.lang.Object[1]; + treeExpansionListeners[0] = Class.forName("javax.swing.event.TreeExpansionListener"); + treeExpansionArgs[0] = this; + + treeSelectionListeners = new java.lang.Class[1]; + treeSelectionArgs = new java.lang.Object[1]; + treeSelectionListeners[0] = Class.forName("javax.swing.event.TreeSelectionListener"); + treeSelectionArgs[0] = this; + + undoableEditListeners = new java.lang.Class[1]; + undoableEditArgs = new java.lang.Object[1]; + undoableEditListeners[0] = Class.forName("javax.swing.event.UndoableEditListener"); + undoableEditArgs[0] = this; + + internalFrameListeners = new java.lang.Class[1]; + internalFrameArgs = new java.lang.Object[1]; + internalFrameListeners[0] = Class.forName("javax.swing.event.InternalFrameListener"); + internalFrameArgs[0] = this; + + nullClass = new java.lang.Class[0]; + nullArgs = new java.lang.Object[0]; + + } catch (ClassNotFoundException e) { + System.out.println("EXCEPTION - Class 'javax.swing.event.*' not in CLASSPATH"); + return false; + } + + try { + propertyChangeListeners = new java.lang.Class[1]; + propertyChangeArgs = new java.lang.Object[1]; + propertyChangeListeners[0] = Class.forName("java.beans.PropertyChangeListener"); + propertyChangeArgs[0] = this; + + } catch (ClassNotFoundException e) { + System.out.println("EXCEPTION - Class 'java.beans.*' not in CLASSPATH"); + return false; + } + + return true; + } + + /** + * Installs all appropriate Swing listeners to just the component. + * Also calls super (AWTEventsListener.installListeners()) to install + * the requested AWT listeners. + * @param c the component to add listeners to + */ + protected void installListeners(Component c) { + + // This SwingEventListener needs to be notified when a new + // Swing component has been added so it can add Swing listeners + // to these components. As a result, we always need a Container + // listener on every Container. + // + installListeners(c,EventID.CONTAINER); + + // conditionally install Swing listeners + // + if (SwingEventMonitor.listenerList.getListenerCount(AncestorListener.class) > 0) { + installListeners(c,EventID.ANCESTOR); + } + if (SwingEventMonitor.listenerList.getListenerCount(CaretListener.class) > 0) { + installListeners(c,EventID.CARET); + } + if (SwingEventMonitor.listenerList.getListenerCount(CellEditorListener.class) > 0) { + installListeners(c,EventID.CELLEDITOR); + } + if (SwingEventMonitor.listenerList.getListenerCount(ChangeListener.class) > 0) { + installListeners(c,EventID.CHANGE); + } + if (SwingEventMonitor.listenerList.getListenerCount(TableColumnModelListener.class) > 0) { + installListeners(c,EventID.COLUMNMODEL); + } + if (SwingEventMonitor.listenerList.getListenerCount(DocumentListener.class) > 0) { + installListeners(c,EventID.DOCUMENT); + } + if (SwingEventMonitor.listenerList.getListenerCount(ListDataListener.class) > 0) { + installListeners(c,EventID.LISTDATA); + } + if (SwingEventMonitor.listenerList.getListenerCount(ListSelectionListener.class) > 0) { + installListeners(c,EventID.LISTSELECTION); + } + if (SwingEventMonitor.listenerList.getListenerCount(MenuListener.class) > 0) { + installListeners(c,EventID.MENU); + } + if (SwingEventMonitor.listenerList.getListenerCount(PopupMenuListener.class) > 0) { + installListeners(c,EventID.POPUPMENU); + } + if (SwingEventMonitor.listenerList.getListenerCount(TableModelListener.class) > 0) { + installListeners(c,EventID.TABLEMODEL); + } + if (SwingEventMonitor.listenerList.getListenerCount(TreeExpansionListener.class) > 0) { + installListeners(c,EventID.TREEEXPANSION); + } + if (SwingEventMonitor.listenerList.getListenerCount(TreeModelListener.class) > 0) { + installListeners(c,EventID.TREEMODEL); + } + if (SwingEventMonitor.listenerList.getListenerCount(TreeSelectionListener.class) > 0) { + installListeners(c,EventID.TREESELECTION); + } + if (SwingEventMonitor.listenerList.getListenerCount(UndoableEditListener.class) > 0) { + installListeners(c,EventID.UNDOABLEEDIT); + } + if (SwingEventMonitor.listenerList.getListenerCount(InternalFrameListener.class) > 0) { + installListeners(c,EventID.INTERNALFRAME); + } + + // Conditionally install Beans listeners + // + if (SwingEventMonitor.listenerList.getListenerCount(PropertyChangeListener.class) > 0) { + installListeners(c,EventID.PROPERTYCHANGE); + } + if (SwingEventMonitor.listenerList.getListenerCount(VetoableChangeListener.class) > 0) { + installListeners(c,EventID.VETOABLECHANGE); + } + + // Now install the AWT listeners if needed. + // + super.installListeners(c); + } + + /** + * Installs all appropriate Swing listeners to the component and all its + * children. As a precaution, it always attempts to remove itself as + * a listener first so we're always guaranteed it will installed itself + * just once. + * @param c the component to add listeners to + * @param eventID the eventID to add listeners for + */ + protected void installListeners(Component c, int eventID) { + + // install the appropriate listener hook into this component + // + switch (eventID) { + + case EventID.CONTAINER: + if (c instanceof Container) { + ((Container) c).removeContainerListener(this); + ((Container) c).addContainerListener(this); + } + break; + + case EventID.ANCESTOR: + if (c instanceof JComponent) { + ((JComponent) c).removeAncestorListener(this); + ((JComponent) c).addAncestorListener(this); + } + break; + + case EventID.CARET: + try { + removeCaretMethod = c.getClass().getMethod( + "removeCaretListener", caretListeners); + addCaretMethod = c.getClass().getMethod( + "addCaretListener", caretListeners); + try { + removeCaretMethod.invoke(c, caretArgs); + addCaretMethod.invoke(c, caretArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + case EventID.CELLEDITOR: + // Look for components which support the getCellEditor method + // (e.g. JTable, JTree) + // + try { + getCellEditorMethod = c.getClass().getMethod( + "getCellEditorMethod", nullClass); + try { + Object o = getCellEditorMethod.invoke(c, nullArgs); + if (o != null && o instanceof CellEditor) { + ((CellEditor) o).removeCellEditorListener(this); + ((CellEditor) o).addCellEditorListener(this); + } + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + + // Look for components which support CellEditor listeners + // (no current example) + // + try { + removeCellEditorMethod = c.getClass().getMethod( + "removeCellEditorListener", cellEditorListeners); + addCellEditorMethod = c.getClass().getMethod( + "addCellEditorListener", cellEditorListeners); + try { + removeCellEditorMethod.invoke(c, cellEditorArgs); + addCellEditorMethod.invoke(c, cellEditorArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + case EventID.CHANGE: + // [[[FIXME: Need to add support for Style, StyleContext -pk]]] + + // Look for components which support Change listeners + // (e.g. AbstractButton, Caret, JProgressBar, JSlider, + // JTabbedpane, JTextComponent, JViewport) + // + try { + removeChangeMethod = c.getClass().getMethod( + "removeChangeListener", changeListeners); + addChangeMethod = c.getClass().getMethod( + "addChangeListener", changeListeners); + try { + removeChangeMethod.invoke(c, changeArgs); + addChangeMethod.invoke(c, changeArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + + // Look for components which support the getModel method + // whose model supports Change listeners + // (e.g. BoundedRangeModel, ButtonModel, SingleSelectionModel) + // + try { + getModelMethod = c.getClass().getMethod( + "getModel", nullClass); + try { + Object o = getModelMethod.invoke(c, nullArgs); + if (o != null) { + removeChangeMethod = o.getClass().getMethod( + "removeChangeListener", changeListeners); + addChangeMethod = o.getClass().getMethod( + "addChangeListener", changeListeners); + removeChangeMethod.invoke(o, changeArgs); + addChangeMethod.invoke(o, changeArgs); + } + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + + break; + + case EventID.COLUMNMODEL: + try { + getColumnModelMethod = c.getClass().getMethod( + "getTableColumnModel", nullClass); + try { + Object o = getColumnModelMethod.invoke(c, nullArgs); + if (o != null && o instanceof TableColumnModel) { + ((TableColumnModel) o).removeColumnModelListener(this); + ((TableColumnModel) o).addColumnModelListener(this); + } + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + case EventID.DOCUMENT: + // Look for components which support the getDocument method + // (e.g. JTextComponent) + // + try { + getDocumentMethod = c.getClass().getMethod( + "getDocument", nullClass); + try { + Object o = getDocumentMethod.invoke(c, nullArgs); + if (o != null && o instanceof Document) { + ((Document) o).removeDocumentListener(this); + ((Document) o).addDocumentListener(this); + } + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + + // Look for components which support Document listeners + // (no current example) + // + try { + removeDocumentMethod = c.getClass().getMethod( + "removeDocumentListener", documentListeners); + addDocumentMethod = c.getClass().getMethod( + "addDocumentListener", documentListeners); + try { + removeDocumentMethod.invoke(c, documentArgs); + addDocumentMethod.invoke(c, documentArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + // Add the monitor as a PropertyChangeListener for document + // change events from text components. + // + if (c instanceof JTextComponent) { + try { + removePropertyChangeMethod = c.getClass().getMethod( + "removePropertyChangeListener", + propertyChangeListeners); + addPropertyChangeMethod = c.getClass().getMethod( + "addPropertyChangeListener", + propertyChangeListeners); + try { + removePropertyChangeMethod.invoke(c, + propertyChangeArgs); + addPropertyChangeMethod.invoke(c, + propertyChangeArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + } + break; + + case EventID.LISTDATA: + case EventID.TABLEMODEL: + case EventID.TREEMODEL: + try { + getModelMethod = c.getClass().getMethod( + "getModel", nullClass); + try { + Object o = getModelMethod.invoke(c, nullArgs); + if (o != null) { + if (eventID == EventID.LISTDATA && + o instanceof ListModel) { + ((ListModel) o).removeListDataListener(this); + ((ListModel) o).addListDataListener(this); + } else if (eventID == EventID.TABLEMODEL && + o instanceof TableModel) { + ((TableModel) o).removeTableModelListener(this); + ((TableModel) o).addTableModelListener(this); + } else if ( + o instanceof TreeModel) { + ((TreeModel) o).removeTreeModelListener(this); + ((TreeModel) o).addTreeModelListener(this); + } + } + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + case EventID.LISTSELECTION: + // Look for components which support ListSelectionListeners + // (e.g. JList) + // + try { + removeListSelectionMethod = c.getClass().getMethod( + "removeListSelectionListener", listSelectionListeners); + addListSelectionMethod = c.getClass().getMethod( + "addListSelectionListener", listSelectionListeners); + try { + removeListSelectionMethod.invoke(c, listSelectionArgs); + addListSelectionMethod.invoke(c, listSelectionArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + + // Look for selection models which support ListSelectionListeners + // (e.g. JTable's selection model) + // + try { + getSelectionModelMethod = c.getClass().getMethod( + "getSelectionModel", nullClass); + try { + Object o = getSelectionModelMethod.invoke(c, nullArgs); + if (o != null && o instanceof ListSelectionModel) { + ((ListSelectionModel) o).removeListSelectionListener(this); + ((ListSelectionModel) o).addListSelectionListener(this); + } + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + case EventID.MENU: + try { + removeMenuMethod = c.getClass().getMethod( + "removeMenuListener", menuListeners); + addMenuMethod = c.getClass().getMethod( + "addMenuListener", menuListeners); + try { + removeMenuMethod.invoke(c, menuArgs); + addMenuMethod.invoke(c, menuArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + case EventID.POPUPMENU: + // Look for components which support PopupMenuListeners + // (e.g. JPopupMenu) + // + try { + removePopupMenuMethod = c.getClass().getMethod( + "removePopupMenuListener", popupMenuListeners); + addPopupMenuMethod = c.getClass().getMethod( + "addPopupMenuListener", popupMenuListeners); + try { + removePopupMenuMethod.invoke(c, popupMenuArgs); + addPopupMenuMethod.invoke(c, popupMenuArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + + // Look for components which support getPopupMenu + // (e.g. JMenu) + // + try { + getPopupMenuMethod = c.getClass().getMethod( + "getPopupMenu", nullClass); + try { + Object o = getPopupMenuMethod.invoke(c, nullArgs); + if (o != null) { + removePopupMenuMethod = o.getClass().getMethod( + "removePopupMenuListener", popupMenuListeners); + addPopupMenuMethod = o.getClass().getMethod( + "addPopupMenuListener", popupMenuListeners); + removePopupMenuMethod.invoke(o, popupMenuArgs); + addPopupMenuMethod.invoke(o, popupMenuArgs); + } + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + case EventID.TREEEXPANSION: + try { + removeTreeExpansionMethod = c.getClass().getMethod( + "removeTreeExpansionListener", treeExpansionListeners); + addTreeExpansionMethod = c.getClass().getMethod( + "addTreeExpansionListener", treeExpansionListeners); + try { + removeTreeExpansionMethod.invoke(c, treeExpansionArgs); + addTreeExpansionMethod.invoke(c, treeExpansionArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + case EventID.TREESELECTION: + try { + removeTreeSelectionMethod = c.getClass().getMethod( + "removeTreeSelectionListener", treeSelectionListeners); + addTreeSelectionMethod = c.getClass().getMethod( + "addTreeSelectionListener", treeSelectionListeners); + try { + removeTreeSelectionMethod.invoke(c, treeSelectionArgs); + addTreeSelectionMethod.invoke(c, treeSelectionArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + case EventID.UNDOABLEEDIT: + // Look for components which support the getDocument method + // (e.g. JTextComponent) + // + try { + getDocumentMethod = c.getClass().getMethod( + "getDocument", nullClass); + try { + Object o = getDocumentMethod.invoke(c, nullArgs); + if (o != null && o instanceof Document) { + ((Document) o).removeUndoableEditListener(this); + ((Document) o).addUndoableEditListener(this); + } + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + + // Look for components which support UndoableEdit listeners + // (no current example) + // + try { + removeUndoableEditMethod = c.getClass().getMethod( + "removeUndoableEditListener", undoableEditListeners); + addUndoableEditMethod = c.getClass().getMethod( + "addUndoableEditListener", undoableEditListeners); + try { + removeUndoableEditMethod.invoke(c, undoableEditArgs); + addUndoableEditMethod.invoke(c, undoableEditArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + case EventID.INTERNALFRAME: + // Look for components which support InternalFrame listeners + // (e.g. JInternalFrame) + // + try { + removeInternalFrameMethod = c.getClass().getMethod( + "removeInternalFrameListener", internalFrameListeners); + addInternalFrameMethod = c.getClass().getMethod( + "addInternalFrameListener", internalFrameListeners); + try { + removeInternalFrameMethod.invoke(c, internalFrameArgs); + addInternalFrameMethod.invoke(c, internalFrameArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + case EventID.PROPERTYCHANGE: + // Look for components which support PropertyChange listeners + // (e.g. JComponent) + // + try { + removePropertyChangeMethod = c.getClass().getMethod( + "removePropertyChangeListener", propertyChangeListeners); + addPropertyChangeMethod = c.getClass().getMethod( + "addPropertyChangeListener", propertyChangeListeners); + try { + removePropertyChangeMethod.invoke(c, propertyChangeArgs); + addPropertyChangeMethod.invoke(c, propertyChangeArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + + // Look for components which support the getSelectionModel method + // (e.g. JTextComponent) + // + try { + getSelectionModelMethod = c.getClass().getMethod( + "getSelectionModel", nullClass); + try { + Object o = getSelectionModelMethod.invoke(c, nullArgs); + if (o != null && o instanceof TreeSelectionModel) { + ((TreeSelectionModel) o).removePropertyChangeListener(this); + ((TreeSelectionModel) o).addPropertyChangeListener(this); + } + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + case EventID.VETOABLECHANGE: + if (c instanceof JComponent) { + ((JComponent) c).removeVetoableChangeListener(this); + ((JComponent) c).addVetoableChangeListener(this); + } + break; + + // Don't bother recursing the children if this isn't going to + // accomplish anything. + // + default: + return; + } + + if (c instanceof Container) { + int count = ((Container) c).getComponentCount(); + for (int i = 0; i < count; i++) { + installListeners(((Container) c).getComponent(i), eventID); + } + } + } + + /** + * Removes all listeners for the given component and all its children. + * @param c the component + */ + protected void removeListeners(Component c) { + + // conditionaly remove the Swing listeners + // + if (SwingEventMonitor.listenerList.getListenerCount(AncestorListener.class) > 0) { + removeListeners(c,EventID.ANCESTOR); + } + if (SwingEventMonitor.listenerList.getListenerCount(CaretListener.class) > 0) { + removeListeners(c,EventID.CARET); + } + if (SwingEventMonitor.listenerList.getListenerCount(CellEditorListener.class) > 0) { + removeListeners(c,EventID.CELLEDITOR); + } + if (SwingEventMonitor.listenerList.getListenerCount(ChangeListener.class) > 0) { + removeListeners(c,EventID.CHANGE); + } + if (SwingEventMonitor.listenerList.getListenerCount(TableColumnModelListener.class) > 0) { + removeListeners(c,EventID.COLUMNMODEL); + } + if (SwingEventMonitor.listenerList.getListenerCount(DocumentListener.class) > 0) { + removeListeners(c,EventID.DOCUMENT); + } + if (SwingEventMonitor.listenerList.getListenerCount(ListDataListener.class) > 0) { + removeListeners(c,EventID.LISTDATA); + } + if (SwingEventMonitor.listenerList.getListenerCount(ListSelectionListener.class) > 0) { + removeListeners(c,EventID.LISTSELECTION); + } + if (SwingEventMonitor.listenerList.getListenerCount(MenuListener.class) > 0) { + removeListeners(c,EventID.MENU); + } + if (SwingEventMonitor.listenerList.getListenerCount(PopupMenuListener.class) > 0) { + removeListeners(c,EventID.POPUPMENU); + } + if (SwingEventMonitor.listenerList.getListenerCount(TableModelListener.class) > 0) { + removeListeners(c,EventID.TABLEMODEL); + } + if (SwingEventMonitor.listenerList.getListenerCount(TreeExpansionListener.class) > 0) { + removeListeners(c,EventID.TREEEXPANSION); + } + if (SwingEventMonitor.listenerList.getListenerCount(TreeModelListener.class) > 0) { + removeListeners(c,EventID.TREEMODEL); + } + if (SwingEventMonitor.listenerList.getListenerCount(TreeSelectionListener.class) > 0) { + removeListeners(c,EventID.TREESELECTION); + } + if (SwingEventMonitor.listenerList.getListenerCount(UndoableEditListener.class) > 0) { + removeListeners(c,EventID.UNDOABLEEDIT); + } + if (SwingEventMonitor.listenerList.getListenerCount(InternalFrameListener.class) > 0) { + removeListeners(c,EventID.INTERNALFRAME); + } + + // conditionaly remove the beans listeners + // + if (SwingEventMonitor.listenerList.getListenerCount(PropertyChangeListener.class) > 0) { + removeListeners(c,EventID.PROPERTYCHANGE); + } + if (SwingEventMonitor.listenerList.getListenerCount(VetoableChangeListener.class) > 0) { + removeListeners(c,EventID.VETOABLECHANGE); + } + + // Now remove the AWT listeners if needed. + // + super.removeListeners(c); + } + + /** + * Removes all Swing listeners for the event ID from the component and + * all of its children. + * @param c the component to remove listeners from + */ + protected void removeListeners(Component c, int eventID) { + + // remove the appropriate listener hook into this component + // + switch (eventID) { + + case EventID.CONTAINER: + //Never remove these because we're always interested in them + // for our own use. + break; + + case EventID.ANCESTOR: + if (c instanceof JComponent) { + ((JComponent) c).removeAncestorListener(this); + } + break; + + case EventID.CARET: + try { + removeCaretMethod = c.getClass().getMethod( + "removeCaretListener", caretListeners); + try { + removeCaretMethod.invoke(c, caretArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + case EventID.CELLEDITOR: + // Look for components which support the getCellEditor method + // (e.g. JTable, JTree) + // + try { + getCellEditorMethod = c.getClass().getMethod( + "getCellEditorMethod", nullClass); + try { + Object o = getCellEditorMethod.invoke(c, nullArgs); + if (o != null && o instanceof CellEditor) { + ((CellEditor) o).removeCellEditorListener(this); + } + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + + // Look for components which support CellEditor listeners + // (no current example) + // + try { + removeCellEditorMethod = c.getClass().getMethod( + "removeCellEditorListener", cellEditorListeners); + try { + removeCellEditorMethod.invoke(c, cellEditorArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + case EventID.CHANGE: + // [[[FIXME: Need to add support for Style, StyleContext -pk ]]] + + // Look for components which support Change listeners + // (e.g. AbstractButton, Caret, JProgressBar, JSlider, + // JTabbedpane, JTextComponent, JViewport) + // + try { + removeChangeMethod = c.getClass().getMethod( + "removeChangeListener", changeListeners); + try { + removeChangeMethod.invoke(c, changeArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + + // Look for components which support the getModel method + // whose model supports Change listeners + // (e.g. BoundedRangeModel, ButtonModel, SingleSelectionModel) + // + try { + getModelMethod = c.getClass().getMethod( + "getModel", nullClass); + try { + Object o = getModelMethod.invoke(c, nullArgs); + if (o != null) { + removeChangeMethod = o.getClass().getMethod( + "removeChangeListener", changeListeners); + removeChangeMethod.invoke(o, changeArgs); + } + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + case EventID.COLUMNMODEL: + try { + getColumnModelMethod = c.getClass().getMethod( + "getTableColumnModel", nullClass); + try { + Object o = getColumnModelMethod.invoke(c, nullArgs); + if (o != null && o instanceof TableColumnModel) { + ((TableColumnModel) o).removeColumnModelListener(this); + } + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + case EventID.DOCUMENT: + // Look for components which support the getDocument method + // (e.g. JTextComponent) + // + try { + getDocumentMethod = c.getClass().getMethod( + "getDocument", nullClass); + try { + Object o = getDocumentMethod.invoke(c, nullArgs); + if (o != null && o instanceof Document) { + ((Document) o).removeDocumentListener(this); + } + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + + // Look for components which support Document listeners + // (no current example) + // + try { + removeDocumentMethod = c.getClass().getMethod( + "removeDocumentListener", documentListeners); + try { + removeDocumentMethod.invoke(c, documentArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + case EventID.LISTDATA: + case EventID.TABLEMODEL: + case EventID.TREEMODEL: + try { + getModelMethod = c.getClass().getMethod( + "getModel", nullClass); + try { + Object o = getModelMethod.invoke(c, nullArgs); + if (o != null) { + if (eventID == EventID.LISTDATA && + o instanceof ListModel) { + ((ListModel) o).removeListDataListener(this); + } else if (eventID == EventID.TABLEMODEL && + o instanceof TableModel) { + ((TableModel) o).removeTableModelListener(this); + } else if ( + o instanceof TreeModel) { + ((TreeModel) o).removeTreeModelListener(this); + } + } + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + case EventID.LISTSELECTION: + // Look for components which support ListSelectionListeners + // (e.g. JList) + // + try { + removeListSelectionMethod = c.getClass().getMethod( + "removeListSelectionListener", listSelectionListeners); + try { + removeListSelectionMethod.invoke(c, listSelectionArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + + // Look for selection models which support + // ListSelectionListeners (e.g. JTable's selection model) + // + try { + getSelectionModelMethod = c.getClass().getMethod( + "getSelectionModel", nullClass); + try { + Object o = getSelectionModelMethod.invoke(c, nullArgs); + if (o != null && o instanceof ListSelectionModel) { + ((ListSelectionModel) o).removeListSelectionListener(this); + } + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + case EventID.MENU: + try { + removeMenuMethod = c.getClass().getMethod( + "removeMenuListener", menuListeners); + try { + removeMenuMethod.invoke(c, menuArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + case EventID.POPUPMENU: + // Look for components which support PopupMenuListeners + // (e.g. JPopupMenu) + // + try { + removePopupMenuMethod = c.getClass().getMethod( + "removePopupMenuListener", popupMenuListeners); + try { + removePopupMenuMethod.invoke(c, popupMenuArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + + // Look for components which support getPopupMenu + // (e.g. JMenu) + // + try { + getPopupMenuMethod = c.getClass().getMethod( + "getPopupMenu", nullClass); + try { + Object o = getPopupMenuMethod.invoke(c, nullArgs); + if (o != null) { + removePopupMenuMethod = o.getClass().getMethod( + "removePopupMenuListener", popupMenuListeners); + removePopupMenuMethod.invoke(o, popupMenuArgs); + } + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + case EventID.TREEEXPANSION: + try { + removeTreeExpansionMethod = c.getClass().getMethod( + "removeTreeExpansionListener", treeExpansionListeners); + try { + removeTreeExpansionMethod.invoke(c, treeExpansionArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + case EventID.TREESELECTION: + try { + removeTreeSelectionMethod = c.getClass().getMethod( + "removeTreeSelectionListener", treeSelectionListeners); + try { + removeTreeSelectionMethod.invoke(c, treeSelectionArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + case EventID.UNDOABLEEDIT: + // Look for components which support the getDocument method + // (e.g. JTextComponent) + // + try { + getDocumentMethod = c.getClass().getMethod( + "getDocument", nullClass); + try { + Object o = getDocumentMethod.invoke(c, nullArgs); + if (o != null && o instanceof Document) { + ((Document) o).removeUndoableEditListener(this); + } + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + + // Look for components which support UndoableEdit listeners + // (no current example) + // + try { + removeUndoableEditMethod = c.getClass().getMethod( + "removeUndoableEditListener", undoableEditListeners); + try { + removeUndoableEditMethod.invoke(c, undoableEditArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + case EventID.INTERNALFRAME: + try { + removeInternalFrameMethod = c.getClass().getMethod( + "removeInternalFrameListener", internalFrameListeners); + try { + removeInternalFrameMethod.invoke(c, internalFrameArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + case EventID.PROPERTYCHANGE: + // Look for components which support PropertyChange listeners + // (e.g. JComponent) + // + try { + removePropertyChangeMethod = c.getClass().getMethod( + "removePropertyChangeListener", propertyChangeListeners); + try { + removePropertyChangeMethod.invoke(c, propertyChangeArgs); + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + + // Look for components which support the getSelectionModel + // method (e.g. JTextComponent) + // + try { + getSelectionModelMethod = c.getClass().getMethod( + "getSelectionModel", nullClass); + try { + Object o = getSelectionModelMethod.invoke(c, nullArgs); + if (o != null && o instanceof TreeSelectionModel) { + ((TreeSelectionModel) o).removePropertyChangeListener(this); + } + } catch (java.lang.reflect.InvocationTargetException e) { + System.out.println("Exception: " + e.toString()); + } catch (IllegalAccessException e) { + System.out.println("Exception: " + e.toString()); + } + } catch (NoSuchMethodException e) { + // System.out.println("Exception: " + e.toString()); + } catch (SecurityException e) { + System.out.println("Exception: " + e.toString()); + } + break; + + case EventID.VETOABLECHANGE: + if (c instanceof JComponent) { + ((JComponent) c).removeVetoableChangeListener(this); + } + break; + + default: + return; + } + + if (c instanceof Container) { + int count = ((Container) c).getComponentCount(); + for (int i = 0; i < count; i++) { + removeListeners(((Container) c).getComponent(i), eventID); + } + } + } + + /********************************************************************/ + /* */ + /* Listener Interface Methods */ + /* */ + /********************************************************************/ + + /* ContainerListener Methods ************************************/ + + public void componentAdded(ContainerEvent e) { + installListeners(e.getChild()); + } + public void componentRemoved(ContainerEvent e) { + removeListeners(e.getChild()); + } + + /* AncestorListener Methods ******************************************/ + + public void ancestorAdded(AncestorEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==AncestorListener.class) { + ((AncestorListener)listeners[i+1]).ancestorAdded(e); + } + } + } + + public void ancestorRemoved(AncestorEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==AncestorListener.class) { + ((AncestorListener)listeners[i+1]).ancestorRemoved(e); + } + } + } + + public void ancestorMoved(AncestorEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==AncestorListener.class) { + ((AncestorListener)listeners[i+1]).ancestorMoved(e); + } + } + } + + /* CaretListener Methods ******************************************/ + + public void caretUpdate(CaretEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==CaretListener.class) { + ((CaretListener)listeners[i+1]).caretUpdate(e); + } + } + } + + /* CellEditorListener Methods *****************************************/ + + public void editingStopped(ChangeEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==CellEditorListener.class) { + ((CellEditorListener)listeners[i+1]).editingStopped(e); + } + } + } + + public void editingCanceled(ChangeEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==CellEditorListener.class) { + ((CellEditorListener)listeners[i+1]).editingCanceled(e); + } + } + } + + /* ChangeListener Methods *****************************************/ + + public void stateChanged(ChangeEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==ChangeListener.class) { + ((ChangeListener)listeners[i+1]).stateChanged(e); + } + } + } + + /* TableColumnModelListener Methods *******************************/ + + public void columnAdded(TableColumnModelEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==TableColumnModelListener.class) { + ((TableColumnModelListener)listeners[i+1]).columnAdded(e); + } + } + } + public void columnMarginChanged(ChangeEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==TableColumnModelListener.class) { + ((TableColumnModelListener)listeners[i+1]).columnMarginChanged(e); + } + } + } + public void columnMoved(TableColumnModelEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==TableColumnModelListener.class) { + ((TableColumnModelListener)listeners[i+1]).columnMoved(e); + } + } + } + public void columnRemoved(TableColumnModelEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==TableColumnModelListener.class) { + ((TableColumnModelListener)listeners[i+1]).columnRemoved(e); + } + } + } + public void columnSelectionChanged(ListSelectionEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==TableColumnModelListener.class) { + ((TableColumnModelListener)listeners[i+1]).columnSelectionChanged(e); + } + } + } + + /* DocumentListener Methods **************************************/ + + public void changedUpdate(DocumentEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==DocumentListener.class) { + ((DocumentListener)listeners[i+1]).changedUpdate(e); + } + } + } + public void insertUpdate(DocumentEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==DocumentListener.class) { + ((DocumentListener)listeners[i+1]).insertUpdate(e); + } + } + } + public void removeUpdate(DocumentEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==DocumentListener.class) { + ((DocumentListener)listeners[i+1]).removeUpdate(e); + } + } + } + + /* ListDataListener Methods *****************************************/ + + public void contentsChanged(ListDataEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==ListDataListener.class) { + ((ListDataListener)listeners[i+1]).contentsChanged(e); + } + } + } + public void intervalAdded(ListDataEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==ListDataListener.class) { + ((ListDataListener)listeners[i+1]).intervalAdded(e); + } + } + } + public void intervalRemoved(ListDataEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==ListDataListener.class) { + ((ListDataListener)listeners[i+1]).intervalRemoved(e); + } + } + } + + /* ListSelectionListener Methods ***********************************/ + + public void valueChanged(ListSelectionEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==ListSelectionListener.class) { + ((ListSelectionListener)listeners[i+1]).valueChanged(e); + } + } + } + + /* MenuListener Methods *****************************************/ + + public void menuCanceled(MenuEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==MenuListener.class) { + ((MenuListener)listeners[i+1]).menuCanceled(e); + } + } + } + public void menuDeselected(MenuEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==MenuListener.class) { + ((MenuListener)listeners[i+1]).menuDeselected(e); + } + } + } + public void menuSelected(MenuEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==MenuListener.class) { + ((MenuListener)listeners[i+1]).menuSelected(e); + } + } + } + + /* PopupMenuListener Methods **************************************/ + + public void popupMenuWillBecomeVisible(PopupMenuEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==PopupMenuListener.class) { + ((PopupMenuListener)listeners[i+1]).popupMenuWillBecomeVisible(e); + } + } + } + + public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==PopupMenuListener.class) { + ((PopupMenuListener)listeners[i+1]).popupMenuWillBecomeInvisible(e); + } + } + } + + public void popupMenuCanceled(PopupMenuEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==PopupMenuListener.class) { + ((PopupMenuListener)listeners[i+1]).popupMenuCanceled(e); + } + } + } + + /* TableModelListener Methods **************************************/ + + public void tableChanged(TableModelEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==TableModelListener.class) { + ((TableModelListener)listeners[i+1]).tableChanged(e); + } + } + } + + /* TreeExpansionListener Methods **********************************/ + + public void treeCollapsed(TreeExpansionEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==TreeExpansionListener.class) { + ((TreeExpansionListener)listeners[i+1]).treeCollapsed(e); + } + } + } + public void treeExpanded(TreeExpansionEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==TreeExpansionListener.class) { + ((TreeExpansionListener)listeners[i+1]).treeExpanded(e); + } + } + } + + /* TreeModelListener Methods **********************************/ + + public void treeNodesChanged(TreeModelEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==TreeModelListener.class) { + ((TreeModelListener)listeners[i+1]).treeNodesChanged(e); + } + } + } + public void treeNodesInserted(TreeModelEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==TreeModelListener.class) { + ((TreeModelListener)listeners[i+1]).treeNodesInserted(e); + } + } + } + public void treeNodesRemoved(TreeModelEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==TreeModelListener.class) { + ((TreeModelListener)listeners[i+1]).treeNodesRemoved(e); + } + } + } + public void treeStructureChanged(TreeModelEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==TreeModelListener.class) { + ((TreeModelListener)listeners[i+1]).treeStructureChanged(e); + } + } + } + + /* TreeSelectionListener Methods ***********************************/ + + public void valueChanged(TreeSelectionEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==TreeSelectionListener.class) { + ((TreeSelectionListener)listeners[i+1]).valueChanged(e); + } + } + } + + /* UndoableEditListener Methods **************************************/ + + public void undoableEditHappened(UndoableEditEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==UndoableEditListener.class) { + ((UndoableEditListener)listeners[i+1]).undoableEditHappened(e); + } + } + } + + /* InternalFrame Methods **********************************/ + + public void internalFrameOpened(InternalFrameEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==InternalFrameListener.class) { + ((InternalFrameListener)listeners[i+1]).internalFrameOpened(e); + } + } + } + + public void internalFrameActivated(InternalFrameEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==InternalFrameListener.class) { + ((InternalFrameListener)listeners[i+1]).internalFrameActivated(e); + } + } + } + + public void internalFrameDeactivated(InternalFrameEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==InternalFrameListener.class) { + ((InternalFrameListener)listeners[i+1]).internalFrameDeactivated(e); + } + } + } + + public void internalFrameIconified(InternalFrameEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==InternalFrameListener.class) { + ((InternalFrameListener)listeners[i+1]).internalFrameIconified(e); + } + } + } + + public void internalFrameDeiconified(InternalFrameEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==InternalFrameListener.class) { + ((InternalFrameListener)listeners[i+1]).internalFrameDeiconified(e); + } + } + } + + public void internalFrameClosing(InternalFrameEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==InternalFrameListener.class) { + ((InternalFrameListener)listeners[i+1]).internalFrameClosing(e); + } + } + } + + public void internalFrameClosed(InternalFrameEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==InternalFrameListener.class) { + ((InternalFrameListener)listeners[i+1]).internalFrameClosed(e); + } + } + } + + /* PropertyChangeListener Methods **********************************/ + + public void propertyChange(PropertyChangeEvent e) { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==PropertyChangeListener.class) { + ((PropertyChangeListener)listeners[i+1]).propertyChange(e); + } + } + // Re-add the monitor as a DocumentChangeListener if + // the document changed in the text component. + if (e.getSource() instanceof JTextComponent) { + Document c = ((JTextComponent)e.getSource()).getDocument(); + if (c == null) { + return; + } + try { + removeDocumentMethod = c.getClass().getMethod( + "removeDocumentListener", documentListeners); + addDocumentMethod = c.getClass().getMethod( + "addDocumentListener", documentListeners); + try { + removeDocumentMethod.invoke(c, documentArgs); + addDocumentMethod.invoke(c, documentArgs); + } catch (java.lang.reflect.InvocationTargetException e2) { + System.out.println("Exception: " + e2.toString()); + } catch (IllegalAccessException e2) { + System.out.println("Exception: " + e2.toString()); + } + } catch (NoSuchMethodException e2) { + // System.out.println("Exception: " + e2.toString()); + } catch (SecurityException e2) { + System.out.println("Exception: " + e2.toString()); + } + } + + } + + /* VetoableChangeListener Methods **********************************/ + + public void vetoableChange(PropertyChangeEvent e) + throws PropertyVetoException { + Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==VetoableChangeListener.class) { + ((VetoableChangeListener)listeners[i+1]).vetoableChange(e); + } + } + } + } +} diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/java/accessibility/util/TopLevelWindowListener.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/java/accessibility/util/TopLevelWindowListener.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.java.accessibility.util; + +import java.awt.*; +import java.util.*; +import javax.accessibility.*; + +/** + * The {@code TopLevelWindowListener} interface is used by the {@link EventQueueMonitor} + * class to notify an interested party when a top level window is created + * or destroyed in the Java Virtual Machine. Classes wishing to express + * an interest in top level window events should implement this interface + * and register themselves with the {@code EventQueueMonitor} by calling the + * {@link EventQueueMonitor#addTopLevelWindowListener EventQueueMonitor.addTopLevelWindowListener} + * class method. + * + * @see EventQueueMonitor + * @see EventQueueMonitor#addTopLevelWindowListener + * @see EventQueueMonitor#removeTopLevelWindowListener + * + */ +@jdk.Exported +public interface TopLevelWindowListener extends EventListener { + + /** + * Invoked when a new top level window has been created. + * + * @param w the Window that was created + */ + public void topLevelWindowCreated(Window w); + + /** + * Invoked when a top level window has been destroyed. + * + * @param w the Window that was destroyed + */ + public void topLevelWindowDestroyed(Window w); +} diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/java/accessibility/util/TopLevelWindowMulticaster.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/java/accessibility/util/TopLevelWindowMulticaster.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.java.accessibility.util; + +import java.awt.*; +import java.util.EventListener; +import javax.accessibility.*; + + +/** + * The TopLevelWindowMulticaster class is used to maintain a list of + * TopLevelWindowListener classes. It is intended to be used primarily + * for internal support in the EventQueueMonitor class, and is not intended + * to be used by classes outside the Java Accessibility Utility package. + * + * @see EventQueueMonitor + * @see EventQueueMonitor#addTopLevelWindowListener + * @see EventQueueMonitor#removeTopLevelWindowListener + * + */ +@jdk.Exported(false) +public class TopLevelWindowMulticaster + extends AWTEventMulticaster implements TopLevelWindowListener +{ + protected TopLevelWindowMulticaster(EventListener a, EventListener b) { + super(a, b); + } + + public void topLevelWindowCreated(Window w) { + ((TopLevelWindowListener)a).topLevelWindowCreated(w); + ((TopLevelWindowListener)b).topLevelWindowCreated(w); + } + + public void topLevelWindowDestroyed(Window w) { + ((TopLevelWindowListener)a).topLevelWindowDestroyed(w); + ((TopLevelWindowListener)b).topLevelWindowDestroyed(w); + } + + public static TopLevelWindowListener add(TopLevelWindowListener a, TopLevelWindowListener b) { + return (TopLevelWindowListener)addInternal(a, b); + } + + public static TopLevelWindowListener remove(TopLevelWindowListener l, TopLevelWindowListener oldl) { + return (TopLevelWindowListener)removeInternal(l, oldl); + } + + protected static EventListener addInternal(EventListener a, EventListener b) { + if (a == null) return b; + if (b == null) return a; + return new TopLevelWindowMulticaster(a, b); + } + + protected static EventListener removeInternal(EventListener l, EventListener oldl) { + if (l == oldl || l == null) { + return null; + } else if (l instanceof TopLevelWindowMulticaster) { + return ((TopLevelWindowMulticaster)l).remove(oldl); + } else { + return l; // it's not here + } + } + +} diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/java/accessibility/util/Translator.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/java/accessibility/util/Translator.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,730 @@ +/* + * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +package com.sun.java.accessibility.util; + +import java.lang.*; +import java.beans.*; +import java.util.*; +import java.awt.*; +import java.awt.event.*; +import java.awt.image.*; +// Do not import Swing classes. This module is intended to work +// with both Swing and AWT. +// import javax.swing.*; +import javax.accessibility.*; + +/** + *

The {@code Translator} class provides a translation to interface + * {@link javax.accessibility.Accessible Accessible} + * for objects that do not implement interface {@code Accessible}. Assistive + * technologies can use the {@link #getAccessible getAccessible} class method of + * {@code Translator} to obtain an object that implements interface {@code Accessible}. + * If the object passed in already implements interface {@code Accessible}, + * {@code getAccessible} merely returns the object. + * + *

An example of how an assistive technology might use the {@code Translator} + * class is as follows: + * + *

+ *    Accessible accessible = Translator.getAccessible(someObj);
+ *    // obtain information from the 'accessible' object.
+ * 
+ * + *

Note: This implementation is missing many things and is not a recommended way + * to implement accessibility features for a toolkit. Instead of relying upon this + * code, a toolkit's components should implement interface {@code Accessible} directly. + */ +@jdk.Exported +public class Translator extends AccessibleContext + implements Accessible, AccessibleComponent { + + /** The source object needing translating. */ + protected Object source; + + /** + * Find a translator for this class. If one doesn't exist for this + * class explicitly, try its superclass and so on. + * + * @param c a Class + * @return the {@code Translator} Class for the Class passed in + */ + protected static Class getTranslatorClass(Class c) { + Class t = null; + if (c == null) { + return null; + } + try { + t = Class.forName("com.sun.java.accessibility.util." + + c.getName() + + "Translator"); + return t; + } catch (Exception e) { + return getTranslatorClass(c.getSuperclass()); + } + } + + /** + * Obtain an object that implements interface {@code Accessible}. If the object + * passed in already implements interface {@code Accessible}, {@code getAccessible} + * merely returns the object. + * + * @param o an Object; if a null is passed in a null is returned + * @return an {@code Object}, possibly the {@code Object} passed in, that + * implements the {@code Accessible} interface for the {@code Object} + * which was passed in + */ + public static Accessible getAccessible(Object o) { + Accessible a = null; + + if (o == null) { + return null; + } + if (o instanceof Accessible) { + a = (Accessible)o; + } else { + Class translatorClass = getTranslatorClass(o.getClass()); + if (translatorClass != null) { + try { + Translator t = (Translator)translatorClass.newInstance(); + t.setSource(o); + a = t; + } catch (Exception e) { + } + } + } + if (a == null) { + a = new Translator(o); + } + return a; + } + + /** + * Create a new {@code Translator}. You must call the {@link #setSource setSource} + * method to set the object to be translated after calling this constructor. + */ + public Translator() { + } + + /** + * Create a new {@code Translator} with the source object o. + * + * @param o the Component that does not implement interface + * {@link javax.accessibility.Accessible Accessible} + */ + public Translator(Object o) { + source = o; + } + + /** + * Get the source {@code Object} of the {@code Translator}. + * + * @return the source {@code Object} of the {@code Translator} + */ + public Object getSource() { + return source; + } + + /** + * Set the source object of the {@code Translator}. + * + * @param o the Component that does not implement interface Accessible + */ + public void setSource(Object o) { + source = o; + } + + /** + * Returns true if this object is the same as the one passed in. + * + * @param o the {@code Object} to check against + * @return true if this is the same object + */ + public boolean equals(Object o) { + return source.equals(o); + } + + +// Accessible methods + + /** + * Returns this object. + */ + public AccessibleContext getAccessibleContext() { + return this; + } + +// AccessibleContext methods + + /** + * Get the accessible name of this object. + * + * @return the localized name of the object; can be null if this object + * does not have a name + */ + public String getAccessibleName() { + if (source instanceof MenuItem) { + return ((MenuItem) source).getLabel(); + } else if (source instanceof Component) { + return ((Component) source).getName(); + } else { + return null; + } + } + + /** + * Set the name of this object. + */ + public void setAccessibleName(String s) { + if (source instanceof MenuItem) { + ((MenuItem) source).setLabel(s); + } else if (source instanceof Component) { + ((Component) source).setName(s); + } + } + + /** + * Get the accessible description of this object. + * + * @return the description of the object; can be null if this object does + * not have a description + */ + public String getAccessibleDescription() { + return null; + } + + /** + * Set the accessible description of this object. + * + * @param s the new localized description of the object + */ + public void setAccessibleDescription(String s) { + } + + /** + * Get the role of this object. + * + * @return an instance of AccessibleRole describing the role of the object + */ + public AccessibleRole getAccessibleRole() { + return AccessibleRole.UNKNOWN; + } + + + /** + * Get the state of this object, given an already populated state. + * This method is intended for use by subclasses so they don't have + * to check for everything. + * + * @return an instance of {@code AccessibleStateSet} + * containing the current state of the object + */ + public AccessibleStateSet getAccessibleStateSet() { + AccessibleStateSet states = new AccessibleStateSet(); + if (source instanceof Component) { + Component c = (Component) source; + for (Container p = c.getParent(); p != null; p = p.getParent()) { + if (p instanceof Window) { + if (((Window)p).getFocusOwner() == c) { + states.add(AccessibleState.FOCUSED); + } + } + } + } + if (isEnabled()) { + states.add(AccessibleState.ENABLED); + } + if (isFocusTraversable()) { + states.add(AccessibleState.FOCUSABLE); + } + if (source instanceof MenuItem) { + states.add(AccessibleState.FOCUSABLE); + } + return states; + } + + /** + * Get the accessible parent of this object. + * + * @return the accessible parent of this object; can be null if this + * object does not have an accessible parent + */ + public Accessible getAccessibleParent() { + if (accessibleParent != null) { + return accessibleParent; + } else if (source instanceof Component) { + return getAccessible(((Component) source).getParent()); + } else { + return null; + } + } + + /** + * Get the index of this object in its accessible parent. + * + * @return -1 of this object does not have an accessible parent; otherwise, + * the index of the child in its accessible parent + */ + public int getAccessibleIndexInParent() { + if (source instanceof Component) { + Container parent = ((Component) source).getParent(); + if (parent != null) { + Component ca[] = parent.getComponents(); + for (int i = 0; i < ca.length; i++) { + if (source.equals(ca[i])) { + return i; + } + } + } + } + return -1; + } + + /** + * Returns the number of accessible children in the object. + * + * @return the number of accessible children in the object + */ + public int getAccessibleChildrenCount() { + if (source instanceof Container) { + Component[] children = ((Container) source).getComponents(); + int count = 0; + for (int i = 0; i < children.length; i++) { + Accessible a = getAccessible(children[i]); + if (a != null) { + count++; + } + } + return count; + } else { + return 0; + } + } + + /** + * Return the nth accessible child of the object. + * + * @param i zero-based index of child + * @return the nth accessible child of the object + */ + public Accessible getAccessibleChild(int i) { + if (source instanceof Container) { + Component[] children = ((Container) source).getComponents(); + int count = 0; + + for (int j = 0; j < children.length; j++) { + Accessible a = getAccessible(children[j]); + if (a != null) { + if (count == i) { + AccessibleContext ac = a.getAccessibleContext(); + if (ac != null) { + ac.setAccessibleParent(this); + } + return a; + } else { + count++; + } + } + } + } + return null; + } + + /** + * Gets the {@code Locale} of the component. If the component does not have a + * locale, the locale of its parent is returned. + * + * @return the {@code Locale} of the object + */ + public Locale getLocale() throws IllegalComponentStateException { + if (source instanceof Component) { + return ((Component) source).getLocale(); + } else { + return null; + } + } + + /** + * Add a {@code PropertyChangeListener} to the listener list. The listener + * is registered for all properties. + */ + public void addPropertyChangeListener(PropertyChangeListener l) { + } + + /** + * Remove the {@code PropertyChangeListener} from the listener list. + */ + public void removePropertyChangeListener(PropertyChangeListener l) { + } + +// AccessibleComponent methods + + /** + * Get the background {@code Color} of this object. + * + * @return if supported, the background {@code Color} of the object; + * otherwise, null + * + */ + public Color getBackground() { + if (source instanceof Component) { // MenuComponent doesn't do background + return ((Component) source).getBackground(); + } else { + return null; + } + } + + /** + * Set the background {@code Color} of this object. + * + * @param c the new {@code Color} for the background + */ + public void setBackground(Color c) { + if (source instanceof Component) { // MenuComponent doesn't do background + ((Component) source).setBackground(c); + } + } + + /** + * Get the foreground {@code Color} of this object. + * + * @return if supported, the foreground {@code Color} of the object; otherwise, null + */ + public Color getForeground() { + if (source instanceof Component) { // MenuComponent doesn't do foreground + return ((Component) source).getForeground(); + } else { + return null; + } + } + + /** + * Set the foreground {@code Color} of this object. + * + * @param c the new {@code Color} for the foreground + */ + public void setForeground(Color c) { + if (source instanceof Component) { // MenuComponent doesn't do foreground + ((Component) source).setForeground(c); + } + } + + /** + * Get the {@code Cursor} of this object. + * + * @return if supported, the Cursor of the object; otherwise, null + */ + public Cursor getCursor() { + if (source instanceof Component) { // MenuComponent doesn't do cursor + return ((Component) source).getCursor(); + } else { + return null; + } + } + + /** + * Set the {@code Cursor} of this object. + * @param c the new {@code Cursor} for the object + */ + public void setCursor(Cursor c) { + if (source instanceof Component) { // MenuComponent doesn't do cursor + ((Component) source).setCursor(c); + } + } + + /** + * Get the {@code Font} of this object. + * + * @return if supported, the {@code Font} for the object; otherwise, null + */ + public Font getFont() { + if (source instanceof Component) { + return ((Component) source).getFont(); + } else if (source instanceof MenuComponent) { + return ((MenuComponent) source).getFont(); + } else { + return null; + } + } + + /** + * Set the {@code Font} of this object. + * + * @param f the new {@code Font} for the object + */ + public void setFont(Font f) { + if (source instanceof Component) { + ((Component) source).setFont(f); + } else if (source instanceof MenuComponent) { + ((MenuComponent) source).setFont(f); + } + } + + /** + * Get the {@code FontMetrics} of this object. + * + * @param f the {@code Font} + * @return if supported, the {@code FontMetrics} the object; otherwise, null + * @see #getFont + */ + public FontMetrics getFontMetrics(Font f) { + if (source instanceof Component) { + return ((Component) source).getFontMetrics(f); + } else { + return null; + } + } + + /** + * Determine if the object is enabled. + * + * @return true if object is enabled; otherwise, false + */ + public boolean isEnabled() { + if (source instanceof Component) { + return ((Component) source).isEnabled(); + } else if (source instanceof MenuItem) { + return ((MenuItem) source).isEnabled(); + } else { + return true; + } + } + + /** + * Set the enabled state of the object. + * + * @param b if true, enables this object; otherwise, disables it + */ + public void setEnabled(boolean b) { + if (source instanceof Component) { + ((Component) source).setEnabled(b); + } else if (source instanceof MenuItem) { + ((MenuItem) source).setEnabled(b); + } + } + + /** + * Determine if the object is visible. + * + * @return true if object is visible; otherwise, false + */ + public boolean isVisible() { + if (source instanceof Component) { + return ((Component) source).isVisible(); + } else { + return false; + } + } + + /** + * Set the visible state of the object. + * + * @param b if true, shows this object; otherwise, hides it + */ + public void setVisible(boolean b) { + if (source instanceof Component) { + ((Component) source).setVisible(b); + } + } + + /** + * Determine if the object is showing. This is determined by checking + * the visibility of the object and ancestors of the object. + * + * @return true if object is showing; otherwise, false + */ + public boolean isShowing() { + if (source instanceof Component) { + return ((Component) source).isShowing(); + } else { + return false; + } + } + + /** + * Checks whether the specified {@code Point} is within this + * object's bounds, where the {@code Point} is relative to the coordinate + * system of the object. + * + * @param p the {@code Point} relative to the coordinate system of the object + * @return true if object contains {@code Point}; otherwise false + */ + public boolean contains(Point p) { + if (source instanceof Component) { + return ((Component) source).contains(p); + } else { + return false; + } + } + + /** + * Returns the location of the object on the screen. + * + * @return location of object on screen; can be null if this object + * is not on the screen + */ + public Point getLocationOnScreen() { + if (source instanceof Component) { + return ((Component) source).getLocationOnScreen(); + } else { + return null; + } + } + + /** + * Returns the location of the object relative to parent. + * + * @return location of object relative to parent; can be null if + * this object or its parent are not on the screen + */ + public Point getLocation() { + if (source instanceof Component) { + return ((Component) source).getLocation(); + } else { + return null; + } + } + + /** + * Sets the location of the object relative to parent. + */ + public void setLocation(Point p) { + if (source instanceof Component) { + ((Component) source).setLocation(p); + } + } + + /** + * Returns the current bounds of this object. + * + * @return current bounds of object; can be null if this object + * is not on the screen + */ + public Rectangle getBounds() { + if (source instanceof Component) { + return ((Component) source).getBounds(); + } else { + return null; + } + } + + /** + * Sets the current bounds of this object. + */ + public void setBounds(Rectangle r) { + if (source instanceof Component) { + ((Component) source).setBounds(r); + } + } + + /** + * Returns the current size of this object. + * + * @return current size of object; can be null if this object is + * not on the screen + */ + public Dimension getSize() { + if (source instanceof Component) { + return ((Component) source).getSize(); + } else { + return null; + } + } + + /** + * Sets the current size of this object. + */ + public void setSize(Dimension d) { + if (source instanceof Component) { + ((Component) source).setSize(d); + } + } + + /** + * Returns the accessible child contained at the local coordinate + * Point, if one exists. + * + * @return the Accessible at the specified location, if it exists + */ + public Accessible getAccessibleAt(Point p) { + if (source instanceof Component) { + Component c = ((Component) source).getComponentAt(p); + if (c != null) { + return (getAccessible(c)); + } + } + return null; + } + + /** + * Returns whether this object can accept focus or not. + * + * @return true if object can accept focus; otherwise false + */ + public boolean isFocusTraversable() { + if (source instanceof Component) { + return ((Component) source).isFocusTraversable(); + } else { + return false; + } + } + + /** + * Requests focus for this object. + */ + public void requestFocus() { + if (source instanceof Component) { + ((Component) source).requestFocus(); + } + } + + /** + * Adds the specified {@code FocusListener} to receive focus events from + * this component. + * + * @param l the focus listener + */ + public synchronized void addFocusListener(FocusListener l) { + if (source instanceof Component) { + ((Component) source).addFocusListener(l); + } + } + + /** + * Removes the specified focus listener so it no longer receives focus + * events from this component. + * + * @param l the focus listener; this method performs no function, nor does it + * throw an exception if the listener specified was not previously added + * to this component; if listener is null, no exception is thrown and no + * action is performed. + */ + public synchronized void removeFocusListener(FocusListener l) { + if (source instanceof Component) { + ((Component) source).removeFocusListener(l); + } + } +} diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/java/accessibility/util/java/awt/ButtonTranslator.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/java/accessibility/util/java/awt/ButtonTranslator.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.java.accessibility.util.java.awt; + +import java.lang.*; +import java.util.*; +import java.awt.*; +import java.awt.image.*; +import javax.accessibility.*; +import com.sun.java.accessibility.util.*; + +/** + *

The Translator class provides a translation to interface Accessible + * for objects that do not implement interface Accessible. Assistive + * technologies can use the 'getAccessible' class method of Translator to + * obtain an object that implements interface Accessible. If the object + * passed in already implements interface Accessible, getAccessible merely + * returns the object. + * + *

An example of how an assistive technology might use the Translator + * class is as follows: + * + *

+ *    Accessible accessible = Translator.getAccessible(someObj);
+ *    // obtain information from the 'accessible' object.
+ * 
+ * + *

This class extends the Translator class to provide specific support + * for the Button class. Translator.getAccessible() will automatically + * load this class when an assistive technology asks for an accessible + * translator for Button. + * + */ +public class ButtonTranslator extends Translator { + + /** + * Get the name of this object. + * @return the name of the object -- can be null if this object does + * not have a name + */ + public String getAccessibleName() { + return ((Button) source).getLabel(); + } + + /** + * Set the name of this object. + */ + public void setAccessibleName(String s) { + ((Button) source).setLabel(s); + } + + public AccessibleRole getAccessibleRole() { + return AccessibleRole.PUSH_BUTTON; + } +} diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/java/accessibility/util/java/awt/CheckboxTranslator.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/java/accessibility/util/java/awt/CheckboxTranslator.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.java.accessibility.util.java.awt; + +import java.lang.*; +import java.util.*; +import java.awt.*; +import java.awt.image.*; +import javax.accessibility.*; +import com.sun.java.accessibility.util.*; + +/** + *

The Translator class provides a translation to interface Accessible + * for objects that do not implement interface Accessible. Assistive + * technologies can use the 'getAccessible' class method of Translator to + * obtain an object that implements interface Accessible. If the object + * passed in already implements interface Accessible, getAccessible merely + * returns the object. + * + *

An example of how an assistive technology might use the Translator + * class is as follows: + * + *

+ *    Accessible accessible = Translator.getAccessible(someObj);
+ *    // obtain information from the 'accessible' object.
+ * 
+ * + *

This class extends the Translator class to provide specific support + * for the Checkbox class. Translator.getAccessible() will automatically + * load this class when an assistive technology asks for an accessible + * translator for Checkbox. + * + */ +public class CheckboxTranslator extends Translator { + + /** + * Get the state of this object. + * @return an instance of AccessibleState containing the current state of the object + * @see AccessibleState + */ + public AccessibleStateSet getAccessibleStateSet() { + AccessibleStateSet states = super.getAccessibleStateSet(); + if (((Checkbox) source).getState()) { + states.add(AccessibleState.CHECKED); + } + return states; + } + + /** + * Get the name of this object. + * @return the name of the object -- can be null if this object does + * not have a name + */ + public String getAccessibleName() { + return ((Checkbox) source).getLabel(); + } + + /** + * Set the name of this object. + */ + public void setAccessibleName(String s) { + ((Checkbox) source).setLabel(s); + } + + public AccessibleRole getAccessibleRole() { + return AccessibleRole.CHECK_BOX; + } +} diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/java/accessibility/util/java/awt/LabelTranslator.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/java/accessibility/util/java/awt/LabelTranslator.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.java.accessibility.util.java.awt; + +import java.lang.*; +import java.util.*; +import java.awt.*; +import java.awt.image.*; +import javax.accessibility.*; +import com.sun.java.accessibility.util.*; + +/** + *

The Translator class provides a translation to interface Accessible + * for objects that do not implement interface Accessible. Assistive + * technologies can use the 'getAccessible' class method of Translator to + * obtain an object that implements interface Accessible. If the object + * passed in already implements interface Accessible, getAccessible merely + * returns the object. + * + *

An example of how an assistive technology might use the Translator + * class is as follows: + * + *

+ *    Accessible accessible = Translator.getAccessible(someObj);
+ *    // obtain information from the 'accessible' object.
+ * 
+ * + *

This class extends the Translator class to provide specific support + * for the Label class. Translator.getAccessible() will automatically + * load this class when an assistive technology asks for an accessible + * translator for Label. + * + */ +public class LabelTranslator extends Translator { + + public String getAccessibleName() { + return ((Label) source).getText(); + } + + /** + * Set the name of this object. + */ + public void setAccessibleName(String s) { + ((Label) source).setText(s); + } + + public AccessibleRole getAccessibleRole() { + return AccessibleRole.LABEL; + } +} diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/java/accessibility/util/java/awt/ListTranslator.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/java/accessibility/util/java/awt/ListTranslator.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.java.accessibility.util.java.awt; + +import java.lang.*; +import java.util.*; +import java.awt.*; +import java.awt.image.*; +import javax.accessibility.*; +import com.sun.java.accessibility.util.*; + +/** + *

The Translator class provides a translation to interface Accessible + * for objects that do not implement interface Accessible. Assistive + * technologies can use the 'getAccessible' class method of Translator to + * obtain an object that implements interface Accessible. If the object + * passed in already implements interface Accessible, getAccessible merely + * returns the object. + * + *

An example of how an assistive technology might use the Translator + * class is as follows: + * + *

+ *    Accessible accessible = Translator.getAccessible(someObj);
+ *    // obtain information from the 'accessible' object.
+ * 
+ * + *

This class extends the Translator class to provide specific support + * for the List class. Translator.getAccessible() will automatically + * load this class when an assistive technology asks for an accessible + * translator for List. + * + */ +public class ListTranslator extends Translator { + + /** + * Get the state of this object. + * @return an instance of AccessibleState containing the current state of the object + * @see AccessibleState + */ + public AccessibleStateSet getAccessibleStateSet() { + AccessibleStateSet states = super.getAccessibleStateSet(); + if (((java.awt.List) source).isMultipleMode()) { + states.add(AccessibleState.MULTISELECTABLE); + } + if (((java.awt.List) source).getSelectedItems().length > 0) { + states.add(AccessibleState.SELECTED); + } + return states; + } + + public AccessibleRole getAccessibleRole() { + return AccessibleRole.LIST; + } +} diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/java/accessibility/util/java/awt/TextComponentTranslator.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/java/accessibility/util/java/awt/TextComponentTranslator.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.java.accessibility.util.java.awt; + +import java.lang.*; +import java.util.*; +import java.awt.*; +import java.awt.image.*; +import javax.accessibility.*; +import com.sun.java.accessibility.util.*; + +/** + *

The Translator class provides a translation to interface Accessible + * for objects that do not implement interface Accessible. Assistive + * technologies can use the 'getAccessible' class method of Translator to + * obtain an object that implements interface Accessible. If the object + * passed in already implements interface Accessible, getAccessible merely + * returns the object. + * + *

An example of how an assistive technology might use the Translator + * class is as follows: + * + *

+ *    Accessible accessible = Translator.getAccessible(someObj);
+ *    // obtain information from the 'accessible' object.
+ * 
+ * + *

This class extends the Translator class to provide specific support + * for the TextComponent class. Translator.getAccessible() will automatically + * load this class when an assistive technology asks for an accessible + * translator for TextComponent. + * + */ +public class TextComponentTranslator extends Translator { + + public AccessibleRole getAccessibleRole() { + return AccessibleRole.TEXT; + } +} diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/java/accessibility/util/package-info.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/java/accessibility/util/package-info.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2013, 2015 Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * Provides a collection of interfaces and classes that compose the Java Accessibility + * Utilities. The classes are used by Assistive Technologies, such as the screen + * readers which are used by those who are blind, and help provide access to GUI + * toolkits that implement the Java Accessibility API. An overview of the important + * classes follows. + * + *

The class {@code AccessibilityEventMonitor} implements a PropertyChange + * listener on every UI object that implements interface {@code Accessible} in the Java + * Virtual Machine. + * + *

The class {@code AWTEventMonitor} implements a suite of listeners that are + * conditionally installed on every AWT component instance in the Java Virtual Machine. + * + *

The class {@code EventQueueMonitor} provides key core functionality for + * Assistive Technologies (and other system-level technologies that need some of + * the same things that Assistive Technology needs). + * + *

The class {@code GUIInitializedMulticaster} is used to maintain a list of + * {@code GUIInitializedListener} classes which are used by the {@code EventQueueMonitor} + * class to notify an interested party when the GUI subsystem has been initialized. + * Note that this class is intended to be used primarily for internal support in + * the {@code EventQueueMonitor} class, and is not intended to be used by classes + * outside the Java Accessibility Utility package. + * + *

The class {@code SwingEventMonitor} extends {@code AWTEventMonitor} by adding + * a suite of listeners conditionally installed on every Swing component instance + * in the Java Virtual Machine. + * + *

The class {@code TopLevelWindowMulticaster} is used to maintain a list of + * {@code TopLevelWindowListener} classes which are used by the {@code EventQueueMonitor} + * class to notify an interested party when a top level window is created or destroyed + * in the Java Virtual Machine Note that this class is intended to be used primarily + * for internal support in the {@code EventQueueMonitor} class, and is not intended + * to be used by classes outside the Java Accessibility Utility package. + * + *

The class {@code Translator} provides a translation to interface {@code Accessible} + * for objects that do not implement interface {@code Accessible}. + * + * @since JDK1.7 + */ + +@jdk.Exported +package com.sun.java.accessibility.util; diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk.properties --- a/src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk.properties Wed Jun 03 20:28:57 2015 -0700 @@ -34,9 +34,9 @@ FileChooser.newFolderNoDirectoryError.textAndMnemonic=Error creating directory "{0}": No such file or directory FileChooser.deleteFileButton.textAndMnemonic=De&lete File FileChooser.renameFileButton.textAndMnemonic=&Rename File -FileChooser.cancelButton.textAndMnemonic=&Cancel -FileChooser.saveButton.textAndMnemonic=&OK -FileChooser.openButton.textAndMnemonic=&OK +FileChooser.cancelButton.textAndMnemonic=Cancel +FileChooser.saveButton.textAndMnemonic=OK +FileChooser.openButton.textAndMnemonic=OK FileChooser.saveDialogTitle.textAndMnemonic=Save FileChooser.openDialogTitle.textAndMnemonic=Open FileChooser.pathLabel.textAndMnemonic=&Selection: diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_de.properties --- a/src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_de.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_de.properties Wed Jun 03 20:28:57 2015 -0700 @@ -34,9 +34,9 @@ FileChooser.newFolderNoDirectoryError.textAndMnemonic=Fehler beim Erstellen von Verzeichnis "{0}": Datei oder Verzeichnis nicht vorhanden FileChooser.deleteFileButton.textAndMnemonic=Datei &l\u00F6schen FileChooser.renameFileButton.textAndMnemonic=Datei &umbenennen -FileChooser.cancelButton.textAndMnemonic=&Abbrechen -FileChooser.saveButton.textAndMnemonic=&OK -FileChooser.openButton.textAndMnemonic=&OK +FileChooser.cancelButton.textAndMnemonic=Abbrechen +FileChooser.saveButton.textAndMnemonic=OK +FileChooser.openButton.textAndMnemonic=OK FileChooser.saveDialogTitle.textAndMnemonic=Speichern FileChooser.openDialogTitle.textAndMnemonic=\u00D6ffnen FileChooser.pathLabel.textAndMnemonic=Aus&wahl: diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_es.properties --- a/src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_es.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_es.properties Wed Jun 03 20:28:57 2015 -0700 @@ -34,9 +34,9 @@ FileChooser.newFolderNoDirectoryError.textAndMnemonic=Error al crear el directorio "{0}": no existe dicho archivo o directorio FileChooser.deleteFileButton.textAndMnemonic=Su&primir Archivo FileChooser.renameFileButton.textAndMnemonic=Cambiar Nomb&re de Archivo -FileChooser.cancelButton.textAndMnemonic=&Cancelar -FileChooser.saveButton.textAndMnemonic=&Aceptar -FileChooser.openButton.textAndMnemonic=&Aceptar +FileChooser.cancelButton.textAndMnemonic=Cancelar +FileChooser.saveButton.textAndMnemonic=Aceptar +FileChooser.openButton.textAndMnemonic=Aceptar FileChooser.saveDialogTitle.textAndMnemonic=Guardar FileChooser.openDialogTitle.textAndMnemonic=Abrir FileChooser.pathLabel.textAndMnemonic=&Selecci\u00F3n: diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_fr.properties --- a/src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_fr.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_fr.properties Wed Jun 03 20:28:57 2015 -0700 @@ -34,9 +34,9 @@ FileChooser.newFolderNoDirectoryError.textAndMnemonic=Erreur lors de la cr\u00E9ation du r\u00E9pertoire "{0}" : ce fichier ou r\u00E9pertoire n''existe pas FileChooser.deleteFileButton.textAndMnemonic=Supprimer &le fichier FileChooser.renameFileButton.textAndMnemonic=&Renommer le fichier -FileChooser.cancelButton.textAndMnemonic=&Annuler -FileChooser.saveButton.textAndMnemonic=&OK -FileChooser.openButton.textAndMnemonic=&OK +FileChooser.cancelButton.textAndMnemonic=Annuler +FileChooser.saveButton.textAndMnemonic=OK +FileChooser.openButton.textAndMnemonic=OK FileChooser.saveDialogTitle.textAndMnemonic=Enregistrer FileChooser.openDialogTitle.textAndMnemonic=Ouvrir FileChooser.pathLabel.textAndMnemonic=&S\u00E9lection : diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_it.properties --- a/src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_it.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_it.properties Wed Jun 03 20:28:57 2015 -0700 @@ -34,9 +34,9 @@ FileChooser.newFolderNoDirectoryError.textAndMnemonic=Errore durante la creazione della directory "{0}": file o directory inesistente FileChooser.deleteFileButton.textAndMnemonic=E&limina file FileChooser.renameFileButton.textAndMnemonic=&Rinomina file -FileChooser.cancelButton.textAndMnemonic=&Annulla -FileChooser.saveButton.textAndMnemonic=&OK -FileChooser.openButton.textAndMnemonic=&OK +FileChooser.cancelButton.textAndMnemonic=Annulla +FileChooser.saveButton.textAndMnemonic=OK +FileChooser.openButton.textAndMnemonic=OK FileChooser.saveDialogTitle.textAndMnemonic=Salva FileChooser.openDialogTitle.textAndMnemonic=Apri FileChooser.pathLabel.textAndMnemonic=&Selezione: diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_ja.properties --- a/src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_ja.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_ja.properties Wed Jun 03 20:28:57 2015 -0700 @@ -34,9 +34,9 @@ FileChooser.newFolderNoDirectoryError.textAndMnemonic=\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA"{0}"\u306E\u4F5C\u6210\u4E2D\u306B\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F: \u3053\u306E\u30D5\u30A1\u30A4\u30EB\u307E\u305F\u306F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306F\u5B58\u5728\u3057\u307E\u305B\u3093 FileChooser.deleteFileButton.textAndMnemonic=\u30D5\u30A1\u30A4\u30EB\u306E\u524A\u9664(&L) FileChooser.renameFileButton.textAndMnemonic=\u30D5\u30A1\u30A4\u30EB\u306E\u540D\u524D\u5909\u66F4(&R) -FileChooser.cancelButton.textAndMnemonic=\u53D6\u6D88(&C) -FileChooser.saveButton.textAndMnemonic=OK(&O) -FileChooser.openButton.textAndMnemonic=OK(&O) +FileChooser.cancelButton.textAndMnemonic=\u53D6\u6D88 +FileChooser.saveButton.textAndMnemonic=OK +FileChooser.openButton.textAndMnemonic=OK FileChooser.saveDialogTitle.textAndMnemonic=\u4FDD\u5B58 FileChooser.openDialogTitle.textAndMnemonic=\u958B\u304F FileChooser.pathLabel.textAndMnemonic=\u9078\u629E(&S): diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_ko.properties --- a/src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_ko.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_ko.properties Wed Jun 03 20:28:57 2015 -0700 @@ -34,9 +34,9 @@ FileChooser.newFolderNoDirectoryError.textAndMnemonic="{0}" \uB514\uB809\uD1A0\uB9AC\uB97C \uC0DD\uC131\uD558\uB294 \uC911 \uC624\uB958 \uBC1C\uC0DD: \uD574\uB2F9 \uD30C\uC77C \uB610\uB294 \uB514\uB809\uD1A0\uB9AC\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4. FileChooser.deleteFileButton.textAndMnemonic=\uD30C\uC77C \uC0AD\uC81C(&L) FileChooser.renameFileButton.textAndMnemonic=\uD30C\uC77C \uC774\uB984 \uBC14\uAFB8\uAE30(&R) -FileChooser.cancelButton.textAndMnemonic=\uCDE8\uC18C(&C) -FileChooser.saveButton.textAndMnemonic=\uD655\uC778(&O) -FileChooser.openButton.textAndMnemonic=\uD655\uC778(&O) +FileChooser.cancelButton.textAndMnemonic=\uCDE8\uC18C +FileChooser.saveButton.textAndMnemonic=\uD655\uC778 +FileChooser.openButton.textAndMnemonic=\uD655\uC778 FileChooser.saveDialogTitle.textAndMnemonic=\uC800\uC7A5 FileChooser.openDialogTitle.textAndMnemonic=\uC5F4\uAE30 FileChooser.pathLabel.textAndMnemonic=\uC120\uD0DD \uC0AC\uD56D(&S): diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_pt_BR.properties --- a/src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_pt_BR.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_pt_BR.properties Wed Jun 03 20:28:57 2015 -0700 @@ -34,9 +34,9 @@ FileChooser.newFolderNoDirectoryError.textAndMnemonic=Erro ao criar o diret\u00F3rio "{0}": N\u00E3o h\u00E1 arquivo ou diret\u00F3rio FileChooser.deleteFileButton.textAndMnemonic=De&letar Arquivo FileChooser.renameFileButton.textAndMnemonic=&Renomear Arquivo -FileChooser.cancelButton.textAndMnemonic=&Cancelar -FileChooser.saveButton.textAndMnemonic=&OK -FileChooser.openButton.textAndMnemonic=&OK +FileChooser.cancelButton.textAndMnemonic=Cancelar +FileChooser.saveButton.textAndMnemonic=OK +FileChooser.openButton.textAndMnemonic=OK FileChooser.saveDialogTitle.textAndMnemonic=Salvar FileChooser.openDialogTitle.textAndMnemonic=Abrir FileChooser.pathLabel.textAndMnemonic=&Sele\u00E7\u00E3o: diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_sv.properties --- a/src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_sv.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_sv.properties Wed Jun 03 20:28:57 2015 -0700 @@ -34,9 +34,9 @@ FileChooser.newFolderNoDirectoryError.textAndMnemonic=Ett fel intr\u00E4ffade vid f\u00F6rs\u00F6k att skapa katalogen "{0}": Filen eller katalogen finns inte FileChooser.deleteFileButton.textAndMnemonic=Ta &bort fil FileChooser.renameFileButton.textAndMnemonic=&\u00C4ndra namn p\u00E5 filen -FileChooser.cancelButton.textAndMnemonic=&Avbryt -FileChooser.saveButton.textAndMnemonic=&OK -FileChooser.openButton.textAndMnemonic=&OK +FileChooser.cancelButton.textAndMnemonic=Avbryt +FileChooser.saveButton.textAndMnemonic=OK +FileChooser.openButton.textAndMnemonic=OK FileChooser.saveDialogTitle.textAndMnemonic=Spara FileChooser.openDialogTitle.textAndMnemonic=\u00D6ppna FileChooser.pathLabel.textAndMnemonic=&Urval: diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_zh_CN.properties --- a/src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_zh_CN.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_zh_CN.properties Wed Jun 03 20:28:57 2015 -0700 @@ -34,9 +34,9 @@ FileChooser.newFolderNoDirectoryError.textAndMnemonic=\u521B\u5EFA\u76EE\u5F55 "{0}" \u65F6\u51FA\u9519: \u6CA1\u6709\u6B64\u7C7B\u6587\u4EF6\u6216\u76EE\u5F55 FileChooser.deleteFileButton.textAndMnemonic=\u5220\u9664\u6587\u4EF6(&L) FileChooser.renameFileButton.textAndMnemonic=\u91CD\u547D\u540D\u6587\u4EF6(&R) -FileChooser.cancelButton.textAndMnemonic=\u53D6\u6D88(&C) -FileChooser.saveButton.textAndMnemonic=\u786E\u5B9A(&O) -FileChooser.openButton.textAndMnemonic=\u786E\u5B9A(&O) +FileChooser.cancelButton.textAndMnemonic=\u53D6\u6D88 +FileChooser.saveButton.textAndMnemonic=\u786E\u5B9A +FileChooser.openButton.textAndMnemonic=\u786E\u5B9A FileChooser.saveDialogTitle.textAndMnemonic=\u4FDD\u5B58 FileChooser.openDialogTitle.textAndMnemonic=\u6253\u5F00 FileChooser.pathLabel.textAndMnemonic=\u9009\u5B9A\u5185\u5BB9(&S): diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_zh_TW.properties --- a/src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_zh_TW.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_zh_TW.properties Wed Jun 03 20:28:57 2015 -0700 @@ -34,9 +34,9 @@ FileChooser.newFolderNoDirectoryError.textAndMnemonic=\u5EFA\u7ACB\u76EE\u9304 "{0}" \u6642\u767C\u751F\u932F\u8AA4: \u6C92\u6709\u6B64\u6A94\u6848\u6216\u76EE\u9304 FileChooser.deleteFileButton.textAndMnemonic=\u522A\u9664\u6A94\u6848(&L) FileChooser.renameFileButton.textAndMnemonic=\u91CD\u65B0\u547D\u540D\u6A94\u6848(&R) -FileChooser.cancelButton.textAndMnemonic=\u53D6\u6D88(&C) -FileChooser.saveButton.textAndMnemonic=\u78BA\u5B9A(&O) -FileChooser.openButton.textAndMnemonic=\u78BA\u5B9A(&O) +FileChooser.cancelButton.textAndMnemonic=\u53D6\u6D88 +FileChooser.saveButton.textAndMnemonic=\u78BA\u5B9A +FileChooser.openButton.textAndMnemonic=\u78BA\u5B9A FileChooser.saveDialogTitle.textAndMnemonic=\u5132\u5B58 FileChooser.openDialogTitle.textAndMnemonic=\u958B\u555F FileChooser.pathLabel.textAndMnemonic=\u9078\u53D6(&S): diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/java/util/jar/pack/PackerImpl.java --- a/src/share/classes/com/sun/java/util/jar/pack/PackerImpl.java Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/java/util/jar/pack/PackerImpl.java Wed Jun 03 20:28:57 2015 -0700 @@ -79,18 +79,20 @@ * Takes a JarFile and converts into a pack-stream. *

* Closes its input but not its output. (Pack200 archives are appendable.) - * @param in a JarFile + * + * @param in a JarFile * @param out an OutputStream * @exception IOException if an error is encountered. */ public synchronized void pack(JarFile in, OutputStream out) throws IOException { - assert(Utils.currentInstance.get() == null); - TimeZone tz = (props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE)) - ? null - : TimeZone.getDefault(); + assert (Utils.currentInstance.get() == null); + + boolean needUTC = !props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE); try { Utils.currentInstance.set(this); - if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC")); + if (needUTC) { + Utils.changeDefaultTimeZoneToUtc(); + } if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) { Utils.copyJarFile(in, out); @@ -99,7 +101,9 @@ } } finally { Utils.currentInstance.set(null); - if (tz != null) TimeZone.setDefault(tz); + if (needUTC) { + Utils.restoreDefaultTimeZone(); + } in.close(); } } @@ -119,12 +123,13 @@ * @exception IOException if an error is encountered. */ public synchronized void pack(JarInputStream in, OutputStream out) throws IOException { - assert(Utils.currentInstance.get() == null); - TimeZone tz = (props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE)) ? null : - TimeZone.getDefault(); + assert (Utils.currentInstance.get() == null); + boolean needUTC = !props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE); try { Utils.currentInstance.set(this); - if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC")); + if (needUTC) { + Utils.changeDefaultTimeZoneToUtc(); + } if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) { Utils.copyJarFile(in, out); } else { @@ -132,10 +137,13 @@ } } finally { Utils.currentInstance.set(null); - if (tz != null) TimeZone.setDefault(tz); + if (needUTC) { + Utils.restoreDefaultTimeZone(); + } in.close(); } } + /** * Register a listener for changes to options. * @param listener An object to be invoked when a property is changed. diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java --- a/src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java Wed Jun 03 20:28:57 2015 -0700 @@ -96,13 +96,15 @@ //Driver routines // The unpack worker... + /** * Takes a packed-stream InputStream, and writes to a JarOutputStream. Internally * the entire buffer must be read, it may be more efficient to read the packed-stream * to a file and pass the File object, in the alternate method described below. *

* Closes its input but not its output. (The output can accumulate more elements.) - * @param in an InputStream. + * + * @param in an InputStream. * @param out a JarOutputStream. * @exception IOException if an error is encountered. */ @@ -113,19 +115,19 @@ if (out == null) { throw new NullPointerException("null output"); } - assert(Utils.currentInstance.get() == null); - TimeZone tz = (props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE)) - ? null - : TimeZone.getDefault(); - + assert (Utils.currentInstance.get() == null); + boolean needUTC = !props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE); try { Utils.currentInstance.set(this); - if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC")); + if (needUTC) { + Utils.changeDefaultTimeZoneToUtc(); + } final int verbose = props.getInteger(Utils.DEBUG_VERBOSE); BufferedInputStream in0 = new BufferedInputStream(in); if (Utils.isJarMagic(Utils.readMagic(in0))) { - if (verbose > 0) + if (verbose > 0) { Utils.log.info("Copying unpacked JAR file..."); + } Utils.copyJarFile(new JarInputStream(in0), out); } else if (props.getBoolean(Utils.DEBUG_DISABLE_NATIVE)) { (new DoUnpack()).run(in0, out); @@ -144,7 +146,9 @@ } finally { _nunp = null; Utils.currentInstance.set(null); - if (tz != null) TimeZone.setDefault(tz); + if (needUTC) { + Utils.restoreDefaultTimeZone(); + } } } @@ -152,7 +156,8 @@ * Takes an input File containing the pack file, and generates a JarOutputStream. *

* Does not close its output. (The output can accumulate more elements.) - * @param in a File. + * + * @param in a File. * @param out a JarOutputStream. * @exception IOException if an error is encountered. */ diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/java/util/jar/pack/Utils.java --- a/src/share/classes/com/sun/java/util/jar/pack/Utils.java Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/java/util/jar/pack/Utils.java Wed Jun 03 20:28:57 2015 -0700 @@ -34,6 +34,7 @@ import java.io.OutputStream; import java.util.Collections; import java.util.Date; +import java.util.TimeZone; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.jar.JarInputStream; @@ -133,6 +134,9 @@ // to the engine code, especially the native code. static final ThreadLocal currentInstance = new ThreadLocal<>(); + private static TimeZone tz; + private static int workingPackerCount = 0; + // convenience method to access the TL globals static TLGlobals getTLGlobals() { return currentInstance.get(); @@ -203,6 +207,24 @@ } } + static synchronized void changeDefaultTimeZoneToUtc() { + if (workingPackerCount++ == 0) { + // only first thread saves default TZ + tz = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("UTC")); + } + } + + static synchronized void restoreDefaultTimeZone() { + if (--workingPackerCount == 0) { + // reset timezone when all the packer/unpacker instances have terminated + if (tz != null) { + TimeZone.setDefault(tz); + } + tz = null; + } + } + static final Pack200Logger log = new Pack200Logger("java.util.jar.Pack200"); diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic.properties --- a/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic.properties Wed Jun 03 20:28:57 2015 -0700 @@ -43,13 +43,13 @@ Specify a different file name. FileChooser.acceptAllFileFilter.textAndMnemonic=All Files FileChooser.cancelButton.textAndMnemonic=Cancel -FileChooser.saveButton.textAndMnemonic=&Save -FileChooser.openButton.textAndMnemonic=&Open +FileChooser.saveButton.textAndMnemonic=Save +FileChooser.openButton.textAndMnemonic=Open FileChooser.saveDialogTitle.textAndMnemonic=Save FileChooser.openDialogTitle.textAndMnemonic=Open FileChooser.updateButton.textAndMnemonic=&Update FileChooser.helpButton.textAndMnemonic=&Help -FileChooser.directoryOpenButton.textAndMnemonic=&Open +FileChooser.directoryOpenButton.textAndMnemonic=Open # File Size Units FileChooser.fileSizeKiloBytes={0} KB diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_de.properties --- a/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_de.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_de.properties Wed Jun 03 20:28:57 2015 -0700 @@ -42,13 +42,13 @@ FileChooser.renameErrorFileExists.textAndMnemonic={0} kann nicht umbenannt werden: Es ist bereits eine Datei mit dem angegebenen Namen vorhanden. Geben Sie einen anderen Dateinamen an. FileChooser.acceptAllFileFilter.textAndMnemonic=Alle Dateien FileChooser.cancelButton.textAndMnemonic=Abbrechen -FileChooser.saveButton.textAndMnemonic=&Speichern -FileChooser.openButton.textAndMnemonic=\u00D6&ffnen +FileChooser.saveButton.textAndMnemonic=Speichern +FileChooser.openButton.textAndMnemonic=\u00D6ffnen FileChooser.saveDialogTitle.textAndMnemonic=Speichern FileChooser.openDialogTitle.textAndMnemonic=\u00D6ffnen FileChooser.updateButton.textAndMnemonic=A&ktualisieren FileChooser.helpButton.textAndMnemonic=&Hilfe -FileChooser.directoryOpenButton.textAndMnemonic=\u00D6&ffnen +FileChooser.directoryOpenButton.textAndMnemonic=\u00D6ffnen # File Size Units FileChooser.fileSizeKiloBytes={0} KB diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_es.properties --- a/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_es.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_es.properties Wed Jun 03 20:28:57 2015 -0700 @@ -42,13 +42,13 @@ FileChooser.renameErrorFileExists.textAndMnemonic=No se puede cambiar el nombre de {0}: ya existe un archivo con el nombre especificado. Especifique otro nombre de archivo. FileChooser.acceptAllFileFilter.textAndMnemonic=Todos los Archivos FileChooser.cancelButton.textAndMnemonic=Cancelar -FileChooser.saveButton.textAndMnemonic=&Guardar -FileChooser.openButton.textAndMnemonic=&Abrir +FileChooser.saveButton.textAndMnemonic=Guardar +FileChooser.openButton.textAndMnemonic=Abrir FileChooser.saveDialogTitle.textAndMnemonic=Guardar FileChooser.openDialogTitle.textAndMnemonic=Abrir FileChooser.updateButton.textAndMnemonic=Act&ualizar FileChooser.helpButton.textAndMnemonic=A&yuda -FileChooser.directoryOpenButton.textAndMnemonic=&Abrir +FileChooser.directoryOpenButton.textAndMnemonic=Abrir # File Size Units FileChooser.fileSizeKiloBytes={0} KB diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_fr.properties --- a/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_fr.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_fr.properties Wed Jun 03 20:28:57 2015 -0700 @@ -42,13 +42,13 @@ FileChooser.renameErrorFileExists.textAndMnemonic=Impossible de renommer {0} : il existe d\u00E9j\u00E0 un fichier portant le nom indiqu\u00E9. Indiquez-en un autre. FileChooser.acceptAllFileFilter.textAndMnemonic=Tous les fichiers FileChooser.cancelButton.textAndMnemonic=Annuler -FileChooser.saveButton.textAndMnemonic=Enregi&strer -FileChooser.openButton.textAndMnemonic=&Ouvrir +FileChooser.saveButton.textAndMnemonic=Enregistrer +FileChooser.openButton.textAndMnemonic=Ouvrir FileChooser.saveDialogTitle.textAndMnemonic=Enregistrer FileChooser.openDialogTitle.textAndMnemonic=Ouvrir FileChooser.updateButton.textAndMnemonic=Mettre \u00E0 jo&ur FileChooser.helpButton.textAndMnemonic=&Aide -FileChooser.directoryOpenButton.textAndMnemonic=&Ouvrir +FileChooser.directoryOpenButton.textAndMnemonic=Ouvrir # File Size Units FileChooser.fileSizeKiloBytes={0} KB diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_it.properties --- a/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_it.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_it.properties Wed Jun 03 20:28:57 2015 -0700 @@ -42,13 +42,13 @@ FileChooser.renameErrorFileExists.textAndMnemonic=Impossibile rinominare {0}: esiste gi\u00E0 un file con il nome specificato. Specificare un altro nome. FileChooser.acceptAllFileFilter.textAndMnemonic=Tutti i file FileChooser.cancelButton.textAndMnemonic=Annulla -FileChooser.saveButton.textAndMnemonic=Sal&va -FileChooser.openButton.textAndMnemonic=&Apri +FileChooser.saveButton.textAndMnemonic=Salva +FileChooser.openButton.textAndMnemonic=Apri FileChooser.saveDialogTitle.textAndMnemonic=Salva FileChooser.openDialogTitle.textAndMnemonic=Apri FileChooser.updateButton.textAndMnemonic=Ag&giorna FileChooser.helpButton.textAndMnemonic=&? -FileChooser.directoryOpenButton.textAndMnemonic=&Apri +FileChooser.directoryOpenButton.textAndMnemonic=Apri # File Size Units FileChooser.fileSizeKiloBytes={0} KB diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_ja.properties --- a/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_ja.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_ja.properties Wed Jun 03 20:28:57 2015 -0700 @@ -42,13 +42,13 @@ FileChooser.renameErrorFileExists.textAndMnemonic={0}\u306E\u540D\u524D\u3092\u5909\u66F4\u3067\u304D\u307E\u305B\u3093: \u6307\u5B9A\u3057\u305F\u540D\u524D\u306E\u30D5\u30A1\u30A4\u30EB\u306F\u3059\u3067\u306B\u5B58\u5728\u3057\u307E\u3059\u3002\u5225\u306E\u30D5\u30A1\u30A4\u30EB\u540D\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002 FileChooser.acceptAllFileFilter.textAndMnemonic=\u3059\u3079\u3066\u306E\u30D5\u30A1\u30A4\u30EB FileChooser.cancelButton.textAndMnemonic=\u53D6\u6D88 -FileChooser.saveButton.textAndMnemonic=\u4FDD\u5B58(&S) -FileChooser.openButton.textAndMnemonic=\u958B\u304F(&O) +FileChooser.saveButton.textAndMnemonic=\u4FDD\u5B58 +FileChooser.openButton.textAndMnemonic=\u958B\u304F FileChooser.saveDialogTitle.textAndMnemonic=\u4FDD\u5B58 FileChooser.openDialogTitle.textAndMnemonic=\u958B\u304F FileChooser.updateButton.textAndMnemonic=\u66F4\u65B0(&U) FileChooser.helpButton.textAndMnemonic=\u30D8\u30EB\u30D7(&H) -FileChooser.directoryOpenButton.textAndMnemonic=\u958B\u304F(&O) +FileChooser.directoryOpenButton.textAndMnemonic=\u958B\u304F # File Size Units FileChooser.fileSizeKiloBytes={0} KB diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_ko.properties --- a/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_ko.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_ko.properties Wed Jun 03 20:28:57 2015 -0700 @@ -42,13 +42,13 @@ FileChooser.renameErrorFileExists.textAndMnemonic={0}\uC758 \uC774\uB984\uC744 \uBC14\uAFC0 \uC218 \uC5C6\uC74C: \uC9C0\uC815\uD55C \uC774\uB984\uC744 \uC0AC\uC6A9\uD558\uB294 \uD30C\uC77C\uC774 \uC874\uC7AC\uD569\uB2C8\uB2E4. \uB2E4\uB978 \uD30C\uC77C \uC774\uB984\uC744 \uC9C0\uC815\uD558\uC2ED\uC2DC\uC624. FileChooser.acceptAllFileFilter.textAndMnemonic=\uBAA8\uB4E0 \uD30C\uC77C FileChooser.cancelButton.textAndMnemonic=\uCDE8\uC18C -FileChooser.saveButton.textAndMnemonic=\uC800\uC7A5(&S) -FileChooser.openButton.textAndMnemonic=\uC5F4\uAE30(&O) +FileChooser.saveButton.textAndMnemonic=\uC800\uC7A5 +FileChooser.openButton.textAndMnemonic=\uC5F4\uAE30 FileChooser.saveDialogTitle.textAndMnemonic=\uC800\uC7A5 FileChooser.openDialogTitle.textAndMnemonic=\uC5F4\uAE30 FileChooser.updateButton.textAndMnemonic=\uC5C5\uB370\uC774\uD2B8(&U) FileChooser.helpButton.textAndMnemonic=\uB3C4\uC6C0\uB9D0(&H) -FileChooser.directoryOpenButton.textAndMnemonic=\uC5F4\uAE30(&O) +FileChooser.directoryOpenButton.textAndMnemonic=\uC5F4\uAE30 # File Size Units FileChooser.fileSizeKiloBytes={0} KB diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_pt_BR.properties --- a/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_pt_BR.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_pt_BR.properties Wed Jun 03 20:28:57 2015 -0700 @@ -42,13 +42,13 @@ FileChooser.renameErrorFileExists.textAndMnemonic=N\u00E3o \u00E9 poss\u00EDvel renomear {0}: Um arquivo com o nome especificado j\u00E1 existe. Especifique outro nome de arquivo. FileChooser.acceptAllFileFilter.textAndMnemonic=Todos os Arquivos FileChooser.cancelButton.textAndMnemonic=Cancelar -FileChooser.saveButton.textAndMnemonic=&Salvar -FileChooser.openButton.textAndMnemonic=A&brir +FileChooser.saveButton.textAndMnemonic=Salvar +FileChooser.openButton.textAndMnemonic=Abrir FileChooser.saveDialogTitle.textAndMnemonic=Salvar FileChooser.openDialogTitle.textAndMnemonic=Abrir FileChooser.updateButton.textAndMnemonic=At&ualizar FileChooser.helpButton.textAndMnemonic=Aj&uda -FileChooser.directoryOpenButton.textAndMnemonic=A&brir +FileChooser.directoryOpenButton.textAndMnemonic=Abrir # File Size Units FileChooser.fileSizeKiloBytes={0} KB diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_sv.properties --- a/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_sv.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_sv.properties Wed Jun 03 20:28:57 2015 -0700 @@ -42,13 +42,13 @@ FileChooser.renameErrorFileExists.textAndMnemonic=Kan inte namn\u00E4ndra {0}: En fil med angivet namn finns redan. Ange ett annat filnamn. FileChooser.acceptAllFileFilter.textAndMnemonic=Alla filer FileChooser.cancelButton.textAndMnemonic=Avbryt -FileChooser.saveButton.textAndMnemonic=&Spara -FileChooser.openButton.textAndMnemonic=&\u00D6ppna +FileChooser.saveButton.textAndMnemonic=Spara +FileChooser.openButton.textAndMnemonic=\u00D6ppna FileChooser.saveDialogTitle.textAndMnemonic=Spara FileChooser.openDialogTitle.textAndMnemonic=\u00D6ppna FileChooser.updateButton.textAndMnemonic=Upp&datera FileChooser.helpButton.textAndMnemonic=&Hj\u00E4lp -FileChooser.directoryOpenButton.textAndMnemonic=&\u00D6ppna +FileChooser.directoryOpenButton.textAndMnemonic=\u00D6ppna # File Size Units FileChooser.fileSizeKiloBytes={0} KB diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_zh_CN.properties --- a/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_zh_CN.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_zh_CN.properties Wed Jun 03 20:28:57 2015 -0700 @@ -42,13 +42,13 @@ FileChooser.renameErrorFileExists.textAndMnemonic=\u65E0\u6CD5\u91CD\u547D\u540D{0}: \u5DF2\u5B58\u5728\u5177\u6709\u6240\u6307\u5B9A\u540D\u79F0\u7684\u6587\u4EF6\u3002\u8BF7\u6307\u5B9A\u5176\u4ED6\u6587\u4EF6\u540D\u3002 FileChooser.acceptAllFileFilter.textAndMnemonic=\u6240\u6709\u6587\u4EF6 FileChooser.cancelButton.textAndMnemonic=\u53D6\u6D88 -FileChooser.saveButton.textAndMnemonic=\u4FDD\u5B58(&S) -FileChooser.openButton.textAndMnemonic=\u6253\u5F00(&O) +FileChooser.saveButton.textAndMnemonic=\u4FDD\u5B58 +FileChooser.openButton.textAndMnemonic=\u6253\u5F00 FileChooser.saveDialogTitle.textAndMnemonic=\u4FDD\u5B58 FileChooser.openDialogTitle.textAndMnemonic=\u6253\u5F00 FileChooser.updateButton.textAndMnemonic=\u66F4\u65B0(&U) FileChooser.helpButton.textAndMnemonic=\u5E2E\u52A9(&H) -FileChooser.directoryOpenButton.textAndMnemonic=\u6253\u5F00(&O) +FileChooser.directoryOpenButton.textAndMnemonic=\u6253\u5F00 # File Size Units FileChooser.fileSizeKiloBytes={0} KB diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_zh_TW.properties --- a/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_zh_TW.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_zh_TW.properties Wed Jun 03 20:28:57 2015 -0700 @@ -42,13 +42,13 @@ FileChooser.renameErrorFileExists.textAndMnemonic=\u7121\u6CD5\u91CD\u65B0\u547D\u540D {0}: \u5DF2\u7D93\u5B58\u5728\u60A8\u6240\u6307\u5B9A\u540D\u7A31\u7684\u6A94\u6848\u3002\u8ACB\u6307\u5B9A\u4E0D\u540C\u7684\u540D\u7A31\u3002 FileChooser.acceptAllFileFilter.textAndMnemonic=\u6240\u6709\u6A94\u6848 FileChooser.cancelButton.textAndMnemonic=\u53D6\u6D88 -FileChooser.saveButton.textAndMnemonic=\u5132\u5B58(&S) -FileChooser.openButton.textAndMnemonic=\u958B\u555F(&O) +FileChooser.saveButton.textAndMnemonic=\u5132\u5B58 +FileChooser.openButton.textAndMnemonic=\u958B\u555F FileChooser.saveDialogTitle.textAndMnemonic=\u5132\u5B58 FileChooser.openDialogTitle.textAndMnemonic=\u958B\u555F FileChooser.updateButton.textAndMnemonic=\u66F4\u65B0(&U) FileChooser.helpButton.textAndMnemonic=\u8AAA\u660E(&H) -FileChooser.directoryOpenButton.textAndMnemonic=\u958B\u555F(&O) +FileChooser.directoryOpenButton.textAndMnemonic=\u958B\u555F # File Size Units FileChooser.fileSizeKiloBytes={0} KB diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal.properties --- a/src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal.properties Wed Jun 03 20:28:57 2015 -0700 @@ -43,8 +43,6 @@ FileChooser.fileTypeHeader.textAndMnemonic=Type FileChooser.fileDateHeader.textAndMnemonic=Modified FileChooser.fileAttrHeader.textAndMnemonic=Attributes -FileChooser.saveButton.textAndMnemonic=Save -FileChooser.openButton.textAndMnemonic=Open ############ Used by MetalTitlePane if rendering window decorations############ MetalTitlePane.restore.titleAndMnemonic=&Restore diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_de.properties --- a/src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_de.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_de.properties Wed Jun 03 20:28:57 2015 -0700 @@ -43,8 +43,6 @@ FileChooser.fileTypeHeader.textAndMnemonic=Typ FileChooser.fileDateHeader.textAndMnemonic=Ge\u00E4ndert FileChooser.fileAttrHeader.textAndMnemonic=Attribute -FileChooser.saveButton.textAndMnemonic=Speichern -FileChooser.openButton.textAndMnemonic=\u00D6ffnen ############ Used by MetalTitlePane if rendering window decorations############ MetalTitlePane.restore.titleAndMnemonic=&Wiederherstellen diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_es.properties --- a/src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_es.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_es.properties Wed Jun 03 20:28:57 2015 -0700 @@ -43,8 +43,6 @@ FileChooser.fileTypeHeader.textAndMnemonic=Tipo FileChooser.fileDateHeader.textAndMnemonic=Modificado FileChooser.fileAttrHeader.textAndMnemonic=Atributos -FileChooser.saveButton.textAndMnemonic=Guardar -FileChooser.openButton.textAndMnemonic=Abrir ############ Used by MetalTitlePane if rendering window decorations############ MetalTitlePane.restore.titleAndMnemonic=&Restaurar diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_fr.properties --- a/src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_fr.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_fr.properties Wed Jun 03 20:28:57 2015 -0700 @@ -43,8 +43,6 @@ FileChooser.fileTypeHeader.textAndMnemonic=Type FileChooser.fileDateHeader.textAndMnemonic=Modifi\u00E9 FileChooser.fileAttrHeader.textAndMnemonic=Attributs -FileChooser.saveButton.textAndMnemonic=Enregistrer -FileChooser.openButton.textAndMnemonic=Ouvrir ############ Used by MetalTitlePane if rendering window decorations############ MetalTitlePane.restore.titleAndMnemonic=&Restaurer diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_it.properties --- a/src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_it.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_it.properties Wed Jun 03 20:28:57 2015 -0700 @@ -43,8 +43,6 @@ FileChooser.fileTypeHeader.textAndMnemonic=Tipo FileChooser.fileDateHeader.textAndMnemonic=Modificato FileChooser.fileAttrHeader.textAndMnemonic=Attributi -FileChooser.saveButton.textAndMnemonic=Salva -FileChooser.openButton.textAndMnemonic=Apri ############ Used by MetalTitlePane if rendering window decorations############ MetalTitlePane.restore.titleAndMnemonic=&Ripristina diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_ja.properties --- a/src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_ja.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_ja.properties Wed Jun 03 20:28:57 2015 -0700 @@ -43,8 +43,6 @@ FileChooser.fileTypeHeader.textAndMnemonic=\u30BF\u30A4\u30D7 FileChooser.fileDateHeader.textAndMnemonic=\u4FEE\u6B63\u65E5 FileChooser.fileAttrHeader.textAndMnemonic=\u5C5E\u6027 -FileChooser.saveButton.textAndMnemonic=\u4FDD\u5B58 -FileChooser.openButton.textAndMnemonic=\u958B\u304F ############ Used by MetalTitlePane if rendering window decorations############ MetalTitlePane.restore.titleAndMnemonic=\u5FA9\u5143(&R) diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_ko.properties --- a/src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_ko.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_ko.properties Wed Jun 03 20:28:57 2015 -0700 @@ -43,8 +43,6 @@ FileChooser.fileTypeHeader.textAndMnemonic=\uC720\uD615 FileChooser.fileDateHeader.textAndMnemonic=\uC218\uC815 \uB0A0\uC9DC FileChooser.fileAttrHeader.textAndMnemonic=\uC18D\uC131 -FileChooser.saveButton.textAndMnemonic=\uC800\uC7A5 -FileChooser.openButton.textAndMnemonic=\uC5F4\uAE30 ############ Used by MetalTitlePane if rendering window decorations############ MetalTitlePane.restore.titleAndMnemonic=\uBCF5\uC6D0(&R) diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_pt_BR.properties --- a/src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_pt_BR.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_pt_BR.properties Wed Jun 03 20:28:57 2015 -0700 @@ -43,8 +43,6 @@ FileChooser.fileTypeHeader.textAndMnemonic=Tipo FileChooser.fileDateHeader.textAndMnemonic=Modificado FileChooser.fileAttrHeader.textAndMnemonic=Atributos -FileChooser.saveButton.textAndMnemonic=Salvar -FileChooser.openButton.textAndMnemonic=Abrir ############ Used by MetalTitlePane if rendering window decorations############ MetalTitlePane.restore.titleAndMnemonic=&Restaurar diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_sv.properties --- a/src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_sv.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_sv.properties Wed Jun 03 20:28:57 2015 -0700 @@ -43,8 +43,6 @@ FileChooser.fileTypeHeader.textAndMnemonic=Typ FileChooser.fileDateHeader.textAndMnemonic=\u00C4ndrad FileChooser.fileAttrHeader.textAndMnemonic=Attribut -FileChooser.saveButton.textAndMnemonic=Spara -FileChooser.openButton.textAndMnemonic=\u00D6ppna ############ Used by MetalTitlePane if rendering window decorations############ MetalTitlePane.restore.titleAndMnemonic=&\u00C5terst\u00E4ll diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_zh_CN.properties --- a/src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_zh_CN.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_zh_CN.properties Wed Jun 03 20:28:57 2015 -0700 @@ -43,8 +43,6 @@ FileChooser.fileTypeHeader.textAndMnemonic=\u7C7B\u578B FileChooser.fileDateHeader.textAndMnemonic=\u4FEE\u6539\u65E5\u671F FileChooser.fileAttrHeader.textAndMnemonic=\u5C5E\u6027 -FileChooser.saveButton.textAndMnemonic=\u4FDD\u5B58 -FileChooser.openButton.textAndMnemonic=\u6253\u5F00 ############ Used by MetalTitlePane if rendering window decorations############ MetalTitlePane.restore.titleAndMnemonic=\u8FD8\u539F(&R) diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_zh_TW.properties --- a/src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_zh_TW.properties Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_zh_TW.properties Wed Jun 03 20:28:57 2015 -0700 @@ -43,8 +43,6 @@ FileChooser.fileTypeHeader.textAndMnemonic=\u985E\u578B FileChooser.fileDateHeader.textAndMnemonic=\u4FEE\u6539\u65E5\u671F FileChooser.fileAttrHeader.textAndMnemonic=\u5C6C\u6027 -FileChooser.saveButton.textAndMnemonic=\u5132\u5B58 -FileChooser.openButton.textAndMnemonic=\u958B\u555F ############ Used by MetalTitlePane if rendering window decorations############ MetalTitlePane.restore.titleAndMnemonic=\u56DE\u5FA9(&R) diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/java/awt/geom/Path2D.java --- a/src/share/classes/java/awt/geom/Path2D.java Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/java/awt/geom/Path2D.java Wed Jun 03 20:28:57 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -101,6 +101,8 @@ static final int INIT_SIZE = 20; static final int EXPAND_MAX = 500; + static final int EXPAND_MAX_COORDS = EXPAND_MAX * 2; + static final int EXPAND_MIN = 10; // ensure > 6 (cubics) /** * Constructs a new empty {@code Path2D} object. @@ -141,6 +143,42 @@ abstract int rectCrossings(double rxmin, double rymin, double rxmax, double rymax); + static byte[] expandPointTypes(byte[] oldPointTypes, int needed) { + final int oldSize = oldPointTypes.length; + final int newSizeMin = oldSize + needed; + if (newSizeMin < oldSize) { + // hard overflow failure - we can't even accommodate + // new items without overflowing + throw new ArrayIndexOutOfBoundsException( + "pointTypes exceeds maximum capacity !"); + } + // growth algorithm computation + int grow = oldSize; + if (grow > EXPAND_MAX) { + grow = Math.max(EXPAND_MAX, oldSize >> 3); // 1/8th min + } else if (grow < EXPAND_MIN) { + grow = EXPAND_MIN; + } + assert grow > 0; + + int newSize = oldSize + grow; + if (newSize < newSizeMin) { + // overflow in growth algorithm computation + newSize = Integer.MAX_VALUE; + } + while (true) { + try { + // try allocating the larger array + return Arrays.copyOf(oldPointTypes, newSize); + } catch (OutOfMemoryError oome) { + if (newSize == newSizeMin) { + throw oome; + } + } + newSize = newSizeMin + (newSize - newSizeMin) / 2; + } + } + /** * The {@code Float} class defines a geometric path with * coordinates stored in single precision floating point. @@ -224,8 +262,8 @@ Path2D p2d = (Path2D) s; setWindingRule(p2d.windingRule); this.numTypes = p2d.numTypes; - this.pointTypes = Arrays.copyOf(p2d.pointTypes, - p2d.pointTypes.length); + // trim arrays: + this.pointTypes = Arrays.copyOf(p2d.pointTypes, p2d.numTypes); this.numCoords = p2d.numCoords; this.floatCoords = p2d.cloneCoordsFloat(at); } else { @@ -237,19 +275,23 @@ } } + @Override float[] cloneCoordsFloat(AffineTransform at) { + // trim arrays: float ret[]; if (at == null) { - ret = Arrays.copyOf(this.floatCoords, this.floatCoords.length); + ret = Arrays.copyOf(floatCoords, numCoords); } else { - ret = new float[floatCoords.length]; + ret = new float[numCoords]; at.transform(floatCoords, 0, ret, 0, numCoords / 2); } return ret; } + @Override double[] cloneCoordsDouble(AffineTransform at) { - double ret[] = new double[floatCoords.length]; + // trim arrays: + double ret[] = new double[numCoords]; if (at == null) { for (int i = 0; i < numCoords; i++) { ret[i] = floatCoords[i]; @@ -275,31 +317,53 @@ floatCoords[coordindex+1]); } + @Override void needRoom(boolean needMove, int newCoords) { - if (needMove && numTypes == 0) { + if ((numTypes == 0) && needMove) { throw new IllegalPathStateException("missing initial moveto "+ "in path definition"); } - int size = pointTypes.length; - if (numTypes >= size) { - int grow = size; - if (grow > EXPAND_MAX) { - grow = EXPAND_MAX; - } else if (grow == 0) { - grow = 1; - } - pointTypes = Arrays.copyOf(pointTypes, size+grow); + if (numTypes >= pointTypes.length) { + pointTypes = expandPointTypes(pointTypes, 1); + } + if (numCoords > (floatCoords.length - newCoords)) { + floatCoords = expandCoords(floatCoords, newCoords); + } + } + + static float[] expandCoords(float[] oldCoords, int needed) { + final int oldSize = oldCoords.length; + final int newSizeMin = oldSize + needed; + if (newSizeMin < oldSize) { + // hard overflow failure - we can't even accommodate + // new items without overflowing + throw new ArrayIndexOutOfBoundsException( + "coords exceeds maximum capacity !"); } - size = floatCoords.length; - if (numCoords + newCoords > size) { - int grow = size; - if (grow > EXPAND_MAX * 2) { - grow = EXPAND_MAX * 2; + // growth algorithm computation + int grow = oldSize; + if (grow > EXPAND_MAX_COORDS) { + grow = Math.max(EXPAND_MAX_COORDS, oldSize >> 3); // 1/8th min + } else if (grow < EXPAND_MIN) { + grow = EXPAND_MIN; + } + assert grow > needed; + + int newSize = oldSize + grow; + if (newSize < newSizeMin) { + // overflow in growth algorithm computation + newSize = Integer.MAX_VALUE; + } + while (true) { + try { + // try allocating the larger array + return Arrays.copyOf(oldCoords, newSize); + } catch (OutOfMemoryError oome) { + if (newSize == newSizeMin) { + throw oome; + } } - if (grow < newCoords) { - grow = newCoords; - } - floatCoords = Arrays.copyOf(floatCoords, size+grow); + newSize = newSizeMin + (newSize - newSizeMin) / 2; } } @@ -475,6 +539,9 @@ } int pointCrossings(double px, double py) { + if (numTypes == 0) { + return 0; + } double movx, movy, curx, cury, endx, endy; float coords[] = floatCoords; curx = movx = coords[0]; @@ -552,6 +619,9 @@ int rectCrossings(double rxmin, double rymin, double rxmax, double rymax) { + if (numTypes == 0) { + return 0; + } float coords[] = floatCoords; double curx, cury, movx, movy, endx, endy; curx = movx = coords[0]; @@ -1061,8 +1131,8 @@ Path2D p2d = (Path2D) s; setWindingRule(p2d.windingRule); this.numTypes = p2d.numTypes; - this.pointTypes = Arrays.copyOf(p2d.pointTypes, - p2d.pointTypes.length); + // trim arrays: + this.pointTypes = Arrays.copyOf(p2d.pointTypes, p2d.numTypes); this.numCoords = p2d.numCoords; this.doubleCoords = p2d.cloneCoordsDouble(at); } else { @@ -1074,8 +1144,10 @@ } } + @Override float[] cloneCoordsFloat(AffineTransform at) { - float ret[] = new float[doubleCoords.length]; + // trim arrays: + float ret[] = new float[numCoords]; if (at == null) { for (int i = 0; i < numCoords; i++) { ret[i] = (float) doubleCoords[i]; @@ -1086,13 +1158,14 @@ return ret; } + @Override double[] cloneCoordsDouble(AffineTransform at) { + // trim arrays: double ret[]; if (at == null) { - ret = Arrays.copyOf(this.doubleCoords, - this.doubleCoords.length); + ret = Arrays.copyOf(doubleCoords, numCoords); } else { - ret = new double[doubleCoords.length]; + ret = new double[numCoords]; at.transform(doubleCoords, 0, ret, 0, numCoords / 2); } return ret; @@ -1113,31 +1186,53 @@ doubleCoords[coordindex+1]); } + @Override void needRoom(boolean needMove, int newCoords) { - if (needMove && numTypes == 0) { + if ((numTypes == 0) && needMove) { throw new IllegalPathStateException("missing initial moveto "+ "in path definition"); } - int size = pointTypes.length; - if (numTypes >= size) { - int grow = size; - if (grow > EXPAND_MAX) { - grow = EXPAND_MAX; - } else if (grow == 0) { - grow = 1; - } - pointTypes = Arrays.copyOf(pointTypes, size+grow); + if (numTypes >= pointTypes.length) { + pointTypes = expandPointTypes(pointTypes, 1); + } + if (numCoords > (doubleCoords.length - newCoords)) { + doubleCoords = expandCoords(doubleCoords, newCoords); + } + } + + static double[] expandCoords(double[] oldCoords, int needed) { + final int oldSize = oldCoords.length; + final int newSizeMin = oldSize + needed; + if (newSizeMin < oldSize) { + // hard overflow failure - we can't even accommodate + // new items without overflowing + throw new ArrayIndexOutOfBoundsException( + "coords exceeds maximum capacity !"); } - size = doubleCoords.length; - if (numCoords + newCoords > size) { - int grow = size; - if (grow > EXPAND_MAX * 2) { - grow = EXPAND_MAX * 2; + // growth algorithm computation + int grow = oldSize; + if (grow > EXPAND_MAX_COORDS) { + grow = Math.max(EXPAND_MAX_COORDS, oldSize >> 3); // 1/8th min + } else if (grow < EXPAND_MIN) { + grow = EXPAND_MIN; + } + assert grow > needed; + + int newSize = oldSize + grow; + if (newSize < newSizeMin) { + // overflow in growth algorithm computation + newSize = Integer.MAX_VALUE; + } + while (true) { + try { + // try allocating the larger array + return Arrays.copyOf(oldCoords, newSize); + } catch (OutOfMemoryError oome) { + if (newSize == newSizeMin) { + throw oome; + } } - if (grow < newCoords) { - grow = newCoords; - } - doubleCoords = Arrays.copyOf(doubleCoords, size+grow); + newSize = newSizeMin + (newSize - newSizeMin) / 2; } } @@ -1202,6 +1297,9 @@ } int pointCrossings(double px, double py) { + if (numTypes == 0) { + return 0; + } double movx, movy, curx, cury, endx, endy; double coords[] = doubleCoords; curx = movx = coords[0]; @@ -1279,6 +1377,9 @@ int rectCrossings(double rxmin, double rymin, double rxmax, double rymax) { + if (numTypes == 0) { + return 0; + } double coords[] = doubleCoords; double curx, cury, movx, movy, endx, endy; curx = movx = coords[0]; diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/java/lang/invoke/Invokers.java --- a/src/share/classes/java/lang/invoke/Invokers.java Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/java/lang/invoke/Invokers.java Wed Jun 03 20:28:57 2015 -0700 @@ -281,7 +281,7 @@ outArgs[0] = names[CHECK_TYPE]; } if (CHECK_CUSTOM != -1) { - names[CHECK_CUSTOM] = new Name(NF_checkCustomized, names[CALL_MH]); + names[CHECK_CUSTOM] = new Name(NF_checkCustomized, outArgs[0]); } names[LINKER_CALL] = new Name(outCallType, outArgs); lform = new LambdaForm(debugName, INARG_LIMIT, names); diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/java/lang/invoke/LambdaForm.java --- a/src/share/classes/java/lang/invoke/LambdaForm.java Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/java/lang/invoke/LambdaForm.java Wed Jun 03 20:28:57 2015 -0700 @@ -631,7 +631,7 @@ * as a sort of pre-invocation linkage step.) */ public void prepare() { - if (COMPILE_THRESHOLD == 0) { + if (COMPILE_THRESHOLD == 0 && !isCompiled) { compileToBytecode(); } if (this.vmentry != null) { @@ -645,11 +645,11 @@ /** Generate optimizable bytecode for this form. */ MemberName compileToBytecode() { - MethodType invokerType = methodType(); - assert(vmentry == null || vmentry.getMethodType().basicType().equals(invokerType)); if (vmentry != null && isCompiled) { return vmentry; // already compiled somehow } + MethodType invokerType = methodType(); + assert(vmentry == null || vmentry.getMethodType().basicType().equals(invokerType)); try { vmentry = InvokerBytecodeGenerator.generateCustomizedCode(this, invokerType); if (TRACE_INTERPRETER) diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/java/util/concurrent/ForkJoinPool.java --- a/src/share/classes/java/util/concurrent/ForkJoinPool.java Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/java/util/concurrent/ForkJoinPool.java Wed Jun 03 20:28:57 2015 -0700 @@ -1323,13 +1323,16 @@ /** * Number of times to spin-wait before blocking. The spins (in * awaitRunStateLock and awaitWork) currently use randomized - * spins. If/when MWAIT-like intrinsics becomes available, they - * may allow quieter spinning. The value of SPINS must be a power - * of two, at least 4. The current value causes spinning for a - * small fraction of typical context-switch times, well worthwhile - * given the typical likelihoods that blocking is not necessary. + * spins. Currently set to zero to reduce CPU usage. + * + * If greater than zero the value of SPINS must be a power + * of two, at least 4. A value of 2048 causes spinning for a + * small fraction of typical context-switch times. + * + * If/when MWAIT-like intrinsics becomes available, they + * may allow quieter spinning. */ - private static final int SPINS = 1 << 11; + private static final int SPINS = 0; /** * Increment for seed generators. See class ThreadLocal for diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/javax/script/Compilable.java --- a/src/share/classes/javax/script/Compilable.java Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/javax/script/Compilable.java Wed Jun 03 20:28:57 2015 -0700 @@ -42,7 +42,7 @@ * * @param script The source of the script, represented as a String. * - * @return An subclass of CompiledScript to be executed later using one + * @return An instance of a subclass of CompiledScript to be executed later using one * of the eval methods of CompiledScript. * * @throws ScriptException if compilation fails. @@ -61,7 +61,7 @@ * * @param script The reader from which the script source is obtained. * - * @return An implementation of CompiledScript to be executed + * @return An instance of a subclass of CompiledScript to be executed * later using one of its eval methods of CompiledScript. * * @throws ScriptException if compilation fails. diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/javax/script/SimpleScriptContext.java --- a/src/share/classes/javax/script/SimpleScriptContext.java Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/javax/script/SimpleScriptContext.java Wed Jun 03 20:28:57 2015 -0700 @@ -140,6 +140,7 @@ * @throws IllegalArgumentException if the name is empty. */ public Object getAttribute(String name) { + checkName(name); if (engineScope.containsKey(name)) { return getAttribute(name, ENGINE_SCOPE); } else if (globalScope != null && globalScope.containsKey(name)) { @@ -162,7 +163,7 @@ * @throws NullPointerException if the name is null. */ public Object getAttribute(String name, int scope) { - + checkName(name); switch (scope) { case ENGINE_SCOPE: @@ -191,7 +192,7 @@ * @throws NullPointerException if the name is null. */ public Object removeAttribute(String name, int scope) { - + checkName(name); switch (scope) { case ENGINE_SCOPE: @@ -223,7 +224,7 @@ * @throws NullPointerException if the name is null. */ public void setAttribute(String name, Object value, int scope) { - + checkName(name); switch (scope) { case ENGINE_SCOPE: @@ -281,6 +282,7 @@ * @throws IllegalArgumentException if name is empty. */ public int getAttributesScope(String name) { + checkName(name); if (engineScope.containsKey(name)) { return ENGINE_SCOPE; } else if (globalScope != null && globalScope.containsKey(name)) { @@ -314,6 +316,13 @@ return scopes; } + private void checkName(String name) { + Objects.requireNonNull(name); + if (name.isEmpty()) { + throw new IllegalArgumentException("name cannot be empty"); + } + } + private static List scopes; static { scopes = new ArrayList(2); diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/javax/sql/rowset/serial/SerialBlob.java --- a/src/share/classes/javax/sql/rowset/serial/SerialBlob.java Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/javax/sql/rowset/serial/SerialBlob.java Wed Jun 03 20:28:57 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -66,7 +66,7 @@ * value of this SerialBlob object. * @serial */ - private byte buf[]; + private byte[] buf; /** * The internal representation of the Blob object on which this @@ -102,12 +102,13 @@ * @throws SerialException if an error occurs during serialization * @throws SQLException if a SQL errors occurs */ - public SerialBlob(byte[] b) throws SerialException, SQLException { + public SerialBlob(byte[] b) + throws SerialException, SQLException { len = b.length; buf = new byte[(int)len]; for(int i = 0; i < len; i++) { - buf[i] = b[i]; + buf[i] = b[i]; } origLen = len; } @@ -132,19 +133,17 @@ * to this constructor is a null. * @see java.sql.Blob */ - public SerialBlob (Blob blob) throws SerialException, SQLException { + public SerialBlob (Blob blob) + throws SerialException, SQLException { if (blob == null) { - throw new SQLException("Cannot instantiate a SerialBlob " + - "object with a null Blob object"); + throw new SQLException( + "Cannot instantiate a SerialBlob object with a null Blob object"); } len = blob.length(); buf = blob.getBytes(1, (int)len ); this.blob = blob; - - //if ( len < 10240000) - // len = 10240000; origLen = len; } @@ -245,7 +244,8 @@ * value from the database */ public long position(byte[] pattern, long start) - throws SerialException, SQLException { + throws SerialException, SQLException { + isValid(); if (start < 1 || start > len) { return -1; @@ -290,7 +290,7 @@ * value from the database */ public long position(Blob pattern, long start) - throws SerialException, SQLException { + throws SerialException, SQLException { isValid(); return position(pattern.getBytes(1, (int)(pattern.length())), start); } @@ -316,8 +316,8 @@ * @see #getBytes */ public int setBytes(long pos, byte[] bytes) - throws SerialException, SQLException { - return (setBytes(pos, bytes, 0, bytes.length)); + throws SerialException, SQLException { + return setBytes(pos, bytes, 0, bytes.length); } /** @@ -352,7 +352,7 @@ * @see #getBytes */ public int setBytes(long pos, byte[] bytes, int offset, int length) - throws SerialException, SQLException { + throws SerialException, SQLException { isValid(); if (offset < 0 || offset > bytes.length) { @@ -369,7 +369,7 @@ if ((length + offset) > bytes.length) { throw new SerialException("Invalid OffSet. Cannot have combined offset " + - "and length that is greater that the Blob buffer"); + "and length that is greater that the Blob buffer"); } int i = 0; @@ -402,7 +402,8 @@ * @see #getBinaryStream */ public java.io.OutputStream setBinaryStream(long pos) - throws SerialException, SQLException { + throws SerialException, SQLException { + isValid(); if (this.blob != null) { return this.blob.setBinaryStream(pos); @@ -425,17 +426,16 @@ * if {@code free} had previously been called on this object */ public void truncate(long length) throws SerialException { - isValid(); if (length > len) { - throw new SerialException - ("Length more than what can be truncated"); + throw new SerialException( + "Length more than what can be truncated"); } else if((int)length == 0) { - buf = new byte[0]; - len = length; + buf = new byte[0]; + len = length; } else { - len = length; - buf = this.getBytes(1, (int)len); + len = length; + buf = this.getBytes(1, (int)len); } } @@ -466,8 +466,8 @@ throw new SerialException("Invalid position in BLOB object set"); } if (length < 1 || length > len - pos + 1) { - throw new SerialException("length is < 1 or pos + length >" - + "total number of bytes"); + throw new SerialException( + "length is < 1 or pos + length > total number of bytes"); } return new ByteArrayInputStream(buf, (int) pos - 1, (int) length); } @@ -536,14 +536,13 @@ public Object clone() { try { SerialBlob sb = (SerialBlob) super.clone(); - sb.buf = (buf != null) ? Arrays.copyOf(buf, (int)len) : null; + sb.buf = (buf != null) ? Arrays.copyOf(buf, (int)len) : null; sb.blob = null; return sb; } catch (CloneNotSupportedException ex) { // this shouldn't happen, since we are Cloneable throw new InternalError(); } - } /** @@ -554,15 +553,15 @@ throws IOException, ClassNotFoundException { ObjectInputStream.GetField fields = s.readFields(); - byte[] tmp = (byte[])fields.get("buf", null); - if (tmp == null) - throw new InvalidObjectException("buf is null and should not be!"); - buf = tmp.clone(); - len = fields.get("len", 0L); - if (buf.length != len) - throw new InvalidObjectException("buf is not the expected size"); - origLen = fields.get("origLen", 0L); - blob = (Blob) fields.get("blob", null); + byte[] tmp = (byte[])fields.get("buf", null); + if (tmp == null) + throw new InvalidObjectException("buf is null and should not be!"); + buf = tmp.clone(); + len = fields.get("len", 0L); + if (buf.length != len) + throw new InvalidObjectException("buf is not the expected size"); + origLen = fields.get("origLen", 0L); + blob = (Blob) fields.get("blob", null); } /** @@ -590,8 +589,8 @@ */ private void isValid() throws SerialException { if (buf == null) { - throw new SerialException("Error: You cannot call a method on a " - + "SerialBlob instance once free() has been called."); + throw new SerialException("Error: You cannot call a method on a " + + "SerialBlob instance once free() has been called."); } } diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java --- a/src/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java Wed Jun 03 20:28:57 2015 -0700 @@ -125,6 +125,8 @@ protected MouseMotionListener popupMouseMotionListener; protected KeyListener popupKeyListener; + private MouseWheelListener mouseWheelListener; + // This is used for knowing when to cache the minimum preferred size. // If the data in the list changes, the cached value get marked for recalc. // Added to the current JComboBox model @@ -375,6 +377,10 @@ comboBox.getModel().addListDataListener( listDataListener ); } } + + if ((mouseWheelListener = createMouseWheelListener()) != null) { + comboBox.addMouseWheelListener(mouseWheelListener); + } } /** @@ -421,6 +427,9 @@ comboBox.getModel().removeListDataListener( listDataListener ); } } + if (mouseWheelListener != null) { + comboBox.removeMouseWheelListener(mouseWheelListener); + } } /** @@ -534,6 +543,10 @@ return handler; } + private MouseWheelListener createMouseWheelListener() { + return getHandler(); + } + // // end UI Initialization //====================== @@ -1669,7 +1682,8 @@ // private class Handler implements ActionListener, FocusListener, KeyListener, LayoutManager, - ListDataListener, PropertyChangeListener { + ListDataListener, PropertyChangeListener, + MouseWheelListener { // // PropertyChangeListener // @@ -1939,21 +1953,25 @@ public void actionPerformed(ActionEvent evt) { Object item = comboBox.getEditor().getItem(); if (item != null) { - if(!comboBox.isPopupVisible() && !item.equals(comboBox.getSelectedItem())) { - comboBox.setSelectedItem(comboBox.getEditor().getItem()); - } - ActionMap am = comboBox.getActionMap(); - if (am != null) { - Action action = am.get("enterPressed"); - if (action != null) { - action.actionPerformed(new ActionEvent(comboBox, evt.getID(), - evt.getActionCommand(), - evt.getModifiers())); + if (!comboBox.isPopupVisible() && !item.equals(comboBox.getSelectedItem())) { + comboBox.setSelectedItem(comboBox.getEditor().getItem()); + } + ActionMap am = comboBox.getActionMap(); + if (am != null) { + Action action = am.get("enterPressed"); + if (action != null) { + action.actionPerformed(new ActionEvent(comboBox, evt.getID(), + evt.getActionCommand(), + evt.getModifiers())); + } } } - } + } + + public void mouseWheelMoved(MouseWheelEvent e) { + e.consume(); + } } - } class DefaultKeySelectionManager implements JComboBox.KeySelectionManager, UIResource { private String prefix = ""; diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/javax/swing/plaf/basic/BasicComboPopup.java --- a/src/share/classes/javax/swing/plaf/basic/BasicComboPopup.java Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/javax/swing/plaf/basic/BasicComboPopup.java Wed Jun 03 20:28:57 2015 -0700 @@ -180,6 +180,8 @@ */ protected ItemListener itemListener; + private MouseWheelListener scrollerMouseWheelListener; + /** * This protected field is implementation specific. Do not access directly * or override. @@ -286,6 +288,7 @@ uninstallComboBoxModelListeners(comboBox.getModel()); uninstallKeyboardActions(); uninstallListListeners(); + uninstallScrollerListeners(); // We do this, otherwise the listener the ui installs on // the model (the combobox model in this case) will keep a // reference to the list, causing the list (and us) to never get gced. @@ -572,6 +575,7 @@ scroller.setFocusable( false ); scroller.getVerticalScrollBar().setFocusable( false ); scroller.setBorder( null ); + installScrollerListeners(); } /** @@ -588,6 +592,20 @@ setFocusable( false ); } + private void installScrollerListeners() { + scrollerMouseWheelListener = getHandler(); + if (scrollerMouseWheelListener != null) { + scroller.addMouseWheelListener(scrollerMouseWheelListener); + } + } + + private void uninstallScrollerListeners() { + if (scrollerMouseWheelListener != null) { + scroller.removeMouseWheelListener(scrollerMouseWheelListener); + scrollerMouseWheelListener = null; + } + } + /** * This method adds the necessary listeners to the JComboBox. */ @@ -796,8 +814,8 @@ private class Handler implements ItemListener, MouseListener, - MouseMotionListener, PropertyChangeListener, - Serializable { + MouseMotionListener, MouseWheelListener, + PropertyChangeListener, Serializable { // // MouseListener // NOTE: this is added to both the JList and JComboBox @@ -981,6 +999,13 @@ setListSelection(comboBox.getSelectedIndex()); } } + + // + // MouseWheelListener + // + public void mouseWheelMoved(MouseWheelEvent e) { + e.consume(); + } } // diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/javax/swing/plaf/basic/BasicPopupMenuUI.java --- a/src/share/classes/javax/swing/plaf/basic/BasicPopupMenuUI.java Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/javax/swing/plaf/basic/BasicPopupMenuUI.java Wed Jun 03 20:28:57 2015 -0700 @@ -884,7 +884,9 @@ processMouseEvent(me); break; case MouseEvent.MOUSE_WHEEL: - if (isInPopup(src)) { + if (isInPopup(src) + || ((src instanceof JComboBox) && ((JComboBox) src).isPopupVisible())) { + return; } cancelPopupMenu(); diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java --- a/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java Wed Jun 03 20:28:57 2015 -0700 @@ -982,7 +982,7 @@ SocketPermission p = URLtoSocketPermission(this.url); if (p != null) { try { - AccessController.doPrivileged( + AccessController.doPrivilegedWithCombiner( new PrivilegedExceptionAction() { public Void run() throws IOException { plainConnect0(); @@ -1243,7 +1243,7 @@ if (p != null) { try { - return AccessController.doPrivileged( + return AccessController.doPrivilegedWithCombiner( new PrivilegedExceptionAction() { public OutputStream run() throws IOException { return getOutputStream0(); @@ -1426,7 +1426,7 @@ if (p != null) { try { - return AccessController.doPrivileged( + return AccessController.doPrivilegedWithCombiner( new PrivilegedExceptionAction() { public InputStream run() throws IOException { return getInputStream0(); @@ -2568,7 +2568,7 @@ if (p != null) { try { - return AccessController.doPrivileged( + return AccessController.doPrivilegedWithCombiner( new PrivilegedExceptionAction() { public Boolean run() throws IOException { return followRedirect0(loc, stat, locUrl0); diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/sun/security/krb5/Config.java --- a/src/share/classes/sun/security/krb5/Config.java Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/sun/security/krb5/Config.java Wed Jun 03 20:28:57 2015 -0700 @@ -232,6 +232,31 @@ } /** + * Gets the boolean value for the specified keys. Returns TRUE if the + * string value is "yes", or "true", FALSE if "no", or "false", or null + * if otherwise or not defined. The comparision is case-insensitive. + * + * @param keys the keys, see {@link #get(String...)} + * @return the boolean value, or null if there is no value defined or the + * value does not look like a boolean value. + * @throws IllegalArgumentException see {@link #get(String...)} + */ + private Boolean getBooleanObject(String... keys) { + String s = get(keys); + if (s == null) { + return null; + } + switch (s.toLowerCase(Locale.US)) { + case "yes": case "true": + return Boolean.TRUE; + case "no": case "false": + return Boolean.FALSE; + default: + return null; + } + } + + /** * Gets all values for the specified keys. * @throws IllegalArgumentException if any of the keys is illegal * (See {@link #get}) @@ -942,32 +967,30 @@ /** * Check if need to use DNS to locate Kerberos services */ - private boolean useDNS(String name) { - String value = get("libdefaults", name); - if (value == null) { - value = get("libdefaults", "dns_fallback"); - if ("false".equalsIgnoreCase(value)) { - return false; - } else { - return true; - } - } else { - return value.equalsIgnoreCase("true"); + private boolean useDNS(String name, boolean defaultValue) { + Boolean value = getBooleanObject("libdefaults", name); + if (value != null) { + return value.booleanValue(); } + value = getBooleanObject("libdefaults", "dns_fallback"); + if (value != null) { + return value.booleanValue(); + } + return defaultValue; } /** * Check if need to use DNS to locate the KDC */ private boolean useDNS_KDC() { - return useDNS("dns_lookup_kdc"); + return useDNS("dns_lookup_kdc", true); } /* * Check if need to use DNS to locate the Realm */ private boolean useDNS_Realm() { - return useDNS("dns_lookup_realm"); + return useDNS("dns_lookup_realm", false); } /** diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java --- a/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java Wed Jun 03 20:28:57 2015 -0700 @@ -1058,6 +1058,39 @@ } /** + * Determines if the keystore {@code Entry} for the specified + * {@code alias} is an instance or subclass of the specified + * {@code entryClass}. + * + * @param alias the alias name + * @param entryClass the entry class + * + * @return true if the keystore {@code Entry} for the specified + * {@code alias} is an instance or subclass of the + * specified {@code entryClass}, false otherwise + * + * @since 1.5 + */ + @Override + public boolean + engineEntryInstanceOf(String alias, + Class entryClass) + { + if (entryClass == KeyStore.TrustedCertificateEntry.class) { + return engineIsCertificateEntry(alias); + } + + Entry entry = entries.get(alias.toLowerCase(Locale.ENGLISH)); + if (entryClass == KeyStore.PrivateKeyEntry.class) { + return (entry != null && entry instanceof PrivateKeyEntry); + } + if (entryClass == KeyStore.SecretKeyEntry.class) { + return (entry != null && entry instanceof SecretKeyEntry); + } + return false; + } + + /** * Returns the (alias) name of the first keystore entry whose certificate * matches the given certificate. * @@ -1089,7 +1122,7 @@ } else { continue; } - if (certElem.equals(cert)) { + if (certElem != null && certElem.equals(cert)) { return alias; } } @@ -1932,7 +1965,12 @@ safeContentsData = safeContents.getData(); } else if (contentType.equals((Object)ContentInfo.ENCRYPTED_DATA_OID)) { if (password == null) { - continue; + + if (debug != null) { + debug.println("Warning: skipping PKCS#7 encryptedData" + + " content-type - no password was supplied"); + } + continue; } if (debug != null) { @@ -1974,8 +2012,9 @@ password = new char[1]; continue; } - throw new IOException( - "failed to decrypt safe contents entry: " + e, e); + throw new IOException("keystore password was incorrect", + new UnrecoverableKeyException( + "failed to decrypt safe contents entry: " + e)); } } } else { diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/sun/security/provider/JavaKeyStore.java --- a/src/share/classes/sun/security/provider/JavaKeyStore.java Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/sun/security/provider/JavaKeyStore.java Wed Jun 03 20:28:57 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,9 +31,10 @@ import java.security.cert.CertificateFactory; import java.security.cert.CertificateException; import java.util.*; + import sun.misc.IOUtils; - import sun.security.pkcs.EncryptedPrivateKeyInfo; +import sun.security.pkcs12.PKCS12KeyStore; /** * This class provides the keystore implementation referred to as "JKS". @@ -65,6 +66,13 @@ } } + // special JKS that supports JKS and PKCS12 file formats + public static final class DualFormatJKS extends KeyStoreDelegator { + public DualFormatJKS() { + super("JKS", JKS.class, "PKCS12", PKCS12KeyStore.class); + } + } + private static final int MAGIC = 0xfeedfeed; private static final int VERSION_1 = 0x01; private static final int VERSION_2 = 0x02; diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/sun/security/provider/KeyStoreDelegator.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/sun/security/provider/KeyStoreDelegator.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,279 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.security.provider; + +import java.io.*; +import java.security.*; +import java.security.cert.Certificate; +import java.security.cert.CertificateFactory; +import java.security.cert.CertificateException; +import java.util.*; + +import sun.security.util.Debug; + +/** + * This class delegates to a primary or secondary keystore implementation. + * + * @since 1.8 + */ + +class KeyStoreDelegator extends KeyStoreSpi { + + private static final String KEYSTORE_TYPE_COMPAT = "keystore.type.compat"; + private static final Debug debug = Debug.getInstance("keystore"); + + private final String primaryType; // the primary keystore's type + private final String secondaryType; // the secondary keystore's type + private final Class primaryKeyStore; + // the primary keystore's class + private final Class secondaryKeyStore; + // the secondary keystore's class + private String type; // the delegate's type + private KeyStoreSpi keystore; // the delegate + private boolean compatModeEnabled = true; + + public KeyStoreDelegator( + String primaryType, + Class primaryKeyStore, + String secondaryType, + Class secondaryKeyStore) { + + // Check whether compatibility mode has been disabled + // (Use inner-class instead of lambda to avoid init/ClassLoader problem) + compatModeEnabled = "true".equalsIgnoreCase( + AccessController.doPrivileged( + new PrivilegedAction() { + public String run() { + return Security.getProperty(KEYSTORE_TYPE_COMPAT); + } + } + )); + + if (compatModeEnabled) { + this.primaryType = primaryType; + this.secondaryType = secondaryType; + this.primaryKeyStore = primaryKeyStore; + this.secondaryKeyStore = secondaryKeyStore; + } else { + this.primaryType = primaryType; + this.secondaryType = null; + this.primaryKeyStore = primaryKeyStore; + this.secondaryKeyStore = null; + + if (debug != null) { + debug.println("WARNING: compatibility mode disabled for " + + primaryType + " and " + secondaryType + " keystore types"); + } + } + } + + @Override + public Key engineGetKey(String alias, char[] password) + throws NoSuchAlgorithmException, UnrecoverableKeyException { + return keystore.engineGetKey(alias, password); + } + + @Override + public Certificate[] engineGetCertificateChain(String alias) { + return keystore.engineGetCertificateChain(alias); + } + + @Override + public Certificate engineGetCertificate(String alias) { + return keystore.engineGetCertificate(alias); + } + + @Override + public Date engineGetCreationDate(String alias) { + return keystore.engineGetCreationDate(alias); + } + + @Override + public void engineSetKeyEntry(String alias, Key key, char[] password, + Certificate[] chain) throws KeyStoreException { + keystore.engineSetKeyEntry(alias, key, password, chain); + } + + @Override + public void engineSetKeyEntry(String alias, byte[] key, Certificate[] chain) + throws KeyStoreException { + keystore.engineSetKeyEntry(alias, key, chain); + } + + @Override + public void engineSetCertificateEntry(String alias, Certificate cert) + throws KeyStoreException { + keystore.engineSetCertificateEntry(alias, cert); + } + + @Override + public void engineDeleteEntry(String alias) throws KeyStoreException { + keystore.engineDeleteEntry(alias); + } + + @Override + public Enumeration engineAliases() { + return keystore.engineAliases(); + } + + @Override + public boolean engineContainsAlias(String alias) { + return keystore.engineContainsAlias(alias); + } + + @Override + public int engineSize() { + return keystore.engineSize(); + } + + @Override + public boolean engineIsKeyEntry(String alias) { + return keystore.engineIsKeyEntry(alias); + } + + @Override + public boolean engineIsCertificateEntry(String alias) { + return keystore.engineIsCertificateEntry(alias); + } + + @Override + public String engineGetCertificateAlias(Certificate cert) { + return keystore.engineGetCertificateAlias(cert); + } + + @Override + public KeyStore.Entry engineGetEntry(String alias, + KeyStore.ProtectionParameter protParam) + throws KeyStoreException, NoSuchAlgorithmException, + UnrecoverableEntryException { + return keystore.engineGetEntry(alias, protParam); + } + + @Override + public void engineSetEntry(String alias, KeyStore.Entry entry, + KeyStore.ProtectionParameter protParam) + throws KeyStoreException { + keystore.engineSetEntry(alias, entry, protParam); + } + + @Override + public boolean engineEntryInstanceOf(String alias, + Class entryClass) { + return keystore.engineEntryInstanceOf(alias, entryClass); + } + + @Override + public void engineStore(OutputStream stream, char[] password) + throws IOException, NoSuchAlgorithmException, CertificateException { + + if (debug != null) { + debug.println("Storing keystore in " + type + " format"); + } + keystore.engineStore(stream, password); + } + + @Override + public void engineLoad(InputStream stream, char[] password) + throws IOException, NoSuchAlgorithmException, CertificateException { + + // A new keystore is always created in the primary keystore format + if (stream == null || !compatModeEnabled) { + try { + keystore = primaryKeyStore.newInstance(); + + } catch (InstantiationException | IllegalAccessException e) { + // can safely ignore + } + type = primaryType; + + if (debug != null && stream == null) { + debug.println("Creating a new keystore in " + type + " format"); + } + keystore.engineLoad(stream, password); + + } else { + // First try the primary keystore then try the secondary keystore + try (InputStream bufferedStream = new BufferedInputStream(stream)) { + bufferedStream.mark(Integer.MAX_VALUE); + + try { + keystore = primaryKeyStore.newInstance(); + type = primaryType; + keystore.engineLoad(bufferedStream, password); + + } catch (Exception e) { + + // incorrect password + if (e instanceof IOException && + e.getCause() instanceof UnrecoverableKeyException) { + throw (IOException)e; + } + + try { + keystore = secondaryKeyStore.newInstance(); + type = secondaryType; + bufferedStream.reset(); + keystore.engineLoad(bufferedStream, password); + + if (debug != null) { + debug.println("WARNING: switching from " + + primaryType + " to " + secondaryType + + " keystore file format has altered the " + + "keystore security level"); + } + + } catch (InstantiationException | + IllegalAccessException e2) { + // can safely ignore + + } catch (IOException | + NoSuchAlgorithmException | + CertificateException e3) { + + // incorrect password + if (e3 instanceof IOException && + e3.getCause() instanceof + UnrecoverableKeyException) { + throw (IOException)e3; + } + // rethrow the outer exception + if (e instanceof IOException) { + throw (IOException)e; + } else if (e instanceof CertificateException) { + throw (CertificateException)e; + } else if (e instanceof NoSuchAlgorithmException) { + throw (NoSuchAlgorithmException)e; + } + } + } + } + + if (debug != null) { + debug.println("Loaded a keystore in " + type + " format"); + } + } + } +} diff -r e5171238515c -r ec8f5229c8e9 src/share/classes/sun/security/provider/SunEntries.java --- a/src/share/classes/sun/security/provider/SunEntries.java Fri May 29 10:15:38 2015 -0700 +++ b/src/share/classes/sun/security/provider/SunEntries.java Wed Jun 03 20:28:57 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -228,7 +228,8 @@ /* * KeyStore */ - map.put("KeyStore.JKS", "sun.security.provider.JavaKeyStore$JKS"); + map.put("KeyStore.JKS", + "sun.security.provider.JavaKeyStore$DualFormatJKS"); map.put("KeyStore.CaseExactJKS", "sun.security.provider.JavaKeyStore$CaseExactJKS"); map.put("KeyStore.DKS", "sun.security.provider.DomainKeyStore$DKS"); diff -r e5171238515c -r ec8f5229c8e9 src/share/lib/security/java.security-aix --- a/src/share/lib/security/java.security-aix Fri May 29 10:15:38 2015 -0700 +++ b/src/share/lib/security/java.security-aix Wed Jun 03 20:28:57 2015 -0700 @@ -171,6 +171,15 @@ keystore.type=jks # +# Controls compatibility mode for the JKS keystore type. +# +# When set to 'true', the JKS keystore type supports loading +# keystore files in either JKS or PKCS12 format. When set to 'false' +# it supports loading only JKS keystore files. +# +keystore.type.compat=true + +# # List of comma-separated packages that start with or equal this string # will cause a security exception to be thrown when # passed to checkPackageAccess unless the diff -r e5171238515c -r ec8f5229c8e9 src/share/lib/security/java.security-linux --- a/src/share/lib/security/java.security-linux Fri May 29 10:15:38 2015 -0700 +++ b/src/share/lib/security/java.security-linux Wed Jun 03 20:28:57 2015 -0700 @@ -171,6 +171,15 @@ keystore.type=jks # +# Controls compatibility mode for the JKS keystore type. +# +# When set to 'true', the JKS keystore type supports loading +# keystore files in either JKS or PKCS12 format. When set to 'false' +# it supports loading only JKS keystore files. +# +keystore.type.compat=true + +# # List of comma-separated packages that start with or equal this string # will cause a security exception to be thrown when # passed to checkPackageAccess unless the diff -r e5171238515c -r ec8f5229c8e9 src/share/lib/security/java.security-macosx --- a/src/share/lib/security/java.security-macosx Fri May 29 10:15:38 2015 -0700 +++ b/src/share/lib/security/java.security-macosx Wed Jun 03 20:28:57 2015 -0700 @@ -172,6 +172,15 @@ keystore.type=jks # +# Controls compatibility mode for the JKS keystore type. +# +# When set to 'true', the JKS keystore type supports loading +# keystore files in either JKS or PKCS12 format. When set to 'false' +# it supports loading only JKS keystore files. +# +keystore.type.compat=true + +# # List of comma-separated packages that start with or equal this string # will cause a security exception to be thrown when # passed to checkPackageAccess unless the diff -r e5171238515c -r ec8f5229c8e9 src/share/lib/security/java.security-solaris --- a/src/share/lib/security/java.security-solaris Fri May 29 10:15:38 2015 -0700 +++ b/src/share/lib/security/java.security-solaris Wed Jun 03 20:28:57 2015 -0700 @@ -173,6 +173,15 @@ keystore.type=jks # +# Controls compatibility mode for the JKS keystore type. +# +# When set to 'true', the JKS keystore type supports loading +# keystore files in either JKS or PKCS12 format. When set to 'false' +# it supports loading only JKS keystore files. +# +keystore.type.compat=true + +# # List of comma-separated packages that start with or equal this string # will cause a security exception to be thrown when # passed to checkPackageAccess unless the diff -r e5171238515c -r ec8f5229c8e9 src/share/lib/security/java.security-windows --- a/src/share/lib/security/java.security-windows Fri May 29 10:15:38 2015 -0700 +++ b/src/share/lib/security/java.security-windows Wed Jun 03 20:28:57 2015 -0700 @@ -172,6 +172,15 @@ keystore.type=jks # +# Controls compatibility mode for the JKS keystore type. +# +# When set to 'true', the JKS keystore type supports loading +# keystore files in either JKS or PKCS12 format. When set to 'false' +# it supports loading only JKS keystore files. +# +keystore.type.compat=true + +# # List of comma-separated packages that start with or equal this string # will cause a security exception to be thrown when # passed to checkPackageAccess unless the diff -r e5171238515c -r ec8f5229c8e9 src/solaris/classes/sun/awt/X11/XWindow.java --- a/src/solaris/classes/sun/awt/X11/XWindow.java Fri May 29 10:15:38 2015 -0700 +++ b/src/solaris/classes/sun/awt/X11/XWindow.java Wed Jun 03 20:28:57 2015 -0700 @@ -568,10 +568,6 @@ } static int getModifiers(int state, int button, int keyCode) { - return getModifiers(state, button, keyCode, 0, false); - } - - static int getModifiers(int state, int button, int keyCode, int type, boolean wheel_mouse) { int modifiers = 0; if (((state & XConstants.ShiftMask) != 0) ^ (keyCode == KeyEvent.VK_SHIFT)) { @@ -602,7 +598,7 @@ // ONLY one of these conditions should be TRUE to add that modifier. if (((state & XlibUtil.getButtonMask(i + 1)) != 0) != (button == XConstants.buttons[i])){ //exclude wheel buttons from adding their numbers as modifiers - if (!wheel_mouse) { + if (!isWheel(XConstants.buttons[i])) { modifiers |= InputEvent.getMaskForButton(i+1); } } @@ -610,6 +606,11 @@ return modifiers; } + static boolean isWheel(int button) { + // 4 and 5 buttons are usually considered assigned to a first wheel + return button == XConstants.buttons[3] || button == XConstants.buttons[4]; + } + static int getXModifiers(AWTKeyStroke stroke) { int mods = stroke.getModifiers(); int res = 0; @@ -649,7 +650,6 @@ int modifiers; boolean popupTrigger = false; int button=0; - boolean wheel_mouse = false; int lbutton = xbe.get_button(); /* * Ignore the buttons above 20 due to the bit limit for @@ -702,11 +702,6 @@ } button = XConstants.buttons[lbutton - 1]; - // 4 and 5 buttons are usually considered assigned to a first wheel - if (lbutton == XConstants.buttons[3] || - lbutton == XConstants.buttons[4]) { - wheel_mouse = true; - } // mapping extra buttons to numbers starting from 4. if ((button > XConstants.buttons[4]) && (!Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled())){ @@ -716,9 +711,9 @@ if (button > XConstants.buttons[4]){ button -= 2; } - modifiers = getModifiers(xbe.get_state(),button,0, type, wheel_mouse); + modifiers = getModifiers(xbe.get_state(),button,0); - if (!wheel_mouse) { + if (!isWheel(lbutton)) { MouseEvent me = new MouseEvent((Component)getEventSource(), type == XConstants.ButtonPress ? MouseEvent.MOUSE_PRESSED : MouseEvent.MOUSE_RELEASED, jWhen,modifiers, x, y, diff -r e5171238515c -r ec8f5229c8e9 src/solaris/native/sun/awt/awt_InputMethod.c --- a/src/solaris/native/sun/awt/awt_InputMethod.c Fri May 29 10:15:38 2015 -0700 +++ b/src/solaris/native/sun/awt/awt_InputMethod.c Wed Jun 03 20:28:57 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -904,7 +904,6 @@ static Bool createXIC(JNIEnv * env, X11InputMethodData *pX11IMData, Window w) { - XIC active_ic, passive_ic; XVaNestedList preedit = NULL; XVaNestedList status = NULL; XIMStyle on_the_spot_styles = XIMPreeditCallbacks, @@ -974,6 +973,12 @@ } if (active_styles == on_the_spot_styles) { + pX11IMData->ic_passive = XCreateIC(X11im, + XNClientWindow, w, + XNFocusWindow, w, + XNInputStyle, passive_styles, + NULL); + callbacks = (XIMCallback *)malloc(sizeof(XIMCallback) * NCALLBACKS); if (callbacks == (XIMCallback *)NULL) return False; @@ -1024,12 +1029,6 @@ NULL); XFree((void *)preedit); #endif /* __linux__ || MACOSX */ - pX11IMData->ic_passive = XCreateIC(X11im, - XNClientWindow, w, - XNFocusWindow, w, - XNInputStyle, passive_styles, - NULL); - } else { pX11IMData->ic_active = XCreateIC(X11im, XNClientWindow, w, diff -r e5171238515c -r ec8f5229c8e9 src/solaris/native/sun/awt/utility/rect.h --- a/src/solaris/native/sun/awt/utility/rect.h Fri May 29 10:15:38 2015 -0700 +++ b/src/solaris/native/sun/awt/utility/rect.h Wed Jun 03 20:28:57 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2014 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r e5171238515c -r ec8f5229c8e9 src/windows/bin/java_md.c --- a/src/windows/bin/java_md.c Fri May 29 10:15:38 2015 -0700 +++ b/src/windows/bin/java_md.c Wed Jun 03 20:28:57 2015 -0700 @@ -1407,6 +1407,26 @@ return JNI_FALSE; } +int +filterArgs(StdArg *stdargs, const int nargc, StdArg **pargv) { + StdArg* argv = NULL; + int nargs = 0; + int i; + + /* Copy the non-vm args */ + for (i = 0; i < nargc ; i++) { + const char *arg = stdargs[i].arg; + if (arg[0] == '-' && arg[1] == 'J') + continue; + argv = (StdArg*) JLI_MemRealloc(argv, (nargs+1) * sizeof(StdArg)); + argv[nargs].arg = JLI_StringDup(arg); + argv[nargs].has_wildcard = stdargs[i].has_wildcard; + nargs++; + } + *pargv = argv; + return nargs; +} + /* * At this point we have the arguments to the application, and we need to * check with original stdargs in order to compare which of these truly @@ -1421,8 +1441,9 @@ char *ostart, *astart, **nargv; jboolean needs_expansion = JNI_FALSE; jmethodID mid; - int stdargc; + int filteredargc, stdargc; StdArg *stdargs; + StdArg *filteredargs; jclass cls = GetLauncherHelperClass(env); NULL_CHECK0(cls); @@ -1433,6 +1454,8 @@ stdargs = JLI_GetStdArgs(); stdargc = JLI_GetStdArgc(); + filteredargc = filterArgs(stdargs, stdargc, &filteredargs); + // sanity check, this should never happen if (argc > stdargc) { JLI_TraceLauncher("Warning: app args is larger than the original, %d %d\n", argc, stdargc); @@ -1441,8 +1464,8 @@ } // sanity check, match the args we have, to the holy grail - idx = stdargc - argc; - ostart = stdargs[idx].arg; + idx = filteredargc - argc; + ostart = filteredargs[idx].arg; astart = strv[0]; // sanity check, ensure that the first argument of the arrays are the same if (JLI_StrCmp(ostart, astart) != 0) { @@ -1455,8 +1478,8 @@ // make a copy of the args which will be expanded in java if required. nargv = (char **)JLI_MemAlloc(argc * sizeof(char*)); for (i = 0, j = idx; i < argc; i++, j++) { - jboolean arg_expand = (JLI_StrCmp(stdargs[j].arg, strv[i]) == 0) - ? stdargs[j].has_wildcard + jboolean arg_expand = (JLI_StrCmp(filteredargs[j].arg, strv[i]) == 0) + ? filteredargs[j].has_wildcard : JNI_FALSE; if (needs_expansion == JNI_FALSE) needs_expansion = arg_expand; @@ -1493,5 +1516,6 @@ JLI_MemFree(nargv[i]); } JLI_MemFree(nargv); + JLI_MemFree(filteredargs); return outArray; } diff -r e5171238515c -r ec8f5229c8e9 src/windows/classes/com/sun/java/accessibility/extensions/AccessibleExtendedRelation.java --- a/src/windows/classes/com/sun/java/accessibility/extensions/AccessibleExtendedRelation.java Fri May 29 10:15:38 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.java.accessibility.extensions; - -import javax.accessibility.*; - -/** - *

Class AccessibleExtendedRelation contains extensions to the class - * AccessibleRelation that are currently not in a public API. - * - *

Class AccessibleRelation describes a relation between the - * object that implements the AccessibleRelation and one or more other - * objects. The actual relations that an object has with other - * objects are defined as an AccessibleRelationSet, which is a composed - * set of AccessibleRelations. - *

The toDisplayString method allows you to obtain the localized string - * for a locale independent key from a predefined ResourceBundle for the - * keys defined in this class. - *

The constants in this class present a strongly typed enumeration - * of common object roles. If the constants in this class are not sufficient - * to describe the role of an object, a subclass should be generated - * from this class and it should provide constants in a similar manner. - * - */ - -public class AccessibleExtendedRelation - extends AccessibleExtendedRelationConstants { - - public AccessibleExtendedRelation(String s) { - super(s); - } - - public AccessibleExtendedRelation(String key, Object target) { - super(key, target); - } -} diff -r e5171238515c -r ec8f5229c8e9 src/windows/classes/com/sun/java/accessibility/extensions/AccessibleExtendedRelationConstants.java --- a/src/windows/classes/com/sun/java/accessibility/extensions/AccessibleExtendedRelationConstants.java Fri May 29 10:15:38 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.java.accessibility.extensions; - -import javax.accessibility.*; - -/** - *

Class AccessibleExtendedRelation contains extensions to the class - * AccessibleRelation that are currently not in a public API. - * - *

Class AccessibleRelation describes a relation between the - * object that implements the AccessibleRelation and one or more other - * objects. The actual relations that an object has with other - * objects are defined as an AccessibleRelationSet, which is a composed - * set of AccessibleRelations. - *

The toDisplayString method allows you to obtain the localized string - * for a locale independent key from a predefined ResourceBundle for the - * keys defined in this class. - *

The constants in this class present a strongly typed enumeration - * of common object roles. If the constants in this class are not sufficient - * to describe the role of an object, a subclass should be generated - * from this class and it should provide constants in a similar manner. - * - */ - -public abstract class AccessibleExtendedRelationConstants - extends AccessibleRelation { - - /** - * Indicates that one AccessibleText object is linked to the - * target AccessibleText object(s).

A good example is a StarOffice - * text window with the bottom of one page, a footer, a header, - * and the top of another page all visible in the window. There - * should be a FLOWS_TO relation from the last chunk of AccessibleText - * in the bottom of one page to the first AccessibleText object at the - * top of the next page, skipping over the AccessibleText object(s) - * that make up the header and footer. A corresponding FLOWS_FROM - * relation would link the AccessibleText object in the next page to - * the last one in the previous page. - * @see AccessibleExtendedRole.FLOWS_FROM - */ - public static final String FLOWS_TO = "flowsTo"; - - /** - * Indicates that one AccessibleText object is linked to the - * target AccessibleText object(s). - * @see AccessibleExtendedRole.FLOWS_TO - */ - public static final String FLOWS_FROM = "flowsFrom"; - - /** - * Indicates a component is a subwindow of a target component - */ - public static final String SUBWINDOW_OF = "subwindowOf"; - - /** - * Identifies that the linkage between one AccessibleText - * object and the target AccessibleText object(s) has changed. - * @see AccessibleExtendedRole.FLOWS_TO - * @see AccessibleExtendedRole.FLOWS_FROM - */ - public static final String FLOWS_TO_PROPERTY = "flowsToProperty"; - - /** - * Identifies that the linkage between one AccessibleText - * object and the target AccessibleText object(s) has changed. - * @see AccessibleExtendedRole.FLOWS_TO - * @see AccessibleExtendedRole.FLOWS_FROM - */ - public static final String FLOWS_FROM_PROPERTY = "flowsFromProperty"; - - /** - * Identifies the subwindow relationship between two components - * has changed - */ - public static final String SUBWINDOW_OF_PROPERTY = "subwindowOfProperty"; - - public AccessibleExtendedRelationConstants(String s) { - super(s); - } - - public AccessibleExtendedRelationConstants(String key, Object target) { - super(key, target); - } -} diff -r e5171238515c -r ec8f5229c8e9 src/windows/classes/com/sun/java/accessibility/extensions/AccessibleExtendedRole.java --- a/src/windows/classes/com/sun/java/accessibility/extensions/AccessibleExtendedRole.java Fri May 29 10:15:38 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.java.accessibility.extensions; - -import javax.accessibility.*; - -/** - *

Class AccessibleExtendedRole contains extensions to the class - * AccessibleRole that are currently not in a public API. - * - *

Class AccessibleRole determines the role of a component. The role - * of a component describes its generic function. (E.G., - * "push button," "table," or "list.") - *

The constants in this class present a strongly typed enumeration - * of common object roles. A public constructor for this class has been - * purposely omitted and applications should use one of the constants - * from this class. If the constants in this class are not sufficient - * to describe the role of an object, a subclass should be generated - * from this class and it should provide constants in a similar manner. - * - */ - -public class AccessibleExtendedRole extends AccessibleExtendedRoleConstants { - - public AccessibleExtendedRole(String s) { - super(s); - } -} diff -r e5171238515c -r ec8f5229c8e9 src/windows/classes/com/sun/java/accessibility/extensions/AccessibleExtendedRoleConstants.java --- a/src/windows/classes/com/sun/java/accessibility/extensions/AccessibleExtendedRoleConstants.java Fri May 29 10:15:38 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.java.accessibility.extensions; - -import javax.accessibility.*; - -/** - *

Class AccessibleExtendedRole contains extensions to the class - * AccessibleRole that are currently not in a public API. - * - *

Class AccessibleRole determines the role of a component. The role - * of a component describes its generic function. (E.G., - * "push button," "table," or "list.") - *

The constants in this class present a strongly typed enumeration - * of common object roles. A public constructor for this class has been - * purposely omitted and applications should use one of the constants - * from this class. If the constants in this class are not sufficient - * to describe the role of an object, a subclass should be generated - * from this class and it should provide constants in a similar manner. - * - */ - -public abstract class AccessibleExtendedRoleConstants extends AccessibleRole { - - /** - * Indicates this component is a text header. - */ - public static final AccessibleExtendedRole HEADER - = new AccessibleExtendedRole("Header"); - - /** - * Indicates this component is a text footer. - */ - public static final AccessibleExtendedRole FOOTER - = new AccessibleExtendedRole("Footer"); - - /** - * Indicates this component is a text paragraph. - */ - public static final AccessibleExtendedRole PARAGRAPH - = new AccessibleExtendedRole("Paragraph"); - - /** - * Indicates this component is a ruler. - */ - public static final AccessibleExtendedRole RULER - = new AccessibleExtendedRole("RULER"); - - public AccessibleExtendedRoleConstants(String s) { - super(s); - } -} diff -r e5171238515c -r ec8f5229c8e9 src/windows/classes/com/sun/java/accessibility/extensions/AccessibleExtendedState.java --- a/src/windows/classes/com/sun/java/accessibility/extensions/AccessibleExtendedState.java Fri May 29 10:15:38 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.sun.java.accessibility.extensions; - -import javax.accessibility.*; - -/** - *

Class AccessibleState describes a component's particular state. The actual - * state of the component is defined as an AccessibleStateSet, which is a - * composed set of AccessibleStates. - *

The toDisplayString method allows you to obtain the localized string - * for a locale independent key from a predefined ResourceBundle for the - * keys defined in this class. - *

The constants in this class present a strongly typed enumeration - * of common object roles. A public constructor for this class has been - * purposely omitted and applications should use one of the constants - * from this class. If the constants in this class are not sufficient - * to describe the role of an object, a subclass should be generated - * from this class and it should provide constants in a similar manner. - * - */ - -public abstract class AccessibleExtendedState - extends AccessibleExtendedStateConstants { - - public AccessibleExtendedState(String s) { - super(s); - } -} diff -r e5171238515c -r ec8f5229c8e9 src/windows/classes/com/sun/java/accessibility/extensions/AccessibleExtendedStateConstants.java --- a/src/windows/classes/com/sun/java/accessibility/extensions/AccessibleExtendedStateConstants.java Fri May 29 10:15:38 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.sun.java.accessibility.extensions; - -import javax.accessibility.*; - -/** - *

Class AccessibleState describes a component's particular state. The actual - * state of the component is defined as an AccessibleStateSet, which is a - * composed set of AccessibleStates. - *

The toDisplayString method allows you to obtain the localized string - * for a locale independent key from a predefined ResourceBundle for the - * keys defined in this class. - *

The constants in this class present a strongly typed enumeration - * of common object roles. A public constructor for this class has been - * purposely omitted and applications should use one of the constants - * from this class. If the constants in this class are not sufficient - * to describe the role of an object, a subclass should be generated - * from this class and it should provide constants in a similar manner. - * - */ - -public abstract class AccessibleExtendedStateConstants extends AccessibleState { - - /** - * Indicates a component is responsible for managing - * its subcomponents. - */ - public static final AccessibleExtendedState MANAGES_DESCENDENTS - = new AccessibleExtendedState("managesDescendents"); - - public AccessibleExtendedStateConstants(String s) { - super(s); - } -} diff -r e5171238515c -r ec8f5229c8e9 src/windows/classes/com/sun/java/accessibility/util/AWTEventMonitor.java --- a/src/windows/classes/com/sun/java/accessibility/util/AWTEventMonitor.java Fri May 29 10:15:38 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1495 +0,0 @@ -/* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.java.accessibility.util; - -import java.util.*; -import java.awt.*; -import java.awt.event.*; -import javax.accessibility.*; -import javax.swing.*; -import javax.swing.event.*; -import sun.security.util.SecurityConstants.AWT; - -/** - *

The {@code AWTEventMonitor} implements a suite of listeners that are - * conditionally installed on every AWT component instance in the Java - * Virtual Machine. The events captured by these listeners are made - * available through a unified set of listeners supported by {@code AWTEventMonitor}. - * With this, all the individual events on each of the AWT component - * instances are funneled into one set of listeners broken down by category - * (see {@link EventID} for the categories). - *

This class depends upon {@link EventQueueMonitor}, which provides the base - * level support for capturing the top-level containers as they are created. - */ - -@jdk.Exported -public class AWTEventMonitor { - - static private boolean runningOnJDK1_4 = false; - - /** - * The current component with keyboard focus. - * - * @see #getComponentWithFocus - * - * @deprecated This field is unused; to get the component with focus use the - * getComponentWithFocus method. - */ - @Deprecated - static protected Component componentWithFocus = null; - - static private Component componentWithFocus_private = null; - - // Low-level listeners - /** - * The current list of registered ComponentListener classes. - * - * @see #addComponentListener - * @see #removeComponentListener - * - * @deprecated This field is unused. - */ - @Deprecated - static protected ComponentListener componentListener = null; - - static private ComponentListener componentListener_private = null; - - /** - * The current list of registered ContainerListener classes. - * - * @see #addContainerListener - * @see #removeContainerListener - * - * @deprecated This field is unused. - */ - @Deprecated - static protected ContainerListener containerListener = null; - - static private ContainerListener containerListener_private = null; - - /** - * The current list of registered FocusListener classes. - * - * @see #addFocusListener - * @see #removeFocusListener - * - * @deprecated This field is unused. - */ - @Deprecated - static protected FocusListener focusListener = null; - - static private FocusListener focusListener_private = null; - - /** - * The current list of registered KeyListener classes. - * - * @see #addKeyListener - * @see #removeKeyListener - * - * @deprecated This field is unused. - */ - @Deprecated - static protected KeyListener keyListener = null; - - static private KeyListener keyListener_private = null; - - /** - * The current list of registered MouseListener classes. - * - * @see #addMouseListener - * @see #removeMouseListener - * - * @deprecated This field is unused. - */ - @Deprecated - static protected MouseListener mouseListener = null; - - static private MouseListener mouseListener_private = null; - - /** - * The current list of registered MouseMotionListener classes. - * - * @see #addMouseMotionListener - * @see #removeMouseMotionListener - * - * @deprecated This field is unused. - */ - @Deprecated - static protected MouseMotionListener mouseMotionListener = null; - - static private MouseMotionListener mouseMotionListener_private = null; - - /** - * The current list of registered WindowListener classes. - * - * @see #addWindowListener - * @see #removeWindowListener - * - * @deprecated This field is unused. - */ - @Deprecated - static protected WindowListener windowListener = null; - - static private WindowListener windowListener_private = null; - - - // Semantic listeners - /** - * The current list of registered ActionListener classes. - * - * @see #addActionListener - * @see #removeActionListener - * - * @deprecated This field is unused. - */ - @Deprecated - static protected ActionListener actionListener = null; - - static private ActionListener actionListener_private = null; - - /** - * The current list of registered AdjustmentListener classes. - * - * @see #addAdjustmentListener - * @see #removeAdjustmentListener - * - * @deprecated This field is unused. - */ - @Deprecated - static protected AdjustmentListener adjustmentListener = null; - - static private AdjustmentListener adjustmentListener_private = null; - - /** - * The current list of registered ItemListener classes. - * - * @see #addItemListener - * @see #removeItemListener - * - * @deprecated This field is unused. - */ - @Deprecated - static protected ItemListener itemListener = null; - - static private ItemListener itemListener_private = null; - - /** - * The current list of registered TextListener classes. - * - * @see #addTextListener - * @see #removeTextListener - * - * @deprecated This field is unused. - */ - @Deprecated - static protected TextListener textListener = null; - - static private TextListener textListener_private = null; - - - /** - * The actual listener that is installed on the component instances. - * This listener calls the other registered listeners when an event - * occurs. By doing things this way, the actual number of listeners - * installed on a component instance is drastically reduced. - * - * @deprecated This field is unused. - */ - @Deprecated - static protected AWTEventsListener awtListener = new AWTEventsListener(); - - static private final AWTEventsListener awtListener_private = new AWTEventsListener(); - - /** - * Returns the component that currently has keyboard focus. The return - * value can be null. - * - * @return the component that has keyboard focus - */ - static public Component getComponentWithFocus() { - return componentWithFocus_private; - } - - /* - * Check permissions - */ - static private void checkInstallPermission() { - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkPermission(AWT.ALL_AWT_EVENTS_PERMISSION); - } - } - - /** - * Adds the specified listener to receive all {@link EventID#COMPONENT COMPONENT} - * events on each component instance in the Java Virtual Machine as they occur. - *

Note: this listener is automatically added to all component - * instances created after this method is called. In addition, it - * is only added to component instances that support this listener type. - * - * @param l the listener to add - * @see #removeComponentListener - */ - static public void addComponentListener(ComponentListener l) { - if (componentListener_private == null) { - checkInstallPermission(); - awtListener_private.installListeners(EventID.COMPONENT); - } - componentListener_private = AWTEventMulticaster.add(componentListener_private, l); - } - - /** - * Removes the specified listener so it no longer receives - * {@link EventID#COMPONENT COMPONENT} events when they occur. - * - * @param l the listener to remove - * @see #addComponentListener - */ - static public void removeComponentListener(ComponentListener l) { - componentListener_private = AWTEventMulticaster.remove(componentListener_private, l); - if (componentListener_private == null) { - awtListener_private.removeListeners(EventID.COMPONENT); - } - } - - /** - * Adds the specified listener to receive all {@link EventID#CONTAINER CONTAINER} - * events on each component instance in the Java Virtual Machine as they occur. - *

Note: this listener is automatically added to all component - * instances created after this method is called. In addition, it - * is only added to component instances that support this listener type. - * - * @param l the listener to add - * @see #removeContainerListener - */ - static public void addContainerListener(ContainerListener l) { - containerListener_private = AWTEventMulticaster.add(containerListener_private, l); - } - - /** - * Removes the specified listener so it no longer receives - * {@link EventID#CONTAINER CONTAINER} events when they occur. - * - * @param l the listener to remove - * @see #addContainerListener - */ - static public void removeContainerListener(ContainerListener l) { - containerListener_private = AWTEventMulticaster.remove(containerListener_private, l); - } - - /** - * Adds the specified listener to receive all {@link EventID#FOCUS FOCUS} events - * on each component instance in the Java Virtual Machine when they occur. - *

Note: this listener is automatically added to all component - * instances created after this method is called. In addition, it - * is only added to component instances that support this listener type. - * - * @param l the listener to add - * @see #removeFocusListener - */ - static public void addFocusListener(FocusListener l) { - focusListener_private = AWTEventMulticaster.add(focusListener_private, l); - } - - /** - * Removes the specified listener so it no longer receives {@link EventID#FOCUS FOCUS} - * events when they occur. - * - * @param l the listener to remove - * @see #addFocusListener - */ - static public void removeFocusListener(FocusListener l) { - focusListener_private = AWTEventMulticaster.remove(focusListener_private, l); - } - - /** - * Adds the specified listener to receive all {@link EventID#KEY KEY} events on each - * component instance in the Java Virtual Machine when they occur. - *

Note: this listener is automatically added to all component - * instances created after this method is called. In addition, it - * is only added to component instances that support this listener type. - * - * @param l the listener to add - * @see #removeKeyListener - */ - static public void addKeyListener(KeyListener l) { - if (keyListener_private == null) { - checkInstallPermission(); - awtListener_private.installListeners(EventID.KEY); - } - keyListener_private = AWTEventMulticaster.add(keyListener_private, l); - } - - /** - * Removes the specified listener so it no longer receives {@link EventID#KEY KEY} - * events when they occur. - * - * @param l the listener to remove - * @see #addKeyListener - */ - static public void removeKeyListener(KeyListener l) { - keyListener_private = AWTEventMulticaster.remove(keyListener_private, l); - if (keyListener_private == null) { - awtListener_private.removeListeners(EventID.KEY); - } - } - - /** - * Adds the specified listener to receive all {@link EventID#MOUSE MOUSE} events - * on each component instance in the Java Virtual Machine when they occur. - *

Note: this listener is automatically added to all component - * instances created after this method is called. In addition, it - * is only added to component instances that support this listener type. - * - * @param l the listener to add - * @see #removeMouseListener - */ - static public void addMouseListener(MouseListener l) { - if (mouseListener_private == null) { - checkInstallPermission(); - awtListener_private.installListeners(EventID.MOUSE); - } - mouseListener_private = AWTEventMulticaster.add(mouseListener_private, l); - } - - /** - * Removes the specified listener so it no longer receives - * {@link EventID#MOUSE MOUSE} events when they occur. - * - * @param l the listener to remove - * @see #addMouseListener - */ - static public void removeMouseListener(MouseListener l) { - mouseListener_private = AWTEventMulticaster.remove(mouseListener_private, l); - if (mouseListener_private == null) { - awtListener_private.removeListeners(EventID.MOUSE); - } - } - - /** - * Adds the specified listener to receive all mouse {@link EventID#MOTION MOTION} - * events on each component instance in the Java Virtual Machine when they occur. - *

Note: this listener is automatically added to all component - * instances created after this method is called. In addition, it - * is only added to component instances that support this listener type. - * - * @param l the listener to add - * @see #removeMouseMotionListener - */ - static public void addMouseMotionListener(MouseMotionListener l) { - if (mouseMotionListener_private == null) { - checkInstallPermission(); - awtListener_private.installListeners(EventID.MOTION); - } - mouseMotionListener_private = AWTEventMulticaster.add(mouseMotionListener_private, l); - } - - /** - * Removes the specified listener so it no longer receives - * {@link EventID#MOTION MOTION} events when they occur. - * - * @param l the listener to remove - * @see #addMouseMotionListener - */ - static public void removeMouseMotionListener(MouseMotionListener l) { - mouseMotionListener_private = AWTEventMulticaster.remove(mouseMotionListener_private, l); - if (mouseMotionListener_private == null) { - awtListener_private.removeListeners(EventID.MOTION); - } - } - - /** - * Adds the specified listener to receive all {@link EventID#WINDOW WINDOW} - * events on each component instance in the Java Virtual Machine when they occur. - *

Note: this listener is automatically added to all component - * instances created after this method is called. In addition, it - * is only added to component instances that support this listener type. - * - * @param l the listener to add - * @see #removeWindowListener - */ - static public void addWindowListener(WindowListener l) { - if (windowListener_private == null) { - checkInstallPermission(); - awtListener_private.installListeners(EventID.WINDOW); - } - windowListener_private = AWTEventMulticaster.add(windowListener_private, l); - } - - /** - * Removes the specified listener so it no longer receives - * {@link EventID#WINDOW WINDOW} events when they occur. - * - * @param l the listener to remove - * @see #addWindowListener - */ - static public void removeWindowListener(WindowListener l) { - windowListener_private = AWTEventMulticaster.remove(windowListener_private, l); - if (windowListener_private == null) { - awtListener_private.removeListeners(EventID.WINDOW); - } - } - - /** - * Adds the specified listener to receive all {@link EventID#ACTION ACTION} - * events on each component instance in the Java Virtual Machine when they occur. - *

Note: This listener is automatically added to all component - * instances created after this method is called. In addition, it - * is only added to component instances that support this listener type. - * - * @param l the listener to add - * @see #removeActionListener - */ - static public void addActionListener(ActionListener l) { - if (actionListener_private == null) { - checkInstallPermission(); - awtListener_private.installListeners(EventID.ACTION); - } - actionListener_private = AWTEventMulticaster.add(actionListener_private, l); - } - - /** - * Removes the specified listener so it no longer receives - * {@link EventID#ACTION ACTION} events when they occur. - * - * @param l the listener to remove - * @see #addActionListener - */ - static public void removeActionListener(ActionListener l) { - actionListener_private = AWTEventMulticaster.remove(actionListener_private, l); - if (actionListener_private == null) { - awtListener_private.removeListeners(EventID.ACTION); - } - } - - /** - * Adds the specified listener to receive all - * {@link EventID#ADJUSTMENT ADJUSTMENT} events on each component instance - * in the Java Virtual Machine when they occur. - *

Note: this listener is automatically added to all component - * instances created after this method is called. In addition, it - * is only added to component instances that support this listener type. - * - * @param l the listener to add - * @see #removeAdjustmentListener - */ - static public void addAdjustmentListener(AdjustmentListener l) { - if (adjustmentListener_private == null) { - checkInstallPermission(); - awtListener_private.installListeners(EventID.ADJUSTMENT); - } - adjustmentListener_private = AWTEventMulticaster.add(adjustmentListener_private, l); - } - - /** - * Removes the specified listener so it no longer receives - * {@link EventID#ADJUSTMENT ADJUSTMENT} events when they occur. - * - * @param l the listener to remove - * @see #addAdjustmentListener - */ - static public void removeAdjustmentListener(AdjustmentListener l) { - adjustmentListener_private = AWTEventMulticaster.remove(adjustmentListener_private, l); - if (adjustmentListener_private == null) { - awtListener_private.removeListeners(EventID.ADJUSTMENT); - } - } - - /** - * Adds the specified listener to receive all {@link EventID#ITEM ITEM} events - * on each component instance in the Java Virtual Machine when they occur. - *

Note: this listener is automatically added to all component - * instances created after this method is called. In addition, it - * is only added to component instances that support this listener type. - * - * @param l the listener to add - * @see #removeItemListener - */ - static public void addItemListener(ItemListener l) { - if (itemListener_private == null) { - checkInstallPermission(); - awtListener_private.installListeners(EventID.ITEM); - } - itemListener_private = AWTEventMulticaster.add(itemListener_private, l); - } - - /** - * Removes the specified listener so it no longer receives {@link EventID#ITEM ITEM} - * events when they occur. - * - * @param l the listener to remove - * @see #addItemListener - */ - static public void removeItemListener(ItemListener l) { - itemListener_private = AWTEventMulticaster.remove(itemListener_private, l); - if (itemListener_private == null) { - awtListener_private.removeListeners(EventID.ITEM); - } - } - - /** - * Adds the specified listener to receive all {@link EventID#TEXT TEXT} events - * on each component instance in the Java Virtual Machine when they occur. - *

Note: this listener is automatically added to all component - * instances created after this method is called. In addition, it - * is only added to component instances that support this listener type. - * - * @param l the listener to add - * @see #removeTextListener - */ - static public void addTextListener(TextListener l) { - if (textListener_private == null) { - checkInstallPermission(); - awtListener_private.installListeners(EventID.TEXT); - } - textListener_private = AWTEventMulticaster.add(textListener_private, l); - } - - /** - * Removes the specified listener so it no longer receives {@link EventID#TEXT TEXT} - * events when they occur. - * - * @param l the listener to remove - * @see #addTextListener - */ - static public void removeTextListener(TextListener l) { - textListener_private = AWTEventMulticaster.remove(textListener_private, l); - if (textListener_private == null) { - awtListener_private.removeListeners(EventID.TEXT); - } - } - - - /** - * AWTEventsListener is the class that does all the work for AWTEventMonitor. - * It is not intended for use by any other class except AWTEventMonitor. - * - */ - - static class AWTEventsListener implements TopLevelWindowListener, - ActionListener, AdjustmentListener, ComponentListener, - ContainerListener, FocusListener, ItemListener, KeyListener, - MouseListener, MouseMotionListener, TextListener, WindowListener, - ChangeListener { - - /** - * internal variables for Action introspection - */ - private java.lang.Class actionListeners[]; - private java.lang.reflect.Method removeActionMethod; - private java.lang.reflect.Method addActionMethod; - private java.lang.Object actionArgs[]; - - /** - * internal variables for Item introspection - */ - private java.lang.Class itemListeners[]; - private java.lang.reflect.Method removeItemMethod; - private java.lang.reflect.Method addItemMethod; - private java.lang.Object itemArgs[]; - - /** - * internal variables for Text introspection - */ - private java.lang.Class textListeners[]; - private java.lang.reflect.Method removeTextMethod; - private java.lang.reflect.Method addTextMethod; - private java.lang.Object textArgs[]; - - /** - * internal variables for Window introspection - */ - private java.lang.Class windowListeners[]; - private java.lang.reflect.Method removeWindowMethod; - private java.lang.reflect.Method addWindowMethod; - private java.lang.Object windowArgs[]; - - /** - * Create a new instance of this class and install it on each component - * instance in the virtual machine that supports any of the currently - * registered listeners in AWTEventMonitor. Also registers itself - * as a TopLevelWindowListener with EventQueueMonitor so it can - * automatically add new listeners to new components. - * - * @see EventQueueMonitor - * @see AWTEventMonitor - */ - public AWTEventsListener() { - String version = System.getProperty("java.version"); - if (version != null) { - runningOnJDK1_4 = (version.compareTo("1.4") >= 0); - } - initializeIntrospection(); - installListeners(); - if (runningOnJDK1_4) { - MenuSelectionManager.defaultManager().addChangeListener(this); - } - EventQueueMonitor.addTopLevelWindowListener(this); - } - - /** - * Set up all of the variables needed for introspection - */ - private boolean initializeIntrospection() { - try { - actionListeners = new java.lang.Class[1]; - actionArgs = new java.lang.Object[1]; - actionListeners[0] = Class.forName("java.awt.event.ActionListener"); - actionArgs[0] = this; - - itemListeners = new java.lang.Class[1]; - itemArgs = new java.lang.Object[1]; - itemListeners[0] = Class.forName("java.awt.event.ItemListener"); - itemArgs[0] = this; - - textListeners = new java.lang.Class[1]; - textArgs = new java.lang.Object[1]; - textListeners[0] = Class.forName("java.awt.event.TextListener"); - textArgs[0] = this; - - windowListeners = new java.lang.Class[1]; - windowArgs = new java.lang.Object[1]; - windowListeners[0] = Class.forName("java.awt.event.WindowListener"); - windowArgs[0] = this; - - return true; - } catch (ClassNotFoundException e) { - System.out.println("EXCEPTION - Class 'java.awt.event.*' not in CLASSPATH"); - return false; - } - } - - /** - * Installs all currently registered listeners on all components based - * upon the current topLevelWindows cached by EventQueueMonitor. - * @see EventQueueMonitor - * @see AWTEventMonitor - */ - protected void installListeners() { - Window topLevelWindows[] = EventQueueMonitor.getTopLevelWindows(); - if (topLevelWindows != null) { - for (int i = 0; i < topLevelWindows.length; i++) { - installListeners(topLevelWindows[i]); - } - } - } - - /** - * Installs listeners for the given event ID on all components based - * upon the current topLevelWindows cached by EventQueueMonitor. - * @see EventID - * @param eventID the event ID - */ - protected void installListeners(int eventID) { - Window topLevelWindows[] = EventQueueMonitor.getTopLevelWindows(); - if (topLevelWindows != null) { - for (int i = 0; i < topLevelWindows.length; i++) { - installListeners(topLevelWindows[i], eventID); - } - } - } - - /** - * Installs all currently registered listeners to just the component. - * @param c the component to add listeners to - */ - protected void installListeners(Component c) { - - // Container and focus listeners are always installed for our own use. - // - installListeners(c,EventID.CONTAINER); - installListeners(c,EventID.FOCUS); - - // conditionally install low-level listeners - // - if (AWTEventMonitor.componentListener_private != null) { - installListeners(c,EventID.COMPONENT); - } - if (AWTEventMonitor.keyListener_private != null) { - installListeners(c,EventID.KEY); - } - if (AWTEventMonitor.mouseListener_private != null) { - installListeners(c,EventID.MOUSE); - } - if (AWTEventMonitor.mouseMotionListener_private != null) { - installListeners(c,EventID.MOTION); - } - if (AWTEventMonitor.windowListener_private != null) { - installListeners(c,EventID.WINDOW); - } - - // conditionally install Semantic listeners - // - if (AWTEventMonitor.actionListener_private != null) { - installListeners(c,EventID.ACTION); - } - if (AWTEventMonitor.adjustmentListener_private != null) { - installListeners(c,EventID.ADJUSTMENT); - } - if (AWTEventMonitor.itemListener_private != null) { - installListeners(c,EventID.ITEM); - } - if (AWTEventMonitor.textListener_private != null) { - installListeners(c,EventID.TEXT); - } - } - - public void stateChanged(ChangeEvent e) { - processFocusGained(); - } - - private void processFocusGained() { - Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); - if (focusOwner == null) { - return; - } - MenuSelectionManager.defaultManager().removeChangeListener(this); - MenuSelectionManager.defaultManager().addChangeListener(this); - - // Only menus and popup selections are handled by the JRootPane. - if (focusOwner instanceof JRootPane) { - MenuElement [] path = - MenuSelectionManager.defaultManager().getSelectedPath(); - if (path.length > 1) { - Component penult = path[path.length-2].getComponent(); - Component last = path[path.length-1].getComponent(); - - if (last instanceof JPopupMenu || - last instanceof JMenu) { - // This is a popup with nothing in the popup - // selected. The menu itself is selected. - componentWithFocus_private = last; - } else if (penult instanceof JPopupMenu) { - // This is a popup with an item selected - componentWithFocus_private = penult; - } - } - } else { - // The focus owner has the selection. - componentWithFocus_private = focusOwner; - } - } - - /** - * Installs the given listener on the component and any of its children. - * As a precaution, it always attempts to remove itself as a listener - * first so it's always guaranteed to have installed itself just once. - * @param c the component to add listeners to - * @param eventID the eventID to add listeners for - * @see EventID - */ - protected void installListeners(Component c, int eventID) { - - // install the appropriate listener hook into this component - // - switch (eventID) { - - case EventID.ACTION: - try { - removeActionMethod = c.getClass().getMethod( - "removeActionListener", actionListeners); - addActionMethod = c.getClass().getMethod( - "addActionListener", actionListeners); - try { - removeActionMethod.invoke(c, actionArgs); - addActionMethod.invoke(c, actionArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - case EventID.ADJUSTMENT: - if (c instanceof Adjustable) { - ((Adjustable) c).removeAdjustmentListener(this); - ((Adjustable) c).addAdjustmentListener(this); - } - break; - - case EventID.COMPONENT: - c.removeComponentListener(this); - c.addComponentListener(this); - break; - - case EventID.CONTAINER: - if (c instanceof Container) { - ((Container) c).removeContainerListener(this); - ((Container) c).addContainerListener(this); - } - break; - - case EventID.FOCUS: - c.removeFocusListener(this); - c.addFocusListener(this); - - if (runningOnJDK1_4) { - processFocusGained(); - - } else { // not runningOnJDK1_4 - if ((c != componentWithFocus_private) && c.hasFocus()) { - componentWithFocus_private = c; - } - } - break; - - case EventID.ITEM: - try { - removeItemMethod = c.getClass().getMethod( - "removeItemListener", itemListeners); - addItemMethod = c.getClass().getMethod( - "addItemListener", itemListeners); - try { - removeItemMethod.invoke(c, itemArgs); - addItemMethod.invoke(c, itemArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - // [PK] CheckboxMenuItem isn't a component but it does - // implement Interface ItemSelectable!! - // if (c instanceof CheckboxMenuItem) { - // ((CheckboxMenuItem) c).removeItemListener(this); - // ((CheckboxMenuItem) c).addItemListener(this); - break; - - case EventID.KEY: - c.removeKeyListener(this); - c.addKeyListener(this); - break; - - case EventID.MOUSE: - c.removeMouseListener(this); - c.addMouseListener(this); - break; - - case EventID.MOTION: - c.removeMouseMotionListener(this); - c.addMouseMotionListener(this); - break; - - case EventID.TEXT: - try { - removeTextMethod = c.getClass().getMethod( - "removeTextListener", textListeners); - addTextMethod = c.getClass().getMethod( - "addTextListener", textListeners); - try { - removeTextMethod.invoke(c, textArgs); - addTextMethod.invoke(c, textArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - case EventID.WINDOW: - try { - removeWindowMethod = c.getClass().getMethod( - "removeWindowListener", windowListeners); - addWindowMethod = c.getClass().getMethod( - "addWindowListener", windowListeners); - try { - removeWindowMethod.invoke(c, windowArgs); - addWindowMethod.invoke(c, windowArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - // Don't bother recursing the children if this isn't going to - // accomplish anything. - // - default: - return; - } - - // if this component is a container, recurse through children - // - if (c instanceof Container) { - int count = ((Container) c).getComponentCount(); - for (int i = 0; i < count; i++) { - installListeners(((Container) c).getComponent(i), eventID); - } - } - } - - /** - * Removes all listeners for the given event ID on all components based - * upon the topLevelWindows cached by EventQueueMonitor. - * @param eventID the event ID - * @see EventID - */ - protected void removeListeners(int eventID) { - Window topLevelWindows[] = EventQueueMonitor.getTopLevelWindows(); - if (topLevelWindows != null) { - for (int i = 0; i < topLevelWindows.length; i++) { - removeListeners(topLevelWindows[i], eventID); - } - } - } - - /** - * Removes all listeners for the given component and all its children. - * @param c the component - */ - protected void removeListeners(Component c) { - - // conditionally remove low-level listeners - // - if (AWTEventMonitor.componentListener_private != null) { - removeListeners(c,EventID.COMPONENT); - } - if (AWTEventMonitor.keyListener_private != null) { - removeListeners(c,EventID.KEY); - } - if (AWTEventMonitor.mouseListener_private != null) { - removeListeners(c,EventID.MOUSE); - } - if (AWTEventMonitor.mouseMotionListener_private != null) { - removeListeners(c,EventID.MOTION); - } - if (AWTEventMonitor.windowListener_private != null) { - removeListeners(c,EventID.WINDOW); - } - - // Remove semantic listeners - // - if (AWTEventMonitor.actionListener_private != null) { - removeListeners(c,EventID.ACTION); - } - if (AWTEventMonitor.adjustmentListener_private != null) { - removeListeners(c,EventID.ADJUSTMENT); - } - if (AWTEventMonitor.itemListener_private != null) { - removeListeners(c,EventID.ITEM); - } - if (AWTEventMonitor.textListener_private != null) { - removeListeners(c,EventID.TEXT); - } - } - - /** - * Removes all listeners for the event ID from the component and all - * of its children. - * @param c the component to remove listeners from - * @see EventID - */ - protected void removeListeners(Component c, int eventID) { - - // remove the appropriate listener hook into this component - // - switch (eventID) { - - case EventID.ACTION: - try { - removeActionMethod = c.getClass().getMethod( - "removeActionListener", - actionListeners); - try { - removeActionMethod.invoke(c, actionArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - case EventID.ADJUSTMENT: - if (c instanceof Adjustable) { - ((Adjustable) c).removeAdjustmentListener(this); - } - break; - - case EventID.COMPONENT: - c.removeComponentListener(this); - break; - - // Never remove these because we're always interested in them - // for our own use. - //case EventID.CONTAINER: - // if (c instanceof Container) { - // ((Container) c).removeContainerListener(this); - // } - // break; - // - //case EventID.FOCUS: - // c.removeFocusListener(this); - // break; - - case EventID.ITEM: - try { - removeItemMethod = c.getClass().getMethod( - "removeItemListener", itemListeners); - try { - removeItemMethod.invoke(c, itemArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - // [PK] CheckboxMenuItem isn't a component but it does - // implement Interface ItemSelectable!! - // if (c instanceof CheckboxMenuItem) { - // ((CheckboxMenuItem) c).removeItemListener(this); - break; - - case EventID.KEY: - c.removeKeyListener(this); - break; - - case EventID.MOUSE: - c.removeMouseListener(this); - break; - - case EventID.MOTION: - c.removeMouseMotionListener(this); - break; - - case EventID.TEXT: - try { - removeTextMethod = c.getClass().getMethod( - "removeTextListener", textListeners); - try { - removeTextMethod.invoke(c, textArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - case EventID.WINDOW: - try { - removeWindowMethod = c.getClass().getMethod( - "removeWindowListener", windowListeners); - try { - removeWindowMethod.invoke(c, windowArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - default: - return; - } - - if (c instanceof Container) { - int count = ((Container) c).getComponentCount(); - for (int i = 0; i < count; i++) { - removeListeners(((Container) c).getComponent(i), eventID); - } - } - } - - /********************************************************************/ - /* */ - /* Listener Interface Methods */ - /* */ - /********************************************************************/ - - /* TopLevelWindow Methods ***************************************/ - - /** - * Called when top level window is created. - * @see EventQueueMonitor - * @see EventQueueMonitor#addTopLevelWindowListener - */ - public void topLevelWindowCreated(Window w) { - installListeners(w); - } - - /** - * Called when top level window is destroyed. - * @see EventQueueMonitor - * @see EventQueueMonitor#addTopLevelWindowListener - */ - public void topLevelWindowDestroyed(Window w) { - } - - /* ActionListener Methods ***************************************/ - - /** - * Called when an action is performed. - * @see AWTEventMonitor#addActionListener - */ - public void actionPerformed(ActionEvent e) { - if (AWTEventMonitor.actionListener_private != null) { - AWTEventMonitor.actionListener_private.actionPerformed(e); - } - } - - /* AdjustmentListener Methods ***********************************/ - - /** - * Called when an adjustment is made. - * @see AWTEventMonitor#addAdjustmentListener - */ - public void adjustmentValueChanged(AdjustmentEvent e) { - if (AWTEventMonitor.adjustmentListener_private != null) { - AWTEventMonitor.adjustmentListener_private.adjustmentValueChanged(e); - } - } - - /* ComponentListener Methods ************************************/ - - /** - * Called when a component is hidden. - * @see AWTEventMonitor#addComponentListener - */ - public void componentHidden(ComponentEvent e) { - if (AWTEventMonitor.componentListener_private != null) { - AWTEventMonitor.componentListener_private.componentHidden(e); - } - } - - /** - * Called when a component is moved. - * @see AWTEventMonitor#addComponentListener - */ - public void componentMoved(ComponentEvent e) { - if (AWTEventMonitor.componentListener_private != null) { - AWTEventMonitor.componentListener_private.componentMoved(e); - } - } - - /** - * Called when a component is resized. - * @see AWTEventMonitor#addComponentListener - */ - public void componentResized(ComponentEvent e) { - if (AWTEventMonitor.componentListener_private != null) { - AWTEventMonitor.componentListener_private.componentResized(e); - } - } - - /** - * Called when a component is shown. - * @see AWTEventMonitor#addComponentListener - */ - public void componentShown(ComponentEvent e) { - if (AWTEventMonitor.componentListener_private != null) { - AWTEventMonitor.componentListener_private.componentShown(e); - } - } - - /* ContainerListener Methods ************************************/ - - /** - * Called when a component is added to a container. - * @see AWTEventMonitor#addContainerListener - */ - public void componentAdded(ContainerEvent e) { - installListeners(e.getChild()); - if (AWTEventMonitor.containerListener_private != null) { - AWTEventMonitor.containerListener_private.componentAdded(e); - } - } - - /** - * Called when a component is removed from a container. - * @see AWTEventMonitor#addContainerListener - */ - public void componentRemoved(ContainerEvent e) { - removeListeners(e.getChild()); - if (AWTEventMonitor.containerListener_private != null) { - AWTEventMonitor.containerListener_private.componentRemoved(e); - } - } - - /* FocusListener Methods ****************************************/ - - /** - * Called when a component gains keyboard focus. - * @see AWTEventMonitor#addFocusListener - */ - public void focusGained(FocusEvent e) { - AWTEventMonitor.componentWithFocus_private = (Component) e.getSource(); - if (AWTEventMonitor.focusListener_private != null) { - AWTEventMonitor.focusListener_private.focusGained(e); - } - } - - /** - * Called when a component loses keyboard focus. - * @see AWTEventMonitor#addFocusListener - */ - public void focusLost(FocusEvent e) { - AWTEventMonitor.componentWithFocus_private = null; - if (AWTEventMonitor.focusListener_private != null) { - AWTEventMonitor.focusListener_private.focusLost(e); - } - } - - /* ItemListener Methods *****************************************/ - - /** - * Called when an item's state changes. - * @see AWTEventMonitor#addItemListener - */ - public void itemStateChanged(ItemEvent e) { - if (AWTEventMonitor.itemListener_private != null) { - AWTEventMonitor.itemListener_private.itemStateChanged(e); - } - } - - /* KeyListener Methods ******************************************/ - - /** - * Called when a key is pressed. - * @see AWTEventMonitor#addKeyListener - */ - public void keyPressed(KeyEvent e) { - if (AWTEventMonitor.keyListener_private != null) { - AWTEventMonitor.keyListener_private.keyPressed(e); - } - } - - /** - * Called when a key is typed. - * @see AWTEventMonitor#addKeyListener - */ - public void keyReleased(KeyEvent e) { - if (AWTEventMonitor.keyListener_private != null) { - AWTEventMonitor.keyListener_private.keyReleased(e); - } - } - - /** - * Called when a key is released. - * @see AWTEventMonitor#addKeyListener - */ - public void keyTyped(KeyEvent e) { - if (AWTEventMonitor.keyListener_private != null) { - AWTEventMonitor.keyListener_private.keyTyped(e); - } - } - - /* MouseListener Methods ****************************************/ - - /** - * Called when the mouse is clicked. - * @see AWTEventMonitor#addMouseListener - */ - public void mouseClicked(MouseEvent e) { - if (AWTEventMonitor.mouseListener_private != null) { - AWTEventMonitor.mouseListener_private.mouseClicked(e); - } - } - - /** - * Called when the mouse enters a component. - * @see AWTEventMonitor#addMouseListener - */ - public void mouseEntered(MouseEvent e) { - if (AWTEventMonitor.mouseListener_private != null) { - AWTEventMonitor.mouseListener_private.mouseEntered(e); - } - } - - /** - * Called when the mouse leaves a component. - * @see AWTEventMonitor#addMouseListener - */ - public void mouseExited(MouseEvent e) { - if (AWTEventMonitor.mouseListener_private != null) { - AWTEventMonitor.mouseListener_private.mouseExited(e); - } - } - - /** - * Called when the mouse is pressed. - * @see AWTEventMonitor#addMouseListener - */ - public void mousePressed(MouseEvent e) { - if (AWTEventMonitor.mouseListener_private != null) { - AWTEventMonitor.mouseListener_private.mousePressed(e); - } - } - - /** - * Called when the mouse is released. - * @see AWTEventMonitor#addMouseListener - */ - public void mouseReleased(MouseEvent e) { - if (AWTEventMonitor.mouseListener_private != null) { - AWTEventMonitor.mouseListener_private.mouseReleased(e); - } - } - - /* MouseMotionListener Methods **********************************/ - - /** - * Called when the mouse is dragged. - * @see AWTEventMonitor#addMouseMotionListener - */ - public void mouseDragged(MouseEvent e) { - if (AWTEventMonitor.mouseMotionListener_private != null) { - AWTEventMonitor.mouseMotionListener_private.mouseDragged(e); - } - } - - /** - * Called when the mouse is moved. - * @see AWTEventMonitor#addMouseMotionListener - */ - public void mouseMoved(MouseEvent e) { - if (AWTEventMonitor.mouseMotionListener_private != null) { - AWTEventMonitor.mouseMotionListener_private.mouseMoved(e); - } - } - - /* TextListener Methods *****************************************/ - - /** - * Called when a component's text value changed. - * @see AWTEventMonitor#addTextListener - */ - public void textValueChanged(TextEvent e) { - if (AWTEventMonitor.textListener_private != null) { - AWTEventMonitor.textListener_private.textValueChanged(e); - } - } - - /* WindowListener Methods ***************************************/ - - /** - * Called when a window is opened. - * @see AWTEventMonitor#addWindowListener - */ - public void windowOpened(WindowEvent e) { - if (AWTEventMonitor.windowListener_private != null) { - AWTEventMonitor.windowListener_private.windowOpened(e); - } - } - - /** - * Called when a window is in the process of closing. - * @see AWTEventMonitor#addWindowListener - */ - public void windowClosing(WindowEvent e) { - if (AWTEventMonitor.windowListener_private != null) { - AWTEventMonitor.windowListener_private.windowClosing(e); - } - } - - /** - * Called when a window is closed. - * @see AWTEventMonitor#addWindowListener - */ - public void windowClosed(WindowEvent e) { - if (AWTEventMonitor.windowListener_private != null) { - AWTEventMonitor.windowListener_private.windowClosed(e); - } - } - - /** - * Called when a window is iconified. - * @see AWTEventMonitor#addWindowListener - */ - public void windowIconified(WindowEvent e) { - if (AWTEventMonitor.windowListener_private != null) { - AWTEventMonitor.windowListener_private.windowIconified(e); - } - } - - /** - * Called when a window is deiconified. - * @see AWTEventMonitor#addWindowListener - */ - public void windowDeiconified(WindowEvent e) { - if (AWTEventMonitor.windowListener_private != null) { - AWTEventMonitor.windowListener_private.windowDeiconified(e); - } - } - - /** - * Called when a window is activated. - * @see AWTEventMonitor#addWindowListener - */ - public void windowActivated(WindowEvent e) { - if (AWTEventMonitor.windowListener_private != null) { - AWTEventMonitor.windowListener_private.windowActivated(e); - } - } - - /** - * Called when a window is deactivated. - * @see AWTEventMonitor#addWindowListener - */ - public void windowDeactivated(WindowEvent e) { - if (AWTEventMonitor.windowListener_private != null) { - AWTEventMonitor.windowListener_private.windowDeactivated(e); - } - } - } -} diff -r e5171238515c -r ec8f5229c8e9 src/windows/classes/com/sun/java/accessibility/util/AccessibilityEventMonitor.java --- a/src/windows/classes/com/sun/java/accessibility/util/AccessibilityEventMonitor.java Fri May 29 10:15:38 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,376 +0,0 @@ -/* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.java.accessibility.util; - -import java.util.*; -import java.beans.*; -import java.awt.*; -import java.awt.event.*; -import javax.accessibility.*; - -/** - *

{@code AccessibilityEventMonitor} implements a PropertyChange listener - * on every UI object that implements interface {@code Accessible} in the Java - * Virtual Machine. The events captured by these listeners are made available - * through listeners supported by {@code AccessibilityEventMonitor}. - * With this, all the individual events on each of the UI object - * instances are funneled into one set of PropertyChange listeners. - *

This class depends upon {@link EventQueueMonitor}, which provides the base - * level support for capturing the top-level containers as they are created. - * - */ - -@jdk.Exported -public class AccessibilityEventMonitor { - - // listeners - /** - * The current list of registered {@link java.beans.PropertyChangeListener - * PropertyChangeListener} classes. - * - * @see #addPropertyChangeListener - * @see #removePropertyChangeListener - */ - static protected final AccessibilityListenerList listenerList = - new AccessibilityListenerList(); - - - /** - * The actual listener that is installed on the component instances. - * This listener calls the other registered listeners when an event - * occurs. By doing things this way, the actual number of listeners - * installed on a component instance is drastically reduced. - */ - static protected final AccessibilityEventListener accessibilityListener = - new AccessibilityEventListener(); - - /** - * Adds the specified listener to receive all PropertyChange events on - * each UI object instance in the Java Virtual Machine as they occur. - *

Note: This listener is automatically added to all component - * instances created after this method is called. In addition, it - * is only added to UI object instances that support this listener type. - * - * @param l the listener to add - * - * @see #removePropertyChangeListener - */ - static public void addPropertyChangeListener(PropertyChangeListener l) { - if (listenerList.getListenerCount(PropertyChangeListener.class) == 0) { - accessibilityListener.installListeners(); - } - listenerList.add(PropertyChangeListener.class, l); - } - - /** - * Removes the specified listener so it no longer receives PropertyChange - * events when they occur. - * @see #addPropertyChangeListener - * @param l the listener to remove - */ - static public void removePropertyChangeListener(PropertyChangeListener l) { - listenerList.remove(PropertyChangeListener.class, l); - if (listenerList.getListenerCount(PropertyChangeListener.class) == 0) { - accessibilityListener.removeListeners(); - } - } - - - /** - * AccessibilityEventListener is the class that does all the work for - * AccessibilityEventMonitor. It is not intended for use by any other - * class except AccessibilityEventMonitor. - * - */ - - static class AccessibilityEventListener implements TopLevelWindowListener, - PropertyChangeListener { - - /** - * Create a new instance of this class and install it on each component - * instance in the virtual machine that supports any of the currently - * registered listeners in AccessibilityEventMonitor. Also registers - * itself as a TopLevelWindowListener with EventQueueMonitor so it can - * automatically add new listeners to new components. - * @see EventQueueMonitor - * @see AccessibilityEventMonitor - */ - public AccessibilityEventListener() { - EventQueueMonitor.addTopLevelWindowListener(this); - } - - /** - * Installs PropertyChange listeners on all Accessible objects based - * upon the current topLevelWindows cached by EventQueueMonitor. - * @see EventQueueMonitor - * @see AWTEventMonitor - */ - protected void installListeners() { - Window topLevelWindows[] = EventQueueMonitor.getTopLevelWindows(); - if (topLevelWindows != null) { - for (int i = 0; i < topLevelWindows.length; i++) { - if (topLevelWindows[i] instanceof Accessible) { - installListeners((Accessible) topLevelWindows[i]); - } - } - } - } - - /** - * Installs PropertyChange listeners to the Accessible object, and it's - * children (so long as the object isn't of TRANSIENT state). - * @param a the Accessible object to add listeners to - */ - protected void installListeners(Accessible a) { - installListeners(a.getAccessibleContext()); - } - - /** - * Installs PropertyChange listeners to the AccessibleContext object, - * and it's * children (so long as the object isn't of TRANSIENT state). - * @param a the Accessible object to add listeners to - */ - private void installListeners(AccessibleContext ac) { - - if (ac != null) { - AccessibleStateSet states = ac.getAccessibleStateSet(); - if (!states.contains(AccessibleState.TRANSIENT)) { - ac.addPropertyChangeListener(this); - /* - * Don't add listeners to transient children. Components - * with transient children should return an AccessibleStateSet - * containing AccessibleState.MANAGES_DESCENDANTS. Components - * may not explicitly return the MANAGES_DESCENDANTS state. - * In this case, don't add listeners to the children of - * lists, tables and trees. - */ - AccessibleStateSet set = ac.getAccessibleStateSet(); - if (set.contains(_AccessibleState.MANAGES_DESCENDANTS)) { - return; - } - AccessibleRole role = ac.getAccessibleRole(); - if (role == AccessibleRole.LIST || - role == AccessibleRole.TREE) { - return; - } - if (role == AccessibleRole.TABLE) { - // handle Oracle tables containing tables - Accessible child = ac.getAccessibleChild(0); - if (child != null) { - AccessibleContext ac2 = child.getAccessibleContext(); - if (ac2 != null) { - role = ac2.getAccessibleRole(); - if (role != null && role != AccessibleRole.TABLE) { - return; - } - } - } - } - int count = ac.getAccessibleChildrenCount(); - for (int i = 0; i < count; i++) { - Accessible child = ac.getAccessibleChild(i); - if (child != null) { - installListeners(child); - } - } - } - } - } - - /** - * Removes PropertyChange listeners on all Accessible objects based - * upon the topLevelWindows cached by EventQueueMonitor. - * @param eventID the event ID - * @see EventID - */ - protected void removeListeners() { - Window topLevelWindows[] = EventQueueMonitor.getTopLevelWindows(); - if (topLevelWindows != null) { - for (int i = 0; i < topLevelWindows.length; i++) { - if (topLevelWindows[i] instanceof Accessible) { - removeListeners((Accessible) topLevelWindows[i]); - } - } - } - } - - /** - * Removes PropertyChange listeners for the given Accessible object, - * it's children (so long as the object isn't of TRANSIENT state). - * @param a the Accessible object to remove listeners from - */ - protected void removeListeners(Accessible a) { - removeListeners(a.getAccessibleContext()); - } - - /** - * Removes PropertyChange listeners for the given AccessibleContext - * object, it's children (so long as the object isn't of TRANSIENT - * state). - * @param a the Accessible object to remove listeners from - */ - private void removeListeners(AccessibleContext ac) { - - - if (ac != null) { - // Listeners are not added to transient components. - AccessibleStateSet states = ac.getAccessibleStateSet(); - if (!states.contains(AccessibleState.TRANSIENT)) { - ac.removePropertyChangeListener(this); - /* - * Listeners are not added to transient children. Components - * with transient children should return an AccessibleStateSet - * containing AccessibleState.MANAGES_DESCENDANTS. Components - * may not explicitly return the MANAGES_DESCENDANTS state. - * In this case, don't remove listeners from the children of - * lists, tables and trees. - */ - if (states.contains(_AccessibleState.MANAGES_DESCENDANTS)) { - return; - } - AccessibleRole role = ac.getAccessibleRole(); - if (role == AccessibleRole.LIST || - role == AccessibleRole.TABLE || - role == AccessibleRole.TREE) { - return; - } - int count = ac.getAccessibleChildrenCount(); - for (int i = 0; i < count; i++) { - Accessible child = ac.getAccessibleChild(i); - if (child != null) { - removeListeners(child); - } - } - } - } - } - - /********************************************************************/ - /* */ - /* Listener Interface Methods */ - /* */ - /********************************************************************/ - - /* TopLevelWindow Methods ***************************************/ - - /** - * Called when top level window is created. - * @see EventQueueMonitor - * @see EventQueueMonitor#addTopLevelWindowListener - */ - public void topLevelWindowCreated(Window w) { - if (w instanceof Accessible) { - installListeners((Accessible) w); - } - } - - /** - * Called when top level window is destroyed. - * @see EventQueueMonitor - * @see EventQueueMonitor#addTopLevelWindowListener - */ - public void topLevelWindowDestroyed(Window w) { - if (w instanceof Accessible) { - removeListeners((Accessible) w); - } - } - - - /* PropertyChangeListener Methods **************************************/ - - public void propertyChange(PropertyChangeEvent e) { - // propogate the event - Object[] listeners = - AccessibilityEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==PropertyChangeListener.class) { - ((PropertyChangeListener)listeners[i+1]).propertyChange(e); - } - } - - // handle childbirth/death - String name = e.getPropertyName(); - if (name.compareTo(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY) == 0) { - Object oldValue = e.getOldValue(); - Object newValue = e.getNewValue(); - - if ((oldValue == null) ^ (newValue == null)) { // one null, not both - if (oldValue != null) { - // this Accessible is a child that's going away - if (oldValue instanceof Accessible) { - Accessible a = (Accessible) oldValue; - removeListeners(a.getAccessibleContext()); - } else if (oldValue instanceof AccessibleContext) { - removeListeners((AccessibleContext) oldValue); - } - } else if (newValue != null) { - // this Accessible is a child was just born - if (newValue instanceof Accessible) { - Accessible a = (Accessible) newValue; - installListeners(a.getAccessibleContext()); - } else if (newValue instanceof AccessibleContext) { - installListeners((AccessibleContext) newValue); - } - } - } else { - System.out.println("ERROR in usage of PropertyChangeEvents for: " + e.toString()); - } - } - } - } -} - -/* - * workaround for no public AccessibleState constructor - */ -class _AccessibleState extends AccessibleState { - /** - * Indicates this object is responsible for managing its - * subcomponents. This is typically used for trees and tables - * that have a large number of subcomponents and where the - * objects are created only when needed and otherwise remain virtual. - * The application should not manage the subcomponents directly. - */ - public static final _AccessibleState MANAGES_DESCENDANTS - = new _AccessibleState ("managesDescendants"); - - /** - * Creates a new AccessibleState using the given locale independent key. - * This should not be a public method. Instead, it is used to create - * the constants in this file to make it a strongly typed enumeration. - * Subclasses of this class should enforce similar policy. - *

- * The key String should be a locale independent key for the state. - * It is not intended to be used as the actual String to display - * to the user. To get the localized string, use toDisplayString. - * - * @param key the locale independent name of the state. - * @see AccessibleBundle#toDisplayString - */ - protected _AccessibleState(String key) { - super(key); - } -} diff -r e5171238515c -r ec8f5229c8e9 src/windows/classes/com/sun/java/accessibility/util/AccessibilityListenerList.java --- a/src/windows/classes/com/sun/java/accessibility/util/AccessibilityListenerList.java Fri May 29 10:15:38 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,182 +0,0 @@ -/* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.java.accessibility.util; - -import java.util.*; -import java.beans.*; -import java.awt.*; -import java.awt.event.*; -import javax.accessibility.*; - -/** - *

The {@code AccessibilityListenerList} is a copy of the Swing - * {@link javax.swing.event.EventListenerList EventListerList} class. - * - */ - -@jdk.Exported -public class AccessibilityListenerList { - /* A null array to be shared by all empty listener lists */ - private final static Object[] NULL_ARRAY = new Object[0]; - - /** - * The list of listener type, listener pairs - */ - protected transient Object[] listenerList = NULL_ARRAY; - - /** - * Passes back the event listener list as an array of listener type, listener pairs. - * Note that for performance reasons, this implementation passes back the actual - * data structure in which the listener data is stored internally. This method - * is guaranteed to pass back a non-null array, so that no null-checking - * is required in fire methods. A zero-length array of Object is returned if - * there are currently no listeners. - *

- * Absolutely no modification of the data contained in this array should be - * made. If any such manipulation is necessary, it should be done on a copy - * of the array returned rather than the array itself. - * - * @return an array of listener type, listener pairs. - */ - public Object[] getListenerList() { - return listenerList; - } - - /** - * Returns the total number of listeners for this listener list. - * - * @return the total number of listeners for this listener list. - */ - public int getListenerCount() { - return listenerList.length/2; - } - - /** - * Return the total number of listeners of the supplied type - * for this listener list. - * - * @param t the type of the listener to be counted - * @return the number of listeners found - */ - public int getListenerCount(Class t) { - int count = 0; - Object[] lList = listenerList; - for (int i = 0; i < lList.length; i+=2) { - if (t == (Class)lList[i]) - count++; - } - return count; - } - - /** - * Add the listener as a listener of the specified type. - * - * @param t the type of the listener to be added - * @param l the listener to be added - */ - public synchronized void add(Class t, EventListener l) { - if (!t.isInstance(l)) { - throw new IllegalArgumentException("Listener " + l + - " is not of type " + t); - } - if (l ==null) { - throw new IllegalArgumentException("Listener " + l + - " is null"); - } - if (listenerList == NULL_ARRAY) { - // if this is the first listener added, - // initialize the lists - listenerList = new Object[] { t, l }; - } else { - // Otherwise copy the array and add the new listener - int i = listenerList.length; - Object[] tmp = new Object[i+2]; - System.arraycopy(listenerList, 0, tmp, 0, i); - - tmp[i] = t; - tmp[i+1] = l; - - listenerList = tmp; - } - } - - /** - * Remove the listener as a listener of the specified type. - * - * @param t the type of the listener to be removed - * @param l the listener to be removed - */ - public synchronized void remove(Class t, EventListener l) { - if (!t.isInstance(l)) { - throw new IllegalArgumentException("Listener " + l + - " is not of type " + t); - } - if (l ==null) { - throw new IllegalArgumentException("Listener " + l + - " is null"); - } - - // Is l on the list? - int index = -1; - for (int i = listenerList.length-2; i>=0; i-=2) { - if ((listenerList[i]==t) && (listenerList[i+1] == l)) { - index = i; - break; - } - } - - // If so, remove it - if (index != -1) { - Object[] tmp = new Object[listenerList.length-2]; - // Copy the list up to index - System.arraycopy(listenerList, 0, tmp, 0, index); - // Copy from two past the index, up to - // the end of tmp (which is two elements - // shorter than the old list) - if (index < tmp.length) - System.arraycopy(listenerList, index+2, tmp, index, - tmp.length - index); - // set the listener array to the new array or null - listenerList = (tmp.length == 0) ? NULL_ARRAY : tmp; - } - } - - /** - * Return a string representation of the {@code AccessibilityListenerList}. - * - * @return a string representation of the {@code AccessibilityListenerList}. - */ - public String toString() { - Object[] lList = listenerList; - String s = "EventListenerList: "; - s += lList.length/2 + " listeners: "; - for (int i = 0 ; i <= lList.length-2 ; i+=2) { - s += " type " + ((Class)lList[i]).getName(); - s += " listener " + lList[i+1]; - } - return s; - } -} diff -r e5171238515c -r ec8f5229c8e9 src/windows/classes/com/sun/java/accessibility/util/EventID.java --- a/src/windows/classes/com/sun/java/accessibility/util/EventID.java Fri May 29 10:15:38 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,206 +0,0 @@ -/* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.java.accessibility.util; - -/** - * EventID contains integer constants that map to event support in - * AWT and Swing. They are used by primarily by AWTEventMonitor, - * AWTEventsListener, SwingEventMonitor, and SwingEventListener, but - * can be freely used by any other class. - * - * @see AWTEventMonitor - * @see SwingEventMonitor - * - */ -@jdk.Exported -public class EventID { - - /** - * Maps to AWT Action support (i.e., ActionListener and ActionEvent) - */ - static public final int ACTION = 0; - - /** - * Maps to AWT Adjustment support (i.e., AdjustmentListener - * and AdjustmentEvent) - */ - static public final int ADJUSTMENT = 1; - - /** - * Maps to AWT Component support (i.e., ComponentListener - * and ComponentEvent) - */ - static public final int COMPONENT = 2; - - /** - * Maps to AWT Container support (i.e., ContainerListener - * and ContainerEvent) - */ - static public final int CONTAINER = 3; - - /** - * Maps to AWT Focus support (i.e., FocusListener and FocusEvent) - */ - static public final int FOCUS = 4; - - /** - * Maps to AWT Item support (i.e., ItemListener and ItemEvent) - */ - static public final int ITEM = 5; - - /** - * Maps to AWT Key support (i.e., KeyListener and KeyEvent) - */ - static public final int KEY = 6; - - /** - * Maps to AWT Mouse support (i.e., MouseListener and MouseEvent) - */ - static public final int MOUSE = 7; - - /** - * Maps to AWT MouseMotion support (i.e., MouseMotionListener - * and MouseMotionEvent) - */ - static public final int MOTION = 8; - - /** - * Maps to AWT Text support (i.e., TextListener and TextEvent) - */ - static public final int TEXT = 10; - - /** - * Maps to AWT Window support (i.e., WindowListener and WindowEvent) - */ - static public final int WINDOW = 11; - - /** - * Maps to Swing Ancestor support (i.e., AncestorListener and - * AncestorEvent) - */ - static public final int ANCESTOR = 12; - - /** - * Maps to Swing Text Caret support (i.e., CaretListener and - * CaretEvent) - */ - static public final int CARET = 13; - - /** - * Maps to Swing CellEditor support (i.e., CellEditorListener and - * CellEditorEvent) - */ - static public final int CELLEDITOR = 14; - - /** - * Maps to Swing Change support (i.e., ChangeListener and - * ChangeEvent) - */ - static public final int CHANGE = 15; - - /** - * Maps to Swing TableColumnModel support (i.e., - * TableColumnModelListener and TableColumnModelEvent) - */ - static public final int COLUMNMODEL = 16; - - /** - * Maps to Swing Document support (i.e., DocumentListener and - * DocumentEvent) - */ - static public final int DOCUMENT = 17; - - /** - * Maps to Swing ListData support (i.e., ListDataListener and - * ListDataEvent) - */ - static public final int LISTDATA = 18; - - /** - * Maps to Swing ListSelection support (i.e., ListSelectionListener and - * ListSelectionEvent) - */ - static public final int LISTSELECTION = 19; - - /** - * Maps to Swing Menu support (i.e., MenuListener and - * MenuEvent) - */ - static public final int MENU = 20; - - /** - * Maps to Swing PopupMenu support (i.e., PopupMenuListener and - * PopupMenuEvent) - */ - static public final int POPUPMENU = 21; - - /** - * Maps to Swing TableModel support (i.e., TableModelListener and - * TableModelEvent) - */ - static public final int TABLEMODEL = 22; - - /** - * Maps to Swing TreeExpansion support (i.e., TreeExpansionListener and - * TreeExpansionEvent) - */ - static public final int TREEEXPANSION = 23; - - /** - * Maps to Swing TreeModel support (i.e., TreeModelListener and - * TreeModelEvent) - */ - static public final int TREEMODEL = 24; - - /** - * Maps to Swing TreeSelection support (i.e., TreeSelectionListener and - * TreeSelectionEvent) - */ - static public final int TREESELECTION = 25; - - /** - * Maps to Swing UndoableEdit support (i.e., UndoableEditListener and - * UndoableEditEvent) - */ - static public final int UNDOABLEEDIT = 26; - - /** - * Maps to Beans PropertyChange support (i.e., PropertyChangeListener - * and PropertyChangeEvent) - */ - static public final int PROPERTYCHANGE = 27; - - /** - * Maps to Beans VetoableChange support (i.e., VetoableChangeListener - * and VetoableChangeEvent) - */ - static public final int VETOABLECHANGE = 28; - - /** - * Maps to Swing InternalFrame support (i.e., InternalFrameListener) - */ - static public final int INTERNALFRAME = 29; -} diff -r e5171238515c -r ec8f5229c8e9 src/windows/classes/com/sun/java/accessibility/util/EventQueueMonitor.java --- a/src/windows/classes/com/sun/java/accessibility/util/EventQueueMonitor.java Fri May 29 10:15:38 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,619 +0,0 @@ -/* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.java.accessibility.util; - -import java.util.*; -import java.awt.*; -import java.awt.event.*; -import javax.accessibility.*; -import java.security.AccessController; -import java.security.PrivilegedAction; - -/** - * The {@code EventQueueMonitor} class provides key core functionality for Assistive - * Technologies (and other system-level technologies that need some of the same - * things that Assistive Technology needs). - * - * @see AWTEventMonitor - * @see SwingEventMonitor - */ -@jdk.Exported -public class EventQueueMonitor - implements AWTEventListener { - - // NOTE: All of the following properties are static. The reason - // for this is that there may be multiple EventQueue instances - // in use in the same VM. By making these properties static, - // we can guarantee we get the information from all of the - // EventQueue instances. - - // The stuff that is cached. - // - static Vector topLevelWindows = new Vector(); - static Window topLevelWindowWithFocus = null; - static Point currentMousePosition = null; - static Component currentMouseComponent = null; - - // Low-level listener interfaces - // - static GUIInitializedListener guiInitializedListener = null; - static TopLevelWindowListener topLevelWindowListener = null; - static MouseMotionListener mouseMotionListener = null; - - /** - * Class variable stating whether the assistive technologies have - * been loaded yet or not. The assistive technologies won't be - * loaded until the first event is posted to the EventQueue. This - * gives the toolkit a chance to do all the necessary initialization - * it needs to do. - */ - - /** - * Class variable stating whether the GUI subsystem has been initialized - * or not. - * - * @see #isGUIInitialized - */ - static boolean guiInitialized = false; - - /** - * Queue that holds events for later processing. - */ - static EventQueueMonitorItem componentEventQueue = null; - - /** - * Class that tells us what the component event dispatch thread is. - */ - static private ComponentEvtDispatchThread cedt = null; - - /** - * Handle the synchronization between the thing that populates the - * component event dispatch thread ({@link #queueComponentEvent}) - * and the thing that processes the events ({@link ComponentEvtDispatchThread}). - */ - static Object componentEventQueueLock = new Object(); - - /** - * Create a new {@code EventQueueMonitor} instance. Normally, this will - * be called only by the AWT Toolkit during initialization time. - * Assistive technologies should not create instances of - * EventQueueMonitor by themselves. Instead, they should either - * refer to it directly via the static methods in this class, e.g., - * {@link #getCurrentMousePosition} or obtain the instance by asking the - * Toolkit, e.g., {@link java.awt.Toolkit#getSystemEventQueue}. - */ - public EventQueueMonitor() { - if (cedt == null) { - cedt = new ComponentEvtDispatchThread("EventQueueMonitor-ComponentEvtDispatch"); - - cedt.setDaemon(true); - cedt.start(); - } - } - - /** - * Queue up a {@link java.awt.event.ComponentEvent ComponentEvent} for later - * processing by the {@link ComponentEvtDispatch} thread. - * - * @param e a {@code ComponentEvent} - */ - static void queueComponentEvent(ComponentEvent e) { - synchronized(componentEventQueueLock) { - EventQueueMonitorItem eqi = new EventQueueMonitorItem(e); - if (componentEventQueue == null) { - componentEventQueue = eqi; - } else { - EventQueueMonitorItem q = componentEventQueue; - while (true) { - if (q.next != null) { - q = q.next; - } else { - break; - } - } - q.next = eqi; - } - componentEventQueueLock.notifyAll(); - } - } - - /** - * Tell the {@code EventQueueMonitor} to start listening for events. - */ - public static void maybeInitialize() { - if (cedt == null) { - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { - try { - long eventMask = AWTEvent.WINDOW_EVENT_MASK | - AWTEvent.FOCUS_EVENT_MASK | - AWTEvent.MOUSE_MOTION_EVENT_MASK; - - Toolkit.getDefaultToolkit().addAWTEventListener(new EventQueueMonitor(), eventMask); - } catch (Exception e) { - } - return null; - } - } - ); - } - } - - /** - * Handle events as a result of registering a listener - * on the {@link java.awt.EventQueue EventQueue} in {@link #maybeInitialize}. - */ - public void eventDispatched(AWTEvent theEvent) { - processEvent(theEvent); - } - - /** - * Assisitive technologies that have - * registered a {@link GUIInitializedListener} will be notified. - * - * @see #addGUIInitializedListener - */ - static void maybeNotifyAssistiveTechnologies() { - - if (!guiInitialized) { - guiInitialized = true; - if (guiInitializedListener != null) { - guiInitializedListener.guiInitialized(); - } - } - - } - - /********************************************************************/ - /* */ - /* Package Private Methods */ - /* */ - /********************************************************************/ - - /** - * Add a Container to the list of top-level containers - * in the cache. This follows the object's hierarchy up the - * tree until it finds the top most parent. If the parent is - * not already in the list of Containers, it adds it to the list. - * - * @param c the Container - */ - static void addTopLevelWindow(Component c) { - Container parent; - - if (c == null) { - return; - } - - if (!(c instanceof Window)) { - addTopLevelWindow(c.getParent()); - return; - } - - if ((c instanceof Dialog) || (c instanceof Window)) { - parent = (Container) c; - } else { - parent = c.getParent(); - if (parent != null) { - addTopLevelWindow(parent); - return; - } - } - - if (parent == null) { - parent = (Container) c; - } - - // Because this method is static, do not make it synchronized because - // it can lock the whole class. Instead, just lock what needs to be - // locked. - // - synchronized (topLevelWindows) { - if ((parent != null) && !topLevelWindows.contains(parent)) { - topLevelWindows.addElement(parent); - if (topLevelWindowListener != null) { - topLevelWindowListener.topLevelWindowCreated((Window) parent); - } - } - } - } - - /** - * Removes a container from the list of top level containers in the cache. - * - * @param c the top level container to remove - */ - static void removeTopLevelWindow(Window w) { - - // Because this method is static, do not make it synchronized because - // it can lock the whole class. Instead, just lock what needs to be - // locked. - // - synchronized (topLevelWindows) { - if (topLevelWindows.contains(w)) { - topLevelWindows.removeElement(w); - if (topLevelWindowListener != null) { - topLevelWindowListener.topLevelWindowDestroyed(w); - } - } - } - } - - /** - * Update current mouse position. - * - * @param mouseEvent the MouseEvent that holds the new mouse position. - */ - static void updateCurrentMousePosition(MouseEvent mouseEvent) { - Point oldMousePos = currentMousePosition; - // Be careful here. The component in the event might be - // hidden by the time we process the event. - try { - Point eventPoint = mouseEvent.getPoint(); - currentMouseComponent = (Component) (mouseEvent.getSource()); - currentMousePosition = currentMouseComponent.getLocationOnScreen(); - currentMousePosition.translate(eventPoint.x,eventPoint.y); - } catch (Exception e) { - currentMousePosition = oldMousePos; - } - } - - /** - * Process the event. This maintains the event cache in addition - * to calling all the registered listeners. NOTE: The events that - * come through here are from peered Components. - * - * @param theEvent the AWTEvent - */ - static void processEvent(AWTEvent theEvent) { - switch (theEvent.getID()) { - case MouseEvent.MOUSE_MOVED: - case MouseEvent.MOUSE_DRAGGED: - case FocusEvent.FOCUS_GAINED: - case WindowEvent.WINDOW_DEACTIVATED: - queueComponentEvent((ComponentEvent) theEvent); - break; - - case WindowEvent.WINDOW_ACTIVATED: - // Dialogs fire WINDOW_ACTIVATED and FOCUS_GAINED events - // before WINDOW_OPENED so we need to add topLevelListeners - // for the dialog when it is first activated to get a - // focus gained event for the focus component in the dialog. - if (theEvent instanceof ComponentEvent) { - ComponentEvent ce = (ComponentEvent)theEvent; - if (ce.getComponent() instanceof Window) { - EventQueueMonitor.addTopLevelWindow(ce.getComponent()); - EventQueueMonitor.maybeNotifyAssistiveTechnologies(); - } else { - EventQueueMonitor.maybeNotifyAssistiveTechnologies(); - EventQueueMonitor.addTopLevelWindow(ce.getComponent()); - } - } - queueComponentEvent((ComponentEvent) theEvent); - break; - - // handle WINDOW_OPENED and WINDOW_CLOSED events synchronously - case WindowEvent.WINDOW_OPENED: - if (theEvent instanceof ComponentEvent) { - ComponentEvent ce = (ComponentEvent)theEvent; - if (ce.getComponent() instanceof Window) { - EventQueueMonitor.addTopLevelWindow(ce.getComponent()); - EventQueueMonitor.maybeNotifyAssistiveTechnologies(); - } else { - EventQueueMonitor.maybeNotifyAssistiveTechnologies(); - EventQueueMonitor.addTopLevelWindow(ce.getComponent()); - } - } - break; - case WindowEvent.WINDOW_CLOSED: - if (theEvent instanceof ComponentEvent) { - ComponentEvent ce = (ComponentEvent)theEvent; - EventQueueMonitor.removeTopLevelWindow((Window) (ce.getComponent())); - } - break; - - default: - break; - } - } - - /** - * Internal test - */ - static synchronized Component getShowingComponentAt(Container c, int x, int y) { - if (!c.contains(x, y)) { - return null; - } - int ncomponents = c.getComponentCount(); - for (int i = 0 ; i < ncomponents ; i++) { - Component comp = c.getComponent(i); - if (comp != null && comp.isShowing()) { - Point location = comp.getLocation(); - if (comp.contains(x - location.x, y - location.y)) { - return comp; - } - } - } - return c; - } - - /** - * Return the Component at the given Point on the screen in the - * given Container. - * - * @param c the Container to search - * @param p the Point in screen coordinates - * @return the Component at the given Point on the screen in the - * given Container -- can be null if no Component is at that Point - */ - static synchronized Component getComponentAt(Container c, Point p) { - if (!c.isShowing()) { - return null; - } - - Component comp; - Point containerLoc = c.getLocationOnScreen(); - Point containerPoint = new Point(p.x - containerLoc.x, - p.y - containerLoc.y); - - comp = getShowingComponentAt(c, containerPoint.x, containerPoint.y); - - if ((comp != c) && (comp instanceof Container)) { - return getComponentAt((Container)comp,p); - } else { - return comp; - } - } - - /** - * Obtain the {@link javax.accessibility.Accessible Accessible} object at the given point on the Screen. - * The return value may be null if an {@code Accessible} object cannot be - * found at the particular point. - * - * @param p the point to be accessed - * @return the {@code Accessible} at the specified point - */ - static public Accessible getAccessibleAt(Point p) { - Window w = getTopLevelWindowWithFocus(); - Window[] wins = getTopLevelWindows(); - Component c = null; - - // See if the point we're being asked about is the - // currentMousePosition. If so, start with the component - // that we know the currentMousePostion is over - // - if (currentMousePosition == null) { - return null; - } - if (currentMousePosition.equals(p)) { - if (currentMouseComponent instanceof Container) { - c = getComponentAt((Container) currentMouseComponent, p); - } - } - - // Try the window with focus next - // - if (c == null && w != null) { - c = getComponentAt(w,p); - } - - // Try the other windows next. [[[WDW: Stacking order???]]] - if (c == null) { - for (int i = 0; i < wins.length; i++) { - c = getComponentAt(wins[i],p); - if (c != null) { - break; - } - } - } - - if (c instanceof Accessible) { - AccessibleContext ac = ((Accessible) c).getAccessibleContext(); - if (ac != null) { - AccessibleComponent acmp = ac.getAccessibleComponent(); - if ((acmp != null) && (ac.getAccessibleChildrenCount() != 0)) { - Point location = acmp.getLocationOnScreen(); - location.move(p.x - location.x, p.y - location.y); - return acmp.getAccessibleAt(location); - } - } - return (Accessible) c; - } else { - return Translator.getAccessible(c); - } - } - - /********************************************************************/ - /* */ - /* Public Methods */ - /* */ - /********************************************************************/ - - /** - * Says whether the GUI subsystem has been initialized or not. - * If this returns true, the assistive technology can freely - * create GUI component instances. If the return value is false, - * the assistive technology should register a {@link GUIInitializedListener} - * and wait to create GUI component instances until the listener is - * called. - * - * @return true if the GUI subsystem has been initialized - * @see #addGUIInitializedListener - */ - static public boolean isGUIInitialized() { - maybeInitialize(); - return guiInitialized; - } - - /** - * Adds the specified listener to be notified when the GUI subsystem - * is initialized. Assistive technologies should get the results of - * {@link #isGUIInitialized} before calling this method. - * - * @param l the listener to add - * @see #isGUIInitialized - * @see #removeTopLevelWindowListener - */ - static public void addGUIInitializedListener(GUIInitializedListener l) { - maybeInitialize(); - guiInitializedListener = - GUIInitializedMulticaster.add(guiInitializedListener,l); - } - - /** - * Removes the specified listener to be notified when the GUI subsystem - * is initialized. - * - * @param l the listener to remove - * @see #addGUIInitializedListener - */ - static public void removeGUIInitializedListener(GUIInitializedListener l) { - guiInitializedListener = - GUIInitializedMulticaster.remove(guiInitializedListener,l); - } - - /** - * Adds the specified listener to be notified when a top level window - * is created or destroyed. - * - * @param l the listener to add - * @see #removeTopLevelWindowListener - */ - static public void addTopLevelWindowListener(TopLevelWindowListener l) { - topLevelWindowListener = - TopLevelWindowMulticaster.add(topLevelWindowListener,l); - } - - /** - * Removes the specified listener to be notified when a top level window - * is created or destroyed. - * - * @param l the listener to remove - * @see #addTopLevelWindowListener - */ - static public void removeTopLevelWindowListener(TopLevelWindowListener l) { - topLevelWindowListener = - TopLevelWindowMulticaster.remove(topLevelWindowListener,l); - } - - /** - * Return the last recorded position of the mouse in screen coordinates. - * - * @return the last recorded position of the mouse in screen coordinates - */ - static public Point getCurrentMousePosition() { - return currentMousePosition; - } - - /** - * Return the list of top level Windows in use in the Java Virtual Machine. - * - * @return an array of top level {@code Window}s in use in the Java Virtual Machine - */ - static public Window[] getTopLevelWindows() { - - // Because this method is static, do not make it synchronized because - // it can lock the whole class. Instead, just lock what needs to be - // locked. - // - synchronized (topLevelWindows) { - int count = topLevelWindows.size(); - if (count > 0) { - Window[] w = new Window[count]; - for (int i = 0; i < count; i++) { - w[i] = (Window)topLevelWindows.elementAt(i); - } - return w; - } else { - return new Window[0]; - } - } - } - - /** - * Return the top level {@code Window} that currently has keyboard focus. - * - * @return the top level {@code Window} that currently has keyboard focus - */ - static public Window getTopLevelWindowWithFocus() { - return topLevelWindowWithFocus; - } -} - -/** - * Handle all Component events in a separate thread. The reason for this is - * that WindowEvents tend to be used to do lots of processing on the Window - * hierarchy. As a result, it can frequently result in deadlock situations. - */ -class ComponentEvtDispatchThread extends Thread { - public ComponentEvtDispatchThread(String name) { - super(name); - } - public void run() { - ComponentEvent ce = null; - while (true) { - synchronized(EventQueueMonitor.componentEventQueueLock) { - while (EventQueueMonitor.componentEventQueue == null) { - try { - EventQueueMonitor.componentEventQueueLock.wait(); - } catch (InterruptedException e) { - } - } - ce = (ComponentEvent)EventQueueMonitor.componentEventQueue.event; - EventQueueMonitor.componentEventQueue = - EventQueueMonitor.componentEventQueue.next; - } - switch (ce.getID()) { - case MouseEvent.MOUSE_MOVED: - case MouseEvent.MOUSE_DRAGGED: - EventQueueMonitor.updateCurrentMousePosition((MouseEvent) ce); - break; - case WindowEvent.WINDOW_ACTIVATED: - EventQueueMonitor.maybeNotifyAssistiveTechnologies(); - EventQueueMonitor.topLevelWindowWithFocus = ((WindowEvent) ce).getWindow(); - break; - - default: - break; - } - } - } -} - -/** - * EventQueueMonitorItem is the basic type that handles the - * queue for queueComponentEvent and the ComponentEvtDispatchThread. - */ -class EventQueueMonitorItem { - AWTEvent event; - EventQueueMonitorItem next; - - EventQueueMonitorItem(AWTEvent evt) { - event = evt; - next = null; - } -} diff -r e5171238515c -r ec8f5229c8e9 src/windows/classes/com/sun/java/accessibility/util/GUIInitializedListener.java --- a/src/windows/classes/com/sun/java/accessibility/util/GUIInitializedListener.java Fri May 29 10:15:38 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.java.accessibility.util; - -import java.awt.*; -import java.util.*; -import javax.accessibility.*; - -/** - * The {@code GUIInitializedListener} interface is used by the {@link EventQueueMonitor} - * class to notify an interested party when the GUI subsystem has been - * initialized. This is necessary because assistive technologies can - * be loaded before the GUI subsystem is initialized. As a result, - * assistive technologies should check the - * {@link EventQueueMonitor#isGUIInitialized isGUIInitialized} method - * of {@code EventQueueMonitor} before creating any GUI components. If the - * return value is true, assistive technologies can create GUI components - * following the same thread restrictions as any other application. If - * the return value is false, the assistive technology should register - * a {@code GUIInitializedListener} with the {@code EventQueueMonitor} to be notified - * when the GUI subsystem is initialized. - * - * @see EventQueueMonitor - * @see EventQueueMonitor#isGUIInitialized - * @see EventQueueMonitor#addGUIInitializedListener - * @see EventQueueMonitor#removeGUIInitializedListener - * - */ -@jdk.Exported -public interface GUIInitializedListener extends EventListener { - - /** - * Invoked when the GUI subsystem is initialized and it's OK for - * the assisitive technology to create instances of GUI objects. - */ - public void guiInitialized(); - -} diff -r e5171238515c -r ec8f5229c8e9 src/windows/classes/com/sun/java/accessibility/util/GUIInitializedMulticaster.java --- a/src/windows/classes/com/sun/java/accessibility/util/GUIInitializedMulticaster.java Fri May 29 10:15:38 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.java.accessibility.util; - -import java.awt.*; -import java.util.EventListener; -import javax.accessibility.*; - - -/** - * The GUIInitializedMulticaster class is used to maintain a list of - * GUIInitializedListener classes. It is intended to be used primarily - * for internal support in the EventQueueMonitor class, and is not intended - * to be used by classes outside the Java Accessibility Utility package. - * - * @see EventQueueMonitor - * @see EventQueueMonitor#addGUIInitializedListener - * @see EventQueueMonitor#removeGUIInitializedListener - * - */ -@jdk.Exported(false) -public class GUIInitializedMulticaster - extends AWTEventMulticaster implements GUIInitializedListener -{ - protected GUIInitializedMulticaster(EventListener a, EventListener b) { - super(a, b); - } - - public void guiInitialized() { - ((GUIInitializedListener)a).guiInitialized(); - ((GUIInitializedListener)b).guiInitialized(); - } - - public static GUIInitializedListener add(GUIInitializedListener a, GUIInitializedListener b) { - return (GUIInitializedListener)addInternal(a, b); - } - - public static GUIInitializedListener remove(GUIInitializedListener l, GUIInitializedListener oldl) { - return (GUIInitializedListener)removeInternal(l, oldl); - } - - protected static EventListener addInternal(EventListener a, EventListener b) { - if (a == null) return b; - if (b == null) return a; - return new GUIInitializedMulticaster(a, b); - } - - protected static EventListener removeInternal(EventListener l, EventListener oldl) { - if (l == oldl || l == null) { - return null; - } else if (l instanceof GUIInitializedMulticaster) { - return ((GUIInitializedMulticaster)l).remove(oldl); - } else { - return l; // it's not here - } - } - -} diff -r e5171238515c -r ec8f5229c8e9 src/windows/classes/com/sun/java/accessibility/util/SwingEventMonitor.java --- a/src/windows/classes/com/sun/java/accessibility/util/SwingEventMonitor.java Fri May 29 10:15:38 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2542 +0,0 @@ -/* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.java.accessibility.util; - -import java.util.*; -import java.beans.*; -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.event.*; -import javax.swing.table.*; -import javax.swing.tree.*; -import javax.swing.text.*; -import javax.swing.undo.*; -import javax.accessibility.*; - - -/** - *

{@code SwingEventMonitor} extends {@link AWTEventMonitor} by adding a suite of - * listeners conditionally installed on every Swing component instance - * in the Java Virtual Machine. The events captured by these listeners - * are made available through a unified set of listeners supported by - * {@code SwingEventMonitor}. With this, all the individual events on each of the - * AWT and Swing component instances are funneled into one set of listeners - * broken down by category (see {@link EventID} for the categories). - *

This class depends upon {@link EventQueueMonitor}, which provides the base - * level support for capturing the top-level containers as they are created. - *

Because this class extends {@code AWTEventMonitor}, it is not - * necessary to use this class and {@code AWTEventMonitor} at the same time. - * If you want to monitor both AWT and Swing components, you should - * use just this class. - * - * @see AWTEventMonitor - * - */ -@jdk.Exported -public class SwingEventMonitor extends AWTEventMonitor { - - /** - * The master list of all listeners registered by other classes. - * This can only be publicly modified by calling the add or - * remove listener methods in this class. - */ - static protected final EventListenerList listenerList = new EventListenerList(); - - /** - * The actual listener that is installed on the component instances. - * This listener calls the other registered listeners when an event - * occurs. By doing things this way, the actual number of listeners - * installed on a component instance is drastically reduced. - */ - static protected final SwingEventListener swingListener = new SwingEventListener(); - - /** - * Adds the specified listener to receive all {@link EventID#ANCESTOR ANCESTOR} - * events on each component instance in the Java Virtual Machine as they occur. - *

Note: This listener is automatically added to all component - * instances created after this method is called. In addition, it - * is only added to component instances that support this listener type. - * - * @param l the listener to add - * @see #removeAncestorListener - */ - static public void addAncestorListener(AncestorListener l) { - if (listenerList.getListenerCount(AncestorListener.class) == 0) { - swingListener.installListeners(EventID.ANCESTOR); - } - listenerList.add(AncestorListener.class, l); - } - - /** - * Removes the specified listener so it no longer receives - * {@link EventID#ANCESTOR ANCESTOR} events when they occur. - * - * @param l the listener to remove - * @see #addAncestorListener - */ - static public void removeAncestorListener(AncestorListener l) { - listenerList.remove(AncestorListener.class, l); - if (listenerList.getListenerCount(AncestorListener.class) == 0) { - swingListener.removeListeners(EventID.ANCESTOR); - } - } - - /** - * Adds the specified listener to receive all {@link EventID#CARET CARET} events - * on each component instance in the Java Virtual Machine as they occur. - *

Note: This listener is automatically added to all component - * instances created after this method is called. In addition, it - * is only added to component instances that support this listener type. - * - * @param l the listener to add - * @see #removeCaretListener - */ - static public void addCaretListener(CaretListener l) { - if (listenerList.getListenerCount(CaretListener.class) == 0) { - swingListener.installListeners(EventID.CARET); - } - listenerList.add(CaretListener.class, l); - } - - /** - * Removes the specified listener so it no longer receives - * {@link EventID#CARET CARET} events when they occur. - * - * @param l the listener to remove - * @see #addCaretListener - */ - static public void removeCaretListener(CaretListener l) { - listenerList.remove(CaretListener.class, l); - if (listenerList.getListenerCount(CaretListener.class) == 0) { - swingListener.removeListeners(EventID.CARET); - } - } - - /** - * Adds the specified listener to receive all - * {@link EventID#CELLEDITOR CELLEDITOR} events on each - * component instance in the Java Virtual Machine as they occur. - *

Note: This listener is automatically added to all component - * instances created after this method is called. In addition, it - * is only added to component instances that support this listener type. - * - * @param l the listener to add - * @see #removeCellEditorListener - */ - static public void addCellEditorListener(CellEditorListener l) { - if (listenerList.getListenerCount(CellEditorListener.class) == 0) { - swingListener.installListeners(EventID.CELLEDITOR); - } - listenerList.add(CellEditorListener.class, l); - } - - /** - * Removes the specified listener so it no longer receives - * {@link EventID#CELLEDITOR CELLEDITOR} events when they occur. - * - * @param l the listener to remove - * @see #addCellEditorListener - */ - static public void removeCellEditorListener(CellEditorListener l) { - listenerList.remove(CellEditorListener.class, l); - if (listenerList.getListenerCount(CellEditorListener.class) == 0) { - swingListener.removeListeners(EventID.CELLEDITOR); - } - } - - /** - * Adds the specified listener to receive all {@link EventID#CHANGE CHANGE} - * events on each component instance in the Java Virtual Machine as they occur. - *

Note: This listener is automatically added to all component - * instances created after this method is called. In addition, it - * is only added to component instances that support this listener type. - * - * @param l the listener to add - * @see #removeChangeListener - */ - static public void addChangeListener(ChangeListener l) { - if (listenerList.getListenerCount(ChangeListener.class) == 0) { - swingListener.installListeners(EventID.CHANGE); - } - listenerList.add(ChangeListener.class, l); - } - - /** - * Removes the specified listener so it no longer receives - * {@link EventID#CHANGE CHANGE} events when they occur. - * - * @param l the listener to remove - * @see #addChangeListener - */ - static public void removeChangeListener(ChangeListener l) { - listenerList.remove(ChangeListener.class, l); - if (listenerList.getListenerCount(ChangeListener.class) == 0) { - swingListener.removeListeners(EventID.CHANGE); - } - } - - /** - * Adds the specified listener to receive all {@link EventID#COLUMNMODEL COLUMNMODEL} - * events on each component instance in the Java Virtual Machine as they occur. - *

Note: This listener is automatically added to all component - * instances created after this method is called. In addition, it - * is only added to component instances that support this listener type. - * - * @param l the listener to add - * @see #removeColumnModelListener - */ - static public void addColumnModelListener(TableColumnModelListener l) { - if (listenerList.getListenerCount(TableColumnModelListener.class) == 0) { - swingListener.installListeners(EventID.COLUMNMODEL); - } - listenerList.add(TableColumnModelListener.class, l); - } - - /** - * Removes the specified listener so it no longer receives - * {@link EventID#COLUMNMODEL COLUMNMODEL} events when they occur. - * - * @param l the listener to remove - * @see #addColumnModelListener - */ - static public void removeColumnModelListener(TableColumnModelListener l) { - listenerList.remove(TableColumnModelListener.class, l); - if (listenerList.getListenerCount(TableColumnModelListener.class) == 0) { - swingListener.removeListeners(EventID.COLUMNMODEL); - } - } - - /** - * Adds the specified listener to receive all {@link EventID#DOCUMENT DOCUMENT} - * events on each component instance in the Java Virtual Machine as they occur. - *

Note: This listener is automatically added to all component - * instances created after this method is called. In addition, it - * is only added to component instances that support this listener type. - * - * @param l the listener to add - * @see #removeDocumentListener - */ - static public void addDocumentListener(DocumentListener l) { - if (listenerList.getListenerCount(DocumentListener.class) == 0) { - swingListener.installListeners(EventID.DOCUMENT); - } - listenerList.add(DocumentListener.class, l); - } - - /** - * Removes the specified listener so it no longer receives - * {@link EventID#DOCUMENT DOCUMENT} events when they occur. - * - * @param l the listener to remove - * @see #addDocumentListener - */ - static public void removeDocumentListener(DocumentListener l) { - listenerList.remove(DocumentListener.class, l); - if (listenerList.getListenerCount(DocumentListener.class) == 0) { - swingListener.removeListeners(EventID.DOCUMENT); - } - } - - /** - * Adds the specified listener to receive all {@link EventID#LISTDATA LISTDATA} - * events on each component instance in the Java Virtual Machine as they occur. - *

Note: This listener is automatically added to all component - * instances created after this method is called. In addition, it - * is only added to component instances that support this listener type. - * - * @param l the listener to add - * @see #removeListDataListener - */ - static public void addListDataListener(ListDataListener l) { - if (listenerList.getListenerCount(ListDataListener.class) == 0) { - swingListener.installListeners(EventID.LISTDATA); - } - listenerList.add(ListDataListener.class, l); - } - - /** - * Removes the specified listener so it no longer receives - * {@link EventID#LISTDATA LISTDATA} events when they occur. - * - * @param l the listener to remove - * @see #addListDataListener - */ - static public void removeListDataListener(ListDataListener l) { - listenerList.remove(ListDataListener.class, l); - if (listenerList.getListenerCount(ListDataListener.class) == 0) { - swingListener.removeListeners(EventID.LISTDATA); - } - } - - /** - * Adds the specified listener to receive all {@link EventID#LISTSELECTION LISTSELECTION} - * events on each component instance in the Java Virtual Machine as they occur. - *

Note: This listener is automatically added to all component - * instances created after this method is called. In addition, it - * is only added to component instances that support this listener type. - * - * @param l the listener to add - * @see #removeListSelectionListener - */ - static public void addListSelectionListener(ListSelectionListener l) { - if (listenerList.getListenerCount(ListSelectionListener.class) == 0) { - swingListener.installListeners(EventID.LISTSELECTION); - } - listenerList.add(ListSelectionListener.class, l); - } - - /** - * Removes the specified listener so it no longer receives - * {@link EventID#LISTSELECTION LISTSELECTION} events when they occur. - * - * @param l the listener to remove - * @see #addListSelectionListener - */ - static public void removeListSelectionListener(ListSelectionListener l) { - listenerList.remove(ListSelectionListener.class, l); - if (listenerList.getListenerCount(ListSelectionListener.class) == 0) { - swingListener.removeListeners(EventID.LISTSELECTION); - } - } - - /** - * Adds the specified listener to receive all {@link EventID#MENU MENU} events - * on each component instance in the Java Virtual Machine as they occur. - *

Note: This listener is automatically added to all component - * instances created after this method is called. In addition, it - * is only added to component instances that support this listener type. - * - * @param l the listener to add - * @see #removeMenuListener - */ - static public void addMenuListener(MenuListener l) { - if (listenerList.getListenerCount(MenuListener.class) == 0) { - swingListener.installListeners(EventID.MENU); - } - listenerList.add(MenuListener.class, l); - } - - /** - * Removes the specified listener so it no longer receives - * {@link EventID#MENU MENU} events when they occur. - * - * @param l the listener to remove - * @see #addMenuListener - */ - static public void removeMenuListener(MenuListener l) { - listenerList.remove(MenuListener.class, l); - if (listenerList.getListenerCount(MenuListener.class) == 0) { - swingListener.removeListeners(EventID.MENU); - } - } - - /** - * Adds the specified listener to receive all {@link EventID#POPUPMENU POPUPMENU} - * events on each component instance in the Java Virtual Machine as they occur. - *

Note: This listener is automatically added to all component - * instances created after this method is called. In addition, it - * is only added to component instances that support this listener type. - * - * @param l the listener to add - * @see #removePopupMenuListener - */ - static public void addPopupMenuListener(PopupMenuListener l) { - if (listenerList.getListenerCount(PopupMenuListener.class) == 0) { - swingListener.installListeners(EventID.POPUPMENU); - } - listenerList.add(PopupMenuListener.class, l); - } - - /** - * Removes the specified listener so it no longer receives - * {@link EventID#POPUPMENU POPUPMENU} events when they occur. - * - * @param l the listener to remove - * @see #addPopupMenuListener - */ - static public void removePopupMenuListener(PopupMenuListener l) { - listenerList.remove(PopupMenuListener.class, l); - if (listenerList.getListenerCount(PopupMenuListener.class) == 0) { - swingListener.removeListeners(EventID.POPUPMENU); - } - } - - /** - * Adds the specified listener to receive all {@link EventID#TABLEMODEL TABLEMODEL} - * events on each component instance in the Java Virtual Machine as they occur. - *

Note: This listener is automatically added to all component - * instances created after this method is called. In addition, it - * is only added to component instances that support this listener type. - * - * @param l the listener to add - * @see #removeTableModelListener - */ - static public void addTableModelListener(TableModelListener l) { - if (listenerList.getListenerCount(TableModelListener.class) == 0) { - swingListener.installListeners(EventID.TABLEMODEL); - } - listenerList.add(TableModelListener.class, l); - } - - /** - * Removes the specified listener so it no longer receives - * {@link EventID#TABLEMODEL TABLEMODEL} events when they occur. - * - * @param l the listener to remove - * @see #addTableModelListener - */ - static public void removeTableModelListener(TableModelListener l) { - listenerList.remove(TableModelListener.class, l); - if (listenerList.getListenerCount(TableModelListener.class) == 0) { - swingListener.removeListeners(EventID.TABLEMODEL); - } - } - - /** - * Adds the specified listener to receive all {@link EventID#TREEEXPANSION TREEEXPANSION} - * events on each component instance in the Java Virtual Machine as they occur. - *

Note: This listener is automatically added to all component - * instances created after this method is called. In addition, it - * is only added to component instances that support this listener type. - * - * @param l the listener to add - * @see #removeTreeExpansionListener - */ - static public void addTreeExpansionListener(TreeExpansionListener l) { - if (listenerList.getListenerCount(TreeExpansionListener.class) == 0) { - swingListener.installListeners(EventID.TREEEXPANSION); - } - listenerList.add(TreeExpansionListener.class, l); - } - - /** - * Removes the specified listener so it no longer receives - * {@link EventID#TREEEXPANSION TREEEXPANSION} events when they occur. - * - * @param l the listener to remove - * @see #addTreeExpansionListener - */ - static public void removeTreeExpansionListener(TreeExpansionListener l) { - listenerList.remove(TreeExpansionListener.class, l); - if (listenerList.getListenerCount(TreeExpansionListener.class) == 0) { - swingListener.removeListeners(EventID.TREEEXPANSION); - } - } - - /** - * Adds the specified listener to receive all {@link EventID#TREEMODEL TREEMODEL} - * events on each component instance in the Java Virtual Machine as they occur. - *

Note: This listener is automatically added to all component - * instances created after this method is called. In addition, it - * is only added to component instances that support this listener type. - * - * @param l the listener to add - * @see #removeTreeModelListener - */ - static public void addTreeModelListener(TreeModelListener l) { - if (listenerList.getListenerCount(TreeModelListener.class) == 0) { - swingListener.installListeners(EventID.TREEMODEL); - } - listenerList.add(TreeModelListener.class, l); - } - - /** - * Removes the specified listener so it no longer receives - * {@link EventID#TREEMODEL TREEMODEL} events when they occur. - * - * @param l the listener to remove - * @see #addTreeModelListener - */ - static public void removeTreeModelListener(TreeModelListener l) { - listenerList.remove(TreeModelListener.class, l); - if (listenerList.getListenerCount(TreeModelListener.class) == 0) { - swingListener.removeListeners(EventID.TREEMODEL); - } - } - - /** - * Adds the specified listener to receive all {@link EventID#TREESELECTION TREESELECTION} - * events on each component instance in the Java Virtual Machine as they occur. - *

Note: This listener is automatically added to all component - * instances created after this method is called. In addition, it - * is only added to component instances that support this listener type. - * - * @param l the listener to add - * @see #removeTreeSelectionListener - */ - static public void addTreeSelectionListener(TreeSelectionListener l) { - if (listenerList.getListenerCount(TreeSelectionListener.class) == 0) { - swingListener.installListeners(EventID.TREESELECTION); - } - listenerList.add(TreeSelectionListener.class, l); - } - - /** - * Removes the specified listener so it no longer receives - * {@link EventID#TREESELECTION TREESELECTION} events when they occur. - * @see #addTreeSelectionListener - * @param l the listener to remove - */ - static public void removeTreeSelectionListener(TreeSelectionListener l) { - listenerList.remove(TreeSelectionListener.class, l); - if (listenerList.getListenerCount(TreeSelectionListener.class) == 0) { - swingListener.removeListeners(EventID.TREESELECTION); - } - } - - /** - * Adds the specified listener to receive all {@link EventID#UNDOABLEEDIT UNDOABLEEDIT} - * events on each component instance in the Java Virtual Machine as they occur. - *

Note: This listener is automatically added to all component - * instances created after this method is called. In addition, it - * is only added to component instances that support this listener type. - * - * @param l the listener to add - * @see #removeUndoableEditListener - */ - static public void addUndoableEditListener(UndoableEditListener l) { - if (listenerList.getListenerCount(UndoableEditListener.class) == 0) { - swingListener.installListeners(EventID.UNDOABLEEDIT); - } - listenerList.add(UndoableEditListener.class, l); - } - - /** - * Removes the specified listener so it no longer receives - * {@link EventID#UNDOABLEEDIT UNDOABLEEDIT} events when they occur. - * - * @param l the listener to remove - * @see #addUndoableEditListener - */ - static public void removeUndoableEditListener(UndoableEditListener l) { - listenerList.remove(UndoableEditListener.class, l); - if (listenerList.getListenerCount(UndoableEditListener.class) == 0) { - swingListener.removeListeners(EventID.UNDOABLEEDIT); - } - } - - /** - * Adds the specified listener to receive all {@link EventID#INTERNALFRAME INTERNALFRAME} - * events on each component instance in the Java Virtual Machine as they occur. - *

Note: This listener is automatically added to all component - * instances created after this method is called. In addition, it - * is only added to component instances that support this listener type. - * - * @param l the listener to add - * @see #removeInternalFrameListener - */ - static public void addInternalFrameListener(InternalFrameListener l) { - if (listenerList.getListenerCount(InternalFrameListener.class) == 0) { - swingListener.installListeners(EventID.INTERNALFRAME); - } - listenerList.add(InternalFrameListener.class, l); - } - - /** - * Removes the specified listener so it no longer receives - * {@link EventID#INTERNALFRAME INTERNALFRAME} events when they occur. - * - * @param l the listener to remove - * @see #addInternalFrameListener - */ - static public void removeInternalFrameListener(InternalFrameListener l) { - listenerList.remove(InternalFrameListener.class, l); - if (listenerList.getListenerCount(InternalFrameListener.class) == 0) { - swingListener.removeListeners(EventID.INTERNALFRAME); - } - } - - /** - * Adds the specified listener to receive all {@link EventID#PROPERTYCHANGE PROPERTYCHANGE} - * events on each component instance in the Java Virtual Machine as they occur. - *

Note: This listener is automatically added to all component - * instances created after this method is called. In addition, it - * is only added to component instances that support this listener type. - * - * @param l the listener to add - * @see #removePropertyChangeListener - */ - static public void addPropertyChangeListener(PropertyChangeListener l) { - if (listenerList.getListenerCount(PropertyChangeListener.class) == 0) { - swingListener.installListeners(EventID.PROPERTYCHANGE); - } - listenerList.add(PropertyChangeListener.class, l); - } - - /** - * Removes the specified listener so it no longer receives - * {@link EventID#PROPERTYCHANGE PROPERTYCHANGE} events when they occur. - * @see #addPropertyChangeListener - * @param l the listener to remove - */ - static public void removePropertyChangeListener(PropertyChangeListener l) { - listenerList.remove(PropertyChangeListener.class, l); - if (listenerList.getListenerCount(PropertyChangeListener.class) == 0) { - swingListener.removeListeners(EventID.PROPERTYCHANGE); - } - } - - /** - * Adds the specified listener to receive all {@link EventID#VETOABLECHANGE VETOABLECHANGE} - * events on each component instance in the Java Virtual Machine as they occur. - *

Note: This listener is automatically added to all component - * instances created after this method is called. In addition, it - * is only added to component instances that support this listener type. - * - * @param l the listener to add - * @see #removeVetoableChangeListener - */ - static public void addVetoableChangeListener(VetoableChangeListener l) { - if (listenerList.getListenerCount(VetoableChangeListener.class) == 0) { - swingListener.installListeners(EventID.VETOABLECHANGE); - } - listenerList.add(VetoableChangeListener.class, l); - } - - /** - * Removes the specified listener so it no longer receives - * {@link EventID#VETOABLECHANGE VETOABLECHANGE} events when they occur. - * - * @param l the listener to remove - * @see #addVetoableChangeListener - */ - static public void removeVetoableChangeListener(VetoableChangeListener l) { - listenerList.remove(VetoableChangeListener.class, l); - if (listenerList.getListenerCount(VetoableChangeListener.class) == 0) { - swingListener.removeListeners(EventID.VETOABLECHANGE); - } - } - - - /** - * SwingEventListener is the class that does all the work for - * SwingEventMonitor. It is not intended for use by any other class - * except SwingEventMonitor. - * - */ - static class SwingEventListener extends AWTEventsListener - implements AncestorListener, CaretListener, CellEditorListener, - ChangeListener, DocumentListener, ListDataListener, - ListSelectionListener, MenuListener, PopupMenuListener, - TableColumnModelListener, TableModelListener, TreeExpansionListener, - TreeModelListener, TreeSelectionListener, UndoableEditListener, - InternalFrameListener, - PropertyChangeListener, VetoableChangeListener { - - /** - * internal variables for Caret introspection - */ - private java.lang.Class caretListeners[]; - private java.lang.reflect.Method removeCaretMethod; - private java.lang.reflect.Method addCaretMethod; - private java.lang.Object caretArgs[]; - - /** - * internal variables for CellEditor introspection - */ - private java.lang.Class cellEditorListeners[]; - private java.lang.reflect.Method removeCellEditorMethod; - private java.lang.reflect.Method addCellEditorMethod; - private java.lang.Object cellEditorArgs[]; - private java.lang.reflect.Method getCellEditorMethod; - - /** - * internal variables for Change introspection - */ - private java.lang.Class changeListeners[]; - private java.lang.reflect.Method removeChangeMethod; - private java.lang.reflect.Method addChangeMethod; - private java.lang.Object changeArgs[]; - - /** - * internal variable for ColumnModel introspection - */ - private java.lang.reflect.Method getColumnModelMethod; - - /** - * internal variables for Document introspection - */ - private java.lang.Class documentListeners[]; - private java.lang.reflect.Method removeDocumentMethod; - private java.lang.reflect.Method addDocumentMethod; - private java.lang.Object documentArgs[]; - private java.lang.reflect.Method getDocumentMethod; - - /** - * internal variable for ListData, Table, and Tree introspection - */ - private java.lang.reflect.Method getModelMethod; - - /** - * internal variables for ListSelection introspection - */ - private java.lang.Class listSelectionListeners[]; - private java.lang.reflect.Method removeListSelectionMethod; - private java.lang.reflect.Method addListSelectionMethod; - private java.lang.Object listSelectionArgs[]; - private java.lang.reflect.Method getSelectionModelMethod; - - /** - * internal variables for Menu introspection - */ - private java.lang.Class menuListeners[]; - private java.lang.reflect.Method removeMenuMethod; - private java.lang.reflect.Method addMenuMethod; - private java.lang.Object menuArgs[]; - - /** - * internal variables for PopupMenu introspection - */ - private java.lang.Class popupMenuListeners[]; - private java.lang.reflect.Method removePopupMenuMethod; - private java.lang.reflect.Method addPopupMenuMethod; - private java.lang.Object popupMenuArgs[]; - private java.lang.reflect.Method getPopupMenuMethod; - - /** - * internal variables for TreeExpansion introspection - */ - private java.lang.Class treeExpansionListeners[]; - private java.lang.reflect.Method removeTreeExpansionMethod; - private java.lang.reflect.Method addTreeExpansionMethod; - private java.lang.Object treeExpansionArgs[]; - - /** - * internal variables for TreeSelection introspection - */ - private java.lang.Class treeSelectionListeners[]; - private java.lang.reflect.Method removeTreeSelectionMethod; - private java.lang.reflect.Method addTreeSelectionMethod; - private java.lang.Object treeSelectionArgs[]; - - /** - * internal variables for UndoableEdit introspection - */ - private java.lang.Class undoableEditListeners[]; - private java.lang.reflect.Method removeUndoableEditMethod; - private java.lang.reflect.Method addUndoableEditMethod; - private java.lang.Object undoableEditArgs[]; - - /** - * internal variables for InternalFrame introspection - */ - private java.lang.Class internalFrameListeners[]; - private java.lang.reflect.Method removeInternalFrameMethod; - private java.lang.reflect.Method addInternalFrameMethod; - private java.lang.Object internalFrameArgs[]; - - /** - * internal variables for PropertyChange introspection - */ - private java.lang.Class propertyChangeListeners[]; - private java.lang.reflect.Method removePropertyChangeMethod; - private java.lang.reflect.Method addPropertyChangeMethod; - private java.lang.Object propertyChangeArgs[]; - - /** - * internal variables for a variety of change introspections - */ - private java.lang.Class nullClass[]; - private java.lang.Object nullArgs[]; - - /** - * Create a new instance of this class and install it on each component - * instance in the virtual machine that supports any of the currently - * registered listeners in SwingEventMonitor. Also registers itself - * as a TopLevelWindowListener with EventQueueMonitor so it can - * automatically add new listeners to new components. - * @see EventQueueMonitor - * @see SwingEventMonitor - */ - public SwingEventListener() { - initializeIntrospection(); - installListeners(); - EventQueueMonitor.addTopLevelWindowListener(this); - } - - /** - * Set up all of the variables needed for introspection - */ - private boolean initializeIntrospection() { - try { - caretListeners = new java.lang.Class[1]; - caretArgs = new java.lang.Object[1]; - caretListeners[0] = Class.forName("javax.swing.event.CaretListener"); - caretArgs[0] = this; - - cellEditorListeners = new java.lang.Class[1]; - cellEditorArgs = new java.lang.Object[1]; - cellEditorListeners[0] = Class.forName("javax.swing.event.CellEditorListener"); - cellEditorArgs[0] = this; - - changeListeners = new java.lang.Class[1]; - changeArgs = new java.lang.Object[1]; - changeListeners[0] = Class.forName("javax.swing.event.ChangeListener"); - changeArgs[0] = this; - - documentListeners = new java.lang.Class[1]; - documentArgs = new java.lang.Object[1]; - documentListeners[0] = Class.forName("javax.swing.event.DocumentListener"); - documentArgs[0] = this; - - listSelectionListeners = new java.lang.Class[1]; - listSelectionArgs = new java.lang.Object[1]; - listSelectionListeners[0] = Class.forName("javax.swing.event.ListSelectionListener"); - listSelectionArgs[0] = this; - - menuListeners = new java.lang.Class[1]; - menuArgs = new java.lang.Object[1]; - menuListeners[0] = Class.forName("javax.swing.event.MenuListener"); - menuArgs[0] = this; - - popupMenuListeners = new java.lang.Class[1]; - popupMenuArgs = new java.lang.Object[1]; - popupMenuListeners[0] = Class.forName("javax.swing.event.PopupMenuListener"); - popupMenuArgs[0] = this; - - treeExpansionListeners = new java.lang.Class[1]; - treeExpansionArgs = new java.lang.Object[1]; - treeExpansionListeners[0] = Class.forName("javax.swing.event.TreeExpansionListener"); - treeExpansionArgs[0] = this; - - treeSelectionListeners = new java.lang.Class[1]; - treeSelectionArgs = new java.lang.Object[1]; - treeSelectionListeners[0] = Class.forName("javax.swing.event.TreeSelectionListener"); - treeSelectionArgs[0] = this; - - undoableEditListeners = new java.lang.Class[1]; - undoableEditArgs = new java.lang.Object[1]; - undoableEditListeners[0] = Class.forName("javax.swing.event.UndoableEditListener"); - undoableEditArgs[0] = this; - - internalFrameListeners = new java.lang.Class[1]; - internalFrameArgs = new java.lang.Object[1]; - internalFrameListeners[0] = Class.forName("javax.swing.event.InternalFrameListener"); - internalFrameArgs[0] = this; - - nullClass = new java.lang.Class[0]; - nullArgs = new java.lang.Object[0]; - - } catch (ClassNotFoundException e) { - System.out.println("EXCEPTION - Class 'javax.swing.event.*' not in CLASSPATH"); - return false; - } - - try { - propertyChangeListeners = new java.lang.Class[1]; - propertyChangeArgs = new java.lang.Object[1]; - propertyChangeListeners[0] = Class.forName("java.beans.PropertyChangeListener"); - propertyChangeArgs[0] = this; - - } catch (ClassNotFoundException e) { - System.out.println("EXCEPTION - Class 'java.beans.*' not in CLASSPATH"); - return false; - } - - return true; - } - - /** - * Installs all appropriate Swing listeners to just the component. - * Also calls super (AWTEventsListener.installListeners()) to install - * the requested AWT listeners. - * @param c the component to add listeners to - */ - protected void installListeners(Component c) { - - // This SwingEventListener needs to be notified when a new - // Swing component has been added so it can add Swing listeners - // to these components. As a result, we always need a Container - // listener on every Container. - // - installListeners(c,EventID.CONTAINER); - - // conditionally install Swing listeners - // - if (SwingEventMonitor.listenerList.getListenerCount(AncestorListener.class) > 0) { - installListeners(c,EventID.ANCESTOR); - } - if (SwingEventMonitor.listenerList.getListenerCount(CaretListener.class) > 0) { - installListeners(c,EventID.CARET); - } - if (SwingEventMonitor.listenerList.getListenerCount(CellEditorListener.class) > 0) { - installListeners(c,EventID.CELLEDITOR); - } - if (SwingEventMonitor.listenerList.getListenerCount(ChangeListener.class) > 0) { - installListeners(c,EventID.CHANGE); - } - if (SwingEventMonitor.listenerList.getListenerCount(TableColumnModelListener.class) > 0) { - installListeners(c,EventID.COLUMNMODEL); - } - if (SwingEventMonitor.listenerList.getListenerCount(DocumentListener.class) > 0) { - installListeners(c,EventID.DOCUMENT); - } - if (SwingEventMonitor.listenerList.getListenerCount(ListDataListener.class) > 0) { - installListeners(c,EventID.LISTDATA); - } - if (SwingEventMonitor.listenerList.getListenerCount(ListSelectionListener.class) > 0) { - installListeners(c,EventID.LISTSELECTION); - } - if (SwingEventMonitor.listenerList.getListenerCount(MenuListener.class) > 0) { - installListeners(c,EventID.MENU); - } - if (SwingEventMonitor.listenerList.getListenerCount(PopupMenuListener.class) > 0) { - installListeners(c,EventID.POPUPMENU); - } - if (SwingEventMonitor.listenerList.getListenerCount(TableModelListener.class) > 0) { - installListeners(c,EventID.TABLEMODEL); - } - if (SwingEventMonitor.listenerList.getListenerCount(TreeExpansionListener.class) > 0) { - installListeners(c,EventID.TREEEXPANSION); - } - if (SwingEventMonitor.listenerList.getListenerCount(TreeModelListener.class) > 0) { - installListeners(c,EventID.TREEMODEL); - } - if (SwingEventMonitor.listenerList.getListenerCount(TreeSelectionListener.class) > 0) { - installListeners(c,EventID.TREESELECTION); - } - if (SwingEventMonitor.listenerList.getListenerCount(UndoableEditListener.class) > 0) { - installListeners(c,EventID.UNDOABLEEDIT); - } - if (SwingEventMonitor.listenerList.getListenerCount(InternalFrameListener.class) > 0) { - installListeners(c,EventID.INTERNALFRAME); - } - - // Conditionally install Beans listeners - // - if (SwingEventMonitor.listenerList.getListenerCount(PropertyChangeListener.class) > 0) { - installListeners(c,EventID.PROPERTYCHANGE); - } - if (SwingEventMonitor.listenerList.getListenerCount(VetoableChangeListener.class) > 0) { - installListeners(c,EventID.VETOABLECHANGE); - } - - // Now install the AWT listeners if needed. - // - super.installListeners(c); - } - - /** - * Installs all appropriate Swing listeners to the component and all its - * children. As a precaution, it always attempts to remove itself as - * a listener first so we're always guaranteed it will installed itself - * just once. - * @param c the component to add listeners to - * @param eventID the eventID to add listeners for - */ - protected void installListeners(Component c, int eventID) { - - // install the appropriate listener hook into this component - // - switch (eventID) { - - case EventID.CONTAINER: - if (c instanceof Container) { - ((Container) c).removeContainerListener(this); - ((Container) c).addContainerListener(this); - } - break; - - case EventID.ANCESTOR: - if (c instanceof JComponent) { - ((JComponent) c).removeAncestorListener(this); - ((JComponent) c).addAncestorListener(this); - } - break; - - case EventID.CARET: - try { - removeCaretMethod = c.getClass().getMethod( - "removeCaretListener", caretListeners); - addCaretMethod = c.getClass().getMethod( - "addCaretListener", caretListeners); - try { - removeCaretMethod.invoke(c, caretArgs); - addCaretMethod.invoke(c, caretArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - case EventID.CELLEDITOR: - // Look for components which support the getCellEditor method - // (e.g. JTable, JTree) - // - try { - getCellEditorMethod = c.getClass().getMethod( - "getCellEditorMethod", nullClass); - try { - Object o = getCellEditorMethod.invoke(c, nullArgs); - if (o != null && o instanceof CellEditor) { - ((CellEditor) o).removeCellEditorListener(this); - ((CellEditor) o).addCellEditorListener(this); - } - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - - // Look for components which support CellEditor listeners - // (no current example) - // - try { - removeCellEditorMethod = c.getClass().getMethod( - "removeCellEditorListener", cellEditorListeners); - addCellEditorMethod = c.getClass().getMethod( - "addCellEditorListener", cellEditorListeners); - try { - removeCellEditorMethod.invoke(c, cellEditorArgs); - addCellEditorMethod.invoke(c, cellEditorArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - case EventID.CHANGE: - // [[[FIXME: Need to add support for Style, StyleContext -pk]]] - - // Look for components which support Change listeners - // (e.g. AbstractButton, Caret, JProgressBar, JSlider, - // JTabbedpane, JTextComponent, JViewport) - // - try { - removeChangeMethod = c.getClass().getMethod( - "removeChangeListener", changeListeners); - addChangeMethod = c.getClass().getMethod( - "addChangeListener", changeListeners); - try { - removeChangeMethod.invoke(c, changeArgs); - addChangeMethod.invoke(c, changeArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - - // Look for components which support the getModel method - // whose model supports Change listeners - // (e.g. BoundedRangeModel, ButtonModel, SingleSelectionModel) - // - try { - getModelMethod = c.getClass().getMethod( - "getModel", nullClass); - try { - Object o = getModelMethod.invoke(c, nullArgs); - if (o != null) { - removeChangeMethod = o.getClass().getMethod( - "removeChangeListener", changeListeners); - addChangeMethod = o.getClass().getMethod( - "addChangeListener", changeListeners); - removeChangeMethod.invoke(o, changeArgs); - addChangeMethod.invoke(o, changeArgs); - } - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - - break; - - case EventID.COLUMNMODEL: - try { - getColumnModelMethod = c.getClass().getMethod( - "getTableColumnModel", nullClass); - try { - Object o = getColumnModelMethod.invoke(c, nullArgs); - if (o != null && o instanceof TableColumnModel) { - ((TableColumnModel) o).removeColumnModelListener(this); - ((TableColumnModel) o).addColumnModelListener(this); - } - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - case EventID.DOCUMENT: - // Look for components which support the getDocument method - // (e.g. JTextComponent) - // - try { - getDocumentMethod = c.getClass().getMethod( - "getDocument", nullClass); - try { - Object o = getDocumentMethod.invoke(c, nullArgs); - if (o != null && o instanceof Document) { - ((Document) o).removeDocumentListener(this); - ((Document) o).addDocumentListener(this); - } - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - - // Look for components which support Document listeners - // (no current example) - // - try { - removeDocumentMethod = c.getClass().getMethod( - "removeDocumentListener", documentListeners); - addDocumentMethod = c.getClass().getMethod( - "addDocumentListener", documentListeners); - try { - removeDocumentMethod.invoke(c, documentArgs); - addDocumentMethod.invoke(c, documentArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - // Add the monitor as a PropertyChangeListener for document - // change events from text components. - // - if (c instanceof JTextComponent) { - try { - removePropertyChangeMethod = c.getClass().getMethod( - "removePropertyChangeListener", - propertyChangeListeners); - addPropertyChangeMethod = c.getClass().getMethod( - "addPropertyChangeListener", - propertyChangeListeners); - try { - removePropertyChangeMethod.invoke(c, - propertyChangeArgs); - addPropertyChangeMethod.invoke(c, - propertyChangeArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - } - break; - - case EventID.LISTDATA: - case EventID.TABLEMODEL: - case EventID.TREEMODEL: - try { - getModelMethod = c.getClass().getMethod( - "getModel", nullClass); - try { - Object o = getModelMethod.invoke(c, nullArgs); - if (o != null) { - if (eventID == EventID.LISTDATA && - o instanceof ListModel) { - ((ListModel) o).removeListDataListener(this); - ((ListModel) o).addListDataListener(this); - } else if (eventID == EventID.TABLEMODEL && - o instanceof TableModel) { - ((TableModel) o).removeTableModelListener(this); - ((TableModel) o).addTableModelListener(this); - } else if ( - o instanceof TreeModel) { - ((TreeModel) o).removeTreeModelListener(this); - ((TreeModel) o).addTreeModelListener(this); - } - } - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - case EventID.LISTSELECTION: - // Look for components which support ListSelectionListeners - // (e.g. JList) - // - try { - removeListSelectionMethod = c.getClass().getMethod( - "removeListSelectionListener", listSelectionListeners); - addListSelectionMethod = c.getClass().getMethod( - "addListSelectionListener", listSelectionListeners); - try { - removeListSelectionMethod.invoke(c, listSelectionArgs); - addListSelectionMethod.invoke(c, listSelectionArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - - // Look for selection models which support ListSelectionListeners - // (e.g. JTable's selection model) - // - try { - getSelectionModelMethod = c.getClass().getMethod( - "getSelectionModel", nullClass); - try { - Object o = getSelectionModelMethod.invoke(c, nullArgs); - if (o != null && o instanceof ListSelectionModel) { - ((ListSelectionModel) o).removeListSelectionListener(this); - ((ListSelectionModel) o).addListSelectionListener(this); - } - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - case EventID.MENU: - try { - removeMenuMethod = c.getClass().getMethod( - "removeMenuListener", menuListeners); - addMenuMethod = c.getClass().getMethod( - "addMenuListener", menuListeners); - try { - removeMenuMethod.invoke(c, menuArgs); - addMenuMethod.invoke(c, menuArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - case EventID.POPUPMENU: - // Look for components which support PopupMenuListeners - // (e.g. JPopupMenu) - // - try { - removePopupMenuMethod = c.getClass().getMethod( - "removePopupMenuListener", popupMenuListeners); - addPopupMenuMethod = c.getClass().getMethod( - "addPopupMenuListener", popupMenuListeners); - try { - removePopupMenuMethod.invoke(c, popupMenuArgs); - addPopupMenuMethod.invoke(c, popupMenuArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - - // Look for components which support getPopupMenu - // (e.g. JMenu) - // - try { - getPopupMenuMethod = c.getClass().getMethod( - "getPopupMenu", nullClass); - try { - Object o = getPopupMenuMethod.invoke(c, nullArgs); - if (o != null) { - removePopupMenuMethod = o.getClass().getMethod( - "removePopupMenuListener", popupMenuListeners); - addPopupMenuMethod = o.getClass().getMethod( - "addPopupMenuListener", popupMenuListeners); - removePopupMenuMethod.invoke(o, popupMenuArgs); - addPopupMenuMethod.invoke(o, popupMenuArgs); - } - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - case EventID.TREEEXPANSION: - try { - removeTreeExpansionMethod = c.getClass().getMethod( - "removeTreeExpansionListener", treeExpansionListeners); - addTreeExpansionMethod = c.getClass().getMethod( - "addTreeExpansionListener", treeExpansionListeners); - try { - removeTreeExpansionMethod.invoke(c, treeExpansionArgs); - addTreeExpansionMethod.invoke(c, treeExpansionArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - case EventID.TREESELECTION: - try { - removeTreeSelectionMethod = c.getClass().getMethod( - "removeTreeSelectionListener", treeSelectionListeners); - addTreeSelectionMethod = c.getClass().getMethod( - "addTreeSelectionListener", treeSelectionListeners); - try { - removeTreeSelectionMethod.invoke(c, treeSelectionArgs); - addTreeSelectionMethod.invoke(c, treeSelectionArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - case EventID.UNDOABLEEDIT: - // Look for components which support the getDocument method - // (e.g. JTextComponent) - // - try { - getDocumentMethod = c.getClass().getMethod( - "getDocument", nullClass); - try { - Object o = getDocumentMethod.invoke(c, nullArgs); - if (o != null && o instanceof Document) { - ((Document) o).removeUndoableEditListener(this); - ((Document) o).addUndoableEditListener(this); - } - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - - // Look for components which support UndoableEdit listeners - // (no current example) - // - try { - removeUndoableEditMethod = c.getClass().getMethod( - "removeUndoableEditListener", undoableEditListeners); - addUndoableEditMethod = c.getClass().getMethod( - "addUndoableEditListener", undoableEditListeners); - try { - removeUndoableEditMethod.invoke(c, undoableEditArgs); - addUndoableEditMethod.invoke(c, undoableEditArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - case EventID.INTERNALFRAME: - // Look for components which support InternalFrame listeners - // (e.g. JInternalFrame) - // - try { - removeInternalFrameMethod = c.getClass().getMethod( - "removeInternalFrameListener", internalFrameListeners); - addInternalFrameMethod = c.getClass().getMethod( - "addInternalFrameListener", internalFrameListeners); - try { - removeInternalFrameMethod.invoke(c, internalFrameArgs); - addInternalFrameMethod.invoke(c, internalFrameArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - case EventID.PROPERTYCHANGE: - // Look for components which support PropertyChange listeners - // (e.g. JComponent) - // - try { - removePropertyChangeMethod = c.getClass().getMethod( - "removePropertyChangeListener", propertyChangeListeners); - addPropertyChangeMethod = c.getClass().getMethod( - "addPropertyChangeListener", propertyChangeListeners); - try { - removePropertyChangeMethod.invoke(c, propertyChangeArgs); - addPropertyChangeMethod.invoke(c, propertyChangeArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - - // Look for components which support the getSelectionModel method - // (e.g. JTextComponent) - // - try { - getSelectionModelMethod = c.getClass().getMethod( - "getSelectionModel", nullClass); - try { - Object o = getSelectionModelMethod.invoke(c, nullArgs); - if (o != null && o instanceof TreeSelectionModel) { - ((TreeSelectionModel) o).removePropertyChangeListener(this); - ((TreeSelectionModel) o).addPropertyChangeListener(this); - } - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - case EventID.VETOABLECHANGE: - if (c instanceof JComponent) { - ((JComponent) c).removeVetoableChangeListener(this); - ((JComponent) c).addVetoableChangeListener(this); - } - break; - - // Don't bother recursing the children if this isn't going to - // accomplish anything. - // - default: - return; - } - - if (c instanceof Container) { - int count = ((Container) c).getComponentCount(); - for (int i = 0; i < count; i++) { - installListeners(((Container) c).getComponent(i), eventID); - } - } - } - - /** - * Removes all listeners for the given component and all its children. - * @param c the component - */ - protected void removeListeners(Component c) { - - // conditionaly remove the Swing listeners - // - if (SwingEventMonitor.listenerList.getListenerCount(AncestorListener.class) > 0) { - removeListeners(c,EventID.ANCESTOR); - } - if (SwingEventMonitor.listenerList.getListenerCount(CaretListener.class) > 0) { - removeListeners(c,EventID.CARET); - } - if (SwingEventMonitor.listenerList.getListenerCount(CellEditorListener.class) > 0) { - removeListeners(c,EventID.CELLEDITOR); - } - if (SwingEventMonitor.listenerList.getListenerCount(ChangeListener.class) > 0) { - removeListeners(c,EventID.CHANGE); - } - if (SwingEventMonitor.listenerList.getListenerCount(TableColumnModelListener.class) > 0) { - removeListeners(c,EventID.COLUMNMODEL); - } - if (SwingEventMonitor.listenerList.getListenerCount(DocumentListener.class) > 0) { - removeListeners(c,EventID.DOCUMENT); - } - if (SwingEventMonitor.listenerList.getListenerCount(ListDataListener.class) > 0) { - removeListeners(c,EventID.LISTDATA); - } - if (SwingEventMonitor.listenerList.getListenerCount(ListSelectionListener.class) > 0) { - removeListeners(c,EventID.LISTSELECTION); - } - if (SwingEventMonitor.listenerList.getListenerCount(MenuListener.class) > 0) { - removeListeners(c,EventID.MENU); - } - if (SwingEventMonitor.listenerList.getListenerCount(PopupMenuListener.class) > 0) { - removeListeners(c,EventID.POPUPMENU); - } - if (SwingEventMonitor.listenerList.getListenerCount(TableModelListener.class) > 0) { - removeListeners(c,EventID.TABLEMODEL); - } - if (SwingEventMonitor.listenerList.getListenerCount(TreeExpansionListener.class) > 0) { - removeListeners(c,EventID.TREEEXPANSION); - } - if (SwingEventMonitor.listenerList.getListenerCount(TreeModelListener.class) > 0) { - removeListeners(c,EventID.TREEMODEL); - } - if (SwingEventMonitor.listenerList.getListenerCount(TreeSelectionListener.class) > 0) { - removeListeners(c,EventID.TREESELECTION); - } - if (SwingEventMonitor.listenerList.getListenerCount(UndoableEditListener.class) > 0) { - removeListeners(c,EventID.UNDOABLEEDIT); - } - if (SwingEventMonitor.listenerList.getListenerCount(InternalFrameListener.class) > 0) { - removeListeners(c,EventID.INTERNALFRAME); - } - - // conditionaly remove the beans listeners - // - if (SwingEventMonitor.listenerList.getListenerCount(PropertyChangeListener.class) > 0) { - removeListeners(c,EventID.PROPERTYCHANGE); - } - if (SwingEventMonitor.listenerList.getListenerCount(VetoableChangeListener.class) > 0) { - removeListeners(c,EventID.VETOABLECHANGE); - } - - // Now remove the AWT listeners if needed. - // - super.removeListeners(c); - } - - /** - * Removes all Swing listeners for the event ID from the component and - * all of its children. - * @param c the component to remove listeners from - */ - protected void removeListeners(Component c, int eventID) { - - // remove the appropriate listener hook into this component - // - switch (eventID) { - - case EventID.CONTAINER: - //Never remove these because we're always interested in them - // for our own use. - break; - - case EventID.ANCESTOR: - if (c instanceof JComponent) { - ((JComponent) c).removeAncestorListener(this); - } - break; - - case EventID.CARET: - try { - removeCaretMethod = c.getClass().getMethod( - "removeCaretListener", caretListeners); - try { - removeCaretMethod.invoke(c, caretArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - case EventID.CELLEDITOR: - // Look for components which support the getCellEditor method - // (e.g. JTable, JTree) - // - try { - getCellEditorMethod = c.getClass().getMethod( - "getCellEditorMethod", nullClass); - try { - Object o = getCellEditorMethod.invoke(c, nullArgs); - if (o != null && o instanceof CellEditor) { - ((CellEditor) o).removeCellEditorListener(this); - } - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - - // Look for components which support CellEditor listeners - // (no current example) - // - try { - removeCellEditorMethod = c.getClass().getMethod( - "removeCellEditorListener", cellEditorListeners); - try { - removeCellEditorMethod.invoke(c, cellEditorArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - case EventID.CHANGE: - // [[[FIXME: Need to add support for Style, StyleContext -pk ]]] - - // Look for components which support Change listeners - // (e.g. AbstractButton, Caret, JProgressBar, JSlider, - // JTabbedpane, JTextComponent, JViewport) - // - try { - removeChangeMethod = c.getClass().getMethod( - "removeChangeListener", changeListeners); - try { - removeChangeMethod.invoke(c, changeArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - - // Look for components which support the getModel method - // whose model supports Change listeners - // (e.g. BoundedRangeModel, ButtonModel, SingleSelectionModel) - // - try { - getModelMethod = c.getClass().getMethod( - "getModel", nullClass); - try { - Object o = getModelMethod.invoke(c, nullArgs); - if (o != null) { - removeChangeMethod = o.getClass().getMethod( - "removeChangeListener", changeListeners); - removeChangeMethod.invoke(o, changeArgs); - } - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - case EventID.COLUMNMODEL: - try { - getColumnModelMethod = c.getClass().getMethod( - "getTableColumnModel", nullClass); - try { - Object o = getColumnModelMethod.invoke(c, nullArgs); - if (o != null && o instanceof TableColumnModel) { - ((TableColumnModel) o).removeColumnModelListener(this); - } - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - case EventID.DOCUMENT: - // Look for components which support the getDocument method - // (e.g. JTextComponent) - // - try { - getDocumentMethod = c.getClass().getMethod( - "getDocument", nullClass); - try { - Object o = getDocumentMethod.invoke(c, nullArgs); - if (o != null && o instanceof Document) { - ((Document) o).removeDocumentListener(this); - } - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - - // Look for components which support Document listeners - // (no current example) - // - try { - removeDocumentMethod = c.getClass().getMethod( - "removeDocumentListener", documentListeners); - try { - removeDocumentMethod.invoke(c, documentArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - case EventID.LISTDATA: - case EventID.TABLEMODEL: - case EventID.TREEMODEL: - try { - getModelMethod = c.getClass().getMethod( - "getModel", nullClass); - try { - Object o = getModelMethod.invoke(c, nullArgs); - if (o != null) { - if (eventID == EventID.LISTDATA && - o instanceof ListModel) { - ((ListModel) o).removeListDataListener(this); - } else if (eventID == EventID.TABLEMODEL && - o instanceof TableModel) { - ((TableModel) o).removeTableModelListener(this); - } else if ( - o instanceof TreeModel) { - ((TreeModel) o).removeTreeModelListener(this); - } - } - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - case EventID.LISTSELECTION: - // Look for components which support ListSelectionListeners - // (e.g. JList) - // - try { - removeListSelectionMethod = c.getClass().getMethod( - "removeListSelectionListener", listSelectionListeners); - try { - removeListSelectionMethod.invoke(c, listSelectionArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - - // Look for selection models which support - // ListSelectionListeners (e.g. JTable's selection model) - // - try { - getSelectionModelMethod = c.getClass().getMethod( - "getSelectionModel", nullClass); - try { - Object o = getSelectionModelMethod.invoke(c, nullArgs); - if (o != null && o instanceof ListSelectionModel) { - ((ListSelectionModel) o).removeListSelectionListener(this); - } - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - case EventID.MENU: - try { - removeMenuMethod = c.getClass().getMethod( - "removeMenuListener", menuListeners); - try { - removeMenuMethod.invoke(c, menuArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - case EventID.POPUPMENU: - // Look for components which support PopupMenuListeners - // (e.g. JPopupMenu) - // - try { - removePopupMenuMethod = c.getClass().getMethod( - "removePopupMenuListener", popupMenuListeners); - try { - removePopupMenuMethod.invoke(c, popupMenuArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - - // Look for components which support getPopupMenu - // (e.g. JMenu) - // - try { - getPopupMenuMethod = c.getClass().getMethod( - "getPopupMenu", nullClass); - try { - Object o = getPopupMenuMethod.invoke(c, nullArgs); - if (o != null) { - removePopupMenuMethod = o.getClass().getMethod( - "removePopupMenuListener", popupMenuListeners); - removePopupMenuMethod.invoke(o, popupMenuArgs); - } - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - case EventID.TREEEXPANSION: - try { - removeTreeExpansionMethod = c.getClass().getMethod( - "removeTreeExpansionListener", treeExpansionListeners); - try { - removeTreeExpansionMethod.invoke(c, treeExpansionArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - case EventID.TREESELECTION: - try { - removeTreeSelectionMethod = c.getClass().getMethod( - "removeTreeSelectionListener", treeSelectionListeners); - try { - removeTreeSelectionMethod.invoke(c, treeSelectionArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - case EventID.UNDOABLEEDIT: - // Look for components which support the getDocument method - // (e.g. JTextComponent) - // - try { - getDocumentMethod = c.getClass().getMethod( - "getDocument", nullClass); - try { - Object o = getDocumentMethod.invoke(c, nullArgs); - if (o != null && o instanceof Document) { - ((Document) o).removeUndoableEditListener(this); - } - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - - // Look for components which support UndoableEdit listeners - // (no current example) - // - try { - removeUndoableEditMethod = c.getClass().getMethod( - "removeUndoableEditListener", undoableEditListeners); - try { - removeUndoableEditMethod.invoke(c, undoableEditArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - case EventID.INTERNALFRAME: - try { - removeInternalFrameMethod = c.getClass().getMethod( - "removeInternalFrameListener", internalFrameListeners); - try { - removeInternalFrameMethod.invoke(c, internalFrameArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - case EventID.PROPERTYCHANGE: - // Look for components which support PropertyChange listeners - // (e.g. JComponent) - // - try { - removePropertyChangeMethod = c.getClass().getMethod( - "removePropertyChangeListener", propertyChangeListeners); - try { - removePropertyChangeMethod.invoke(c, propertyChangeArgs); - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - - // Look for components which support the getSelectionModel - // method (e.g. JTextComponent) - // - try { - getSelectionModelMethod = c.getClass().getMethod( - "getSelectionModel", nullClass); - try { - Object o = getSelectionModelMethod.invoke(c, nullArgs); - if (o != null && o instanceof TreeSelectionModel) { - ((TreeSelectionModel) o).removePropertyChangeListener(this); - } - } catch (java.lang.reflect.InvocationTargetException e) { - System.out.println("Exception: " + e.toString()); - } catch (IllegalAccessException e) { - System.out.println("Exception: " + e.toString()); - } - } catch (NoSuchMethodException e) { - // System.out.println("Exception: " + e.toString()); - } catch (SecurityException e) { - System.out.println("Exception: " + e.toString()); - } - break; - - case EventID.VETOABLECHANGE: - if (c instanceof JComponent) { - ((JComponent) c).removeVetoableChangeListener(this); - } - break; - - default: - return; - } - - if (c instanceof Container) { - int count = ((Container) c).getComponentCount(); - for (int i = 0; i < count; i++) { - removeListeners(((Container) c).getComponent(i), eventID); - } - } - } - - /********************************************************************/ - /* */ - /* Listener Interface Methods */ - /* */ - /********************************************************************/ - - /* ContainerListener Methods ************************************/ - - public void componentAdded(ContainerEvent e) { - installListeners(e.getChild()); - } - public void componentRemoved(ContainerEvent e) { - removeListeners(e.getChild()); - } - - /* AncestorListener Methods ******************************************/ - - public void ancestorAdded(AncestorEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==AncestorListener.class) { - ((AncestorListener)listeners[i+1]).ancestorAdded(e); - } - } - } - - public void ancestorRemoved(AncestorEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==AncestorListener.class) { - ((AncestorListener)listeners[i+1]).ancestorRemoved(e); - } - } - } - - public void ancestorMoved(AncestorEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==AncestorListener.class) { - ((AncestorListener)listeners[i+1]).ancestorMoved(e); - } - } - } - - /* CaretListener Methods ******************************************/ - - public void caretUpdate(CaretEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==CaretListener.class) { - ((CaretListener)listeners[i+1]).caretUpdate(e); - } - } - } - - /* CellEditorListener Methods *****************************************/ - - public void editingStopped(ChangeEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==CellEditorListener.class) { - ((CellEditorListener)listeners[i+1]).editingStopped(e); - } - } - } - - public void editingCanceled(ChangeEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==CellEditorListener.class) { - ((CellEditorListener)listeners[i+1]).editingCanceled(e); - } - } - } - - /* ChangeListener Methods *****************************************/ - - public void stateChanged(ChangeEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==ChangeListener.class) { - ((ChangeListener)listeners[i+1]).stateChanged(e); - } - } - } - - /* TableColumnModelListener Methods *******************************/ - - public void columnAdded(TableColumnModelEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==TableColumnModelListener.class) { - ((TableColumnModelListener)listeners[i+1]).columnAdded(e); - } - } - } - public void columnMarginChanged(ChangeEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==TableColumnModelListener.class) { - ((TableColumnModelListener)listeners[i+1]).columnMarginChanged(e); - } - } - } - public void columnMoved(TableColumnModelEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==TableColumnModelListener.class) { - ((TableColumnModelListener)listeners[i+1]).columnMoved(e); - } - } - } - public void columnRemoved(TableColumnModelEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==TableColumnModelListener.class) { - ((TableColumnModelListener)listeners[i+1]).columnRemoved(e); - } - } - } - public void columnSelectionChanged(ListSelectionEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==TableColumnModelListener.class) { - ((TableColumnModelListener)listeners[i+1]).columnSelectionChanged(e); - } - } - } - - /* DocumentListener Methods **************************************/ - - public void changedUpdate(DocumentEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==DocumentListener.class) { - ((DocumentListener)listeners[i+1]).changedUpdate(e); - } - } - } - public void insertUpdate(DocumentEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==DocumentListener.class) { - ((DocumentListener)listeners[i+1]).insertUpdate(e); - } - } - } - public void removeUpdate(DocumentEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==DocumentListener.class) { - ((DocumentListener)listeners[i+1]).removeUpdate(e); - } - } - } - - /* ListDataListener Methods *****************************************/ - - public void contentsChanged(ListDataEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==ListDataListener.class) { - ((ListDataListener)listeners[i+1]).contentsChanged(e); - } - } - } - public void intervalAdded(ListDataEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==ListDataListener.class) { - ((ListDataListener)listeners[i+1]).intervalAdded(e); - } - } - } - public void intervalRemoved(ListDataEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==ListDataListener.class) { - ((ListDataListener)listeners[i+1]).intervalRemoved(e); - } - } - } - - /* ListSelectionListener Methods ***********************************/ - - public void valueChanged(ListSelectionEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==ListSelectionListener.class) { - ((ListSelectionListener)listeners[i+1]).valueChanged(e); - } - } - } - - /* MenuListener Methods *****************************************/ - - public void menuCanceled(MenuEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==MenuListener.class) { - ((MenuListener)listeners[i+1]).menuCanceled(e); - } - } - } - public void menuDeselected(MenuEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==MenuListener.class) { - ((MenuListener)listeners[i+1]).menuDeselected(e); - } - } - } - public void menuSelected(MenuEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==MenuListener.class) { - ((MenuListener)listeners[i+1]).menuSelected(e); - } - } - } - - /* PopupMenuListener Methods **************************************/ - - public void popupMenuWillBecomeVisible(PopupMenuEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==PopupMenuListener.class) { - ((PopupMenuListener)listeners[i+1]).popupMenuWillBecomeVisible(e); - } - } - } - - public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==PopupMenuListener.class) { - ((PopupMenuListener)listeners[i+1]).popupMenuWillBecomeInvisible(e); - } - } - } - - public void popupMenuCanceled(PopupMenuEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==PopupMenuListener.class) { - ((PopupMenuListener)listeners[i+1]).popupMenuCanceled(e); - } - } - } - - /* TableModelListener Methods **************************************/ - - public void tableChanged(TableModelEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==TableModelListener.class) { - ((TableModelListener)listeners[i+1]).tableChanged(e); - } - } - } - - /* TreeExpansionListener Methods **********************************/ - - public void treeCollapsed(TreeExpansionEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==TreeExpansionListener.class) { - ((TreeExpansionListener)listeners[i+1]).treeCollapsed(e); - } - } - } - public void treeExpanded(TreeExpansionEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==TreeExpansionListener.class) { - ((TreeExpansionListener)listeners[i+1]).treeExpanded(e); - } - } - } - - /* TreeModelListener Methods **********************************/ - - public void treeNodesChanged(TreeModelEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==TreeModelListener.class) { - ((TreeModelListener)listeners[i+1]).treeNodesChanged(e); - } - } - } - public void treeNodesInserted(TreeModelEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==TreeModelListener.class) { - ((TreeModelListener)listeners[i+1]).treeNodesInserted(e); - } - } - } - public void treeNodesRemoved(TreeModelEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==TreeModelListener.class) { - ((TreeModelListener)listeners[i+1]).treeNodesRemoved(e); - } - } - } - public void treeStructureChanged(TreeModelEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==TreeModelListener.class) { - ((TreeModelListener)listeners[i+1]).treeStructureChanged(e); - } - } - } - - /* TreeSelectionListener Methods ***********************************/ - - public void valueChanged(TreeSelectionEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==TreeSelectionListener.class) { - ((TreeSelectionListener)listeners[i+1]).valueChanged(e); - } - } - } - - /* UndoableEditListener Methods **************************************/ - - public void undoableEditHappened(UndoableEditEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==UndoableEditListener.class) { - ((UndoableEditListener)listeners[i+1]).undoableEditHappened(e); - } - } - } - - /* InternalFrame Methods **********************************/ - - public void internalFrameOpened(InternalFrameEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==InternalFrameListener.class) { - ((InternalFrameListener)listeners[i+1]).internalFrameOpened(e); - } - } - } - - public void internalFrameActivated(InternalFrameEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==InternalFrameListener.class) { - ((InternalFrameListener)listeners[i+1]).internalFrameActivated(e); - } - } - } - - public void internalFrameDeactivated(InternalFrameEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==InternalFrameListener.class) { - ((InternalFrameListener)listeners[i+1]).internalFrameDeactivated(e); - } - } - } - - public void internalFrameIconified(InternalFrameEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==InternalFrameListener.class) { - ((InternalFrameListener)listeners[i+1]).internalFrameIconified(e); - } - } - } - - public void internalFrameDeiconified(InternalFrameEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==InternalFrameListener.class) { - ((InternalFrameListener)listeners[i+1]).internalFrameDeiconified(e); - } - } - } - - public void internalFrameClosing(InternalFrameEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==InternalFrameListener.class) { - ((InternalFrameListener)listeners[i+1]).internalFrameClosing(e); - } - } - } - - public void internalFrameClosed(InternalFrameEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==InternalFrameListener.class) { - ((InternalFrameListener)listeners[i+1]).internalFrameClosed(e); - } - } - } - - /* PropertyChangeListener Methods **********************************/ - - public void propertyChange(PropertyChangeEvent e) { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==PropertyChangeListener.class) { - ((PropertyChangeListener)listeners[i+1]).propertyChange(e); - } - } - // Re-add the monitor as a DocumentChangeListener if - // the document changed in the text component. - if (e.getSource() instanceof JTextComponent) { - Document c = ((JTextComponent)e.getSource()).getDocument(); - if (c == null) { - return; - } - try { - removeDocumentMethod = c.getClass().getMethod( - "removeDocumentListener", documentListeners); - addDocumentMethod = c.getClass().getMethod( - "addDocumentListener", documentListeners); - try { - removeDocumentMethod.invoke(c, documentArgs); - addDocumentMethod.invoke(c, documentArgs); - } catch (java.lang.reflect.InvocationTargetException e2) { - System.out.println("Exception: " + e2.toString()); - } catch (IllegalAccessException e2) { - System.out.println("Exception: " + e2.toString()); - } - } catch (NoSuchMethodException e2) { - // System.out.println("Exception: " + e2.toString()); - } catch (SecurityException e2) { - System.out.println("Exception: " + e2.toString()); - } - } - - } - - /* VetoableChangeListener Methods **********************************/ - - public void vetoableChange(PropertyChangeEvent e) - throws PropertyVetoException { - Object[] listeners = SwingEventMonitor.listenerList.getListenerList(); - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==VetoableChangeListener.class) { - ((VetoableChangeListener)listeners[i+1]).vetoableChange(e); - } - } - } - } -} diff -r e5171238515c -r ec8f5229c8e9 src/windows/classes/com/sun/java/accessibility/util/TopLevelWindowListener.java --- a/src/windows/classes/com/sun/java/accessibility/util/TopLevelWindowListener.java Fri May 29 10:15:38 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.java.accessibility.util; - -import java.awt.*; -import java.util.*; -import javax.accessibility.*; - -/** - * The {@code TopLevelWindowListener} interface is used by the {@link EventQueueMonitor} - * class to notify an interested party when a top level window is created - * or destroyed in the Java Virtual Machine. Classes wishing to express - * an interest in top level window events should implement this interface - * and register themselves with the {@code EventQueueMonitor} by calling the - * {@link EventQueueMonitor#addTopLevelWindowListener EventQueueMonitor.addTopLevelWindowListener} - * class method. - * - * @see EventQueueMonitor - * @see EventQueueMonitor#addTopLevelWindowListener - * @see EventQueueMonitor#removeTopLevelWindowListener - * - */ -@jdk.Exported -public interface TopLevelWindowListener extends EventListener { - - /** - * Invoked when a new top level window has been created. - * - * @param w the Window that was created - */ - public void topLevelWindowCreated(Window w); - - /** - * Invoked when a top level window has been destroyed. - * - * @param w the Window that was destroyed - */ - public void topLevelWindowDestroyed(Window w); -} diff -r e5171238515c -r ec8f5229c8e9 src/windows/classes/com/sun/java/accessibility/util/TopLevelWindowMulticaster.java --- a/src/windows/classes/com/sun/java/accessibility/util/TopLevelWindowMulticaster.java Fri May 29 10:15:38 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.java.accessibility.util; - -import java.awt.*; -import java.util.EventListener; -import javax.accessibility.*; - - -/** - * The TopLevelWindowMulticaster class is used to maintain a list of - * TopLevelWindowListener classes. It is intended to be used primarily - * for internal support in the EventQueueMonitor class, and is not intended - * to be used by classes outside the Java Accessibility Utility package. - * - * @see EventQueueMonitor - * @see EventQueueMonitor#addTopLevelWindowListener - * @see EventQueueMonitor#removeTopLevelWindowListener - * - */ -@jdk.Exported(false) -public class TopLevelWindowMulticaster - extends AWTEventMulticaster implements TopLevelWindowListener -{ - protected TopLevelWindowMulticaster(EventListener a, EventListener b) { - super(a, b); - } - - public void topLevelWindowCreated(Window w) { - ((TopLevelWindowListener)a).topLevelWindowCreated(w); - ((TopLevelWindowListener)b).topLevelWindowCreated(w); - } - - public void topLevelWindowDestroyed(Window w) { - ((TopLevelWindowListener)a).topLevelWindowDestroyed(w); - ((TopLevelWindowListener)b).topLevelWindowDestroyed(w); - } - - public static TopLevelWindowListener add(TopLevelWindowListener a, TopLevelWindowListener b) { - return (TopLevelWindowListener)addInternal(a, b); - } - - public static TopLevelWindowListener remove(TopLevelWindowListener l, TopLevelWindowListener oldl) { - return (TopLevelWindowListener)removeInternal(l, oldl); - } - - protected static EventListener addInternal(EventListener a, EventListener b) { - if (a == null) return b; - if (b == null) return a; - return new TopLevelWindowMulticaster(a, b); - } - - protected static EventListener removeInternal(EventListener l, EventListener oldl) { - if (l == oldl || l == null) { - return null; - } else if (l instanceof TopLevelWindowMulticaster) { - return ((TopLevelWindowMulticaster)l).remove(oldl); - } else { - return l; // it's not here - } - } - -} diff -r e5171238515c -r ec8f5229c8e9 src/windows/classes/com/sun/java/accessibility/util/Translator.java --- a/src/windows/classes/com/sun/java/accessibility/util/Translator.java Fri May 29 10:15:38 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,730 +0,0 @@ -/* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -package com.sun.java.accessibility.util; - -import java.lang.*; -import java.beans.*; -import java.util.*; -import java.awt.*; -import java.awt.event.*; -import java.awt.image.*; -// Do not import Swing classes. This module is intended to work -// with both Swing and AWT. -// import javax.swing.*; -import javax.accessibility.*; - -/** - *

The {@code Translator} class provides a translation to interface - * {@link javax.accessibility.Accessible Accessible} - * for objects that do not implement interface {@code Accessible}. Assistive - * technologies can use the {@link #getAccessible getAccessible} class method of - * {@code Translator} to obtain an object that implements interface {@code Accessible}. - * If the object passed in already implements interface {@code Accessible}, - * {@code getAccessible} merely returns the object. - * - *

An example of how an assistive technology might use the {@code Translator} - * class is as follows: - * - *

- *    Accessible accessible = Translator.getAccessible(someObj);
- *    // obtain information from the 'accessible' object.
- * 
- * - *

Note: This implementation is missing many things and is not a recommended way - * to implement accessibility features for a toolkit. Instead of relying upon this - * code, a toolkit's components should implement interface {@code Accessible} directly. - */ -@jdk.Exported -public class Translator extends AccessibleContext - implements Accessible, AccessibleComponent { - - /** The source object needing translating. */ - protected Object source; - - /** - * Find a translator for this class. If one doesn't exist for this - * class explicitly, try its superclass and so on. - * - * @param c a Class - * @return the {@code Translator} Class for the Class passed in - */ - protected static Class getTranslatorClass(Class c) { - Class t = null; - if (c == null) { - return null; - } - try { - t = Class.forName("com.sun.java.accessibility.util." - + c.getName() - + "Translator"); - return t; - } catch (Exception e) { - return getTranslatorClass(c.getSuperclass()); - } - } - - /** - * Obtain an object that implements interface {@code Accessible}. If the object - * passed in already implements interface {@code Accessible}, {@code getAccessible} - * merely returns the object. - * - * @param o an Object; if a null is passed in a null is returned - * @return an {@code Object}, possibly the {@code Object} passed in, that - * implements the {@code Accessible} interface for the {@code Object} - * which was passed in - */ - public static Accessible getAccessible(Object o) { - Accessible a = null; - - if (o == null) { - return null; - } - if (o instanceof Accessible) { - a = (Accessible)o; - } else { - Class translatorClass = getTranslatorClass(o.getClass()); - if (translatorClass != null) { - try { - Translator t = (Translator)translatorClass.newInstance(); - t.setSource(o); - a = t; - } catch (Exception e) { - } - } - } - if (a == null) { - a = new Translator(o); - } - return a; - } - - /** - * Create a new {@code Translator}. You must call the {@link #setSource setSource} - * method to set the object to be translated after calling this constructor. - */ - public Translator() { - } - - /** - * Create a new {@code Translator} with the source object o. - * - * @param o the Component that does not implement interface - * {@link javax.accessibility.Accessible Accessible} - */ - public Translator(Object o) { - source = o; - } - - /** - * Get the source {@code Object} of the {@code Translator}. - * - * @return the source {@code Object} of the {@code Translator} - */ - public Object getSource() { - return source; - } - - /** - * Set the source object of the {@code Translator}. - * - * @param o the Component that does not implement interface Accessible - */ - public void setSource(Object o) { - source = o; - } - - /** - * Returns true if this object is the same as the one passed in. - * - * @param o the {@code Object} to check against - * @return true if this is the same object - */ - public boolean equals(Object o) { - return source.equals(o); - } - - -// Accessible methods - - /** - * Returns this object. - */ - public AccessibleContext getAccessibleContext() { - return this; - } - -// AccessibleContext methods - - /** - * Get the accessible name of this object. - * - * @return the localized name of the object; can be null if this object - * does not have a name - */ - public String getAccessibleName() { - if (source instanceof MenuItem) { - return ((MenuItem) source).getLabel(); - } else if (source instanceof Component) { - return ((Component) source).getName(); - } else { - return null; - } - } - - /** - * Set the name of this object. - */ - public void setAccessibleName(String s) { - if (source instanceof MenuItem) { - ((MenuItem) source).setLabel(s); - } else if (source instanceof Component) { - ((Component) source).setName(s); - } - } - - /** - * Get the accessible description of this object. - * - * @return the description of the object; can be null if this object does - * not have a description - */ - public String getAccessibleDescription() { - return null; - } - - /** - * Set the accessible description of this object. - * - * @param s the new localized description of the object - */ - public void setAccessibleDescription(String s) { - } - - /** - * Get the role of this object. - * - * @return an instance of AccessibleRole describing the role of the object - */ - public AccessibleRole getAccessibleRole() { - return AccessibleRole.UNKNOWN; - } - - - /** - * Get the state of this object, given an already populated state. - * This method is intended for use by subclasses so they don't have - * to check for everything. - * - * @return an instance of {@code AccessibleStateSet} - * containing the current state of the object - */ - public AccessibleStateSet getAccessibleStateSet() { - AccessibleStateSet states = new AccessibleStateSet(); - if (source instanceof Component) { - Component c = (Component) source; - for (Container p = c.getParent(); p != null; p = p.getParent()) { - if (p instanceof Window) { - if (((Window)p).getFocusOwner() == c) { - states.add(AccessibleState.FOCUSED); - } - } - } - } - if (isEnabled()) { - states.add(AccessibleState.ENABLED); - } - if (isFocusTraversable()) { - states.add(AccessibleState.FOCUSABLE); - } - if (source instanceof MenuItem) { - states.add(AccessibleState.FOCUSABLE); - } - return states; - } - - /** - * Get the accessible parent of this object. - * - * @return the accessible parent of this object; can be null if this - * object does not have an accessible parent - */ - public Accessible getAccessibleParent() { - if (accessibleParent != null) { - return accessibleParent; - } else if (source instanceof Component) { - return getAccessible(((Component) source).getParent()); - } else { - return null; - } - } - - /** - * Get the index of this object in its accessible parent. - * - * @return -1 of this object does not have an accessible parent; otherwise, - * the index of the child in its accessible parent - */ - public int getAccessibleIndexInParent() { - if (source instanceof Component) { - Container parent = ((Component) source).getParent(); - if (parent != null) { - Component ca[] = parent.getComponents(); - for (int i = 0; i < ca.length; i++) { - if (source.equals(ca[i])) { - return i; - } - } - } - } - return -1; - } - - /** - * Returns the number of accessible children in the object. - * - * @return the number of accessible children in the object - */ - public int getAccessibleChildrenCount() { - if (source instanceof Container) { - Component[] children = ((Container) source).getComponents(); - int count = 0; - for (int i = 0; i < children.length; i++) { - Accessible a = getAccessible(children[i]); - if (a != null) { - count++; - } - } - return count; - } else { - return 0; - } - } - - /** - * Return the nth accessible child of the object. - * - * @param i zero-based index of child - * @return the nth accessible child of the object - */ - public Accessible getAccessibleChild(int i) { - if (source instanceof Container) { - Component[] children = ((Container) source).getComponents(); - int count = 0; - - for (int j = 0; j < children.length; j++) { - Accessible a = getAccessible(children[j]); - if (a != null) { - if (count == i) { - AccessibleContext ac = a.getAccessibleContext(); - if (ac != null) { - ac.setAccessibleParent(this); - } - return a; - } else { - count++; - } - } - } - } - return null; - } - - /** - * Gets the {@code Locale} of the component. If the component does not have a - * locale, the locale of its parent is returned. - * - * @return the {@code Locale} of the object - */ - public Locale getLocale() throws IllegalComponentStateException { - if (source instanceof Component) { - return ((Component) source).getLocale(); - } else { - return null; - } - } - - /** - * Add a {@code PropertyChangeListener} to the listener list. The listener - * is registered for all properties. - */ - public void addPropertyChangeListener(PropertyChangeListener l) { - } - - /** - * Remove the {@code PropertyChangeListener} from the listener list. - */ - public void removePropertyChangeListener(PropertyChangeListener l) { - } - -// AccessibleComponent methods - - /** - * Get the background {@code Color} of this object. - * - * @return if supported, the background {@code Color} of the object; - * otherwise, null - * - */ - public Color getBackground() { - if (source instanceof Component) { // MenuComponent doesn't do background - return ((Component) source).getBackground(); - } else { - return null; - } - } - - /** - * Set the background {@code Color} of this object. - * - * @param c the new {@code Color} for the background - */ - public void setBackground(Color c) { - if (source instanceof Component) { // MenuComponent doesn't do background - ((Component) source).setBackground(c); - } - } - - /** - * Get the foreground {@code Color} of this object. - * - * @return if supported, the foreground {@code Color} of the object; otherwise, null - */ - public Color getForeground() { - if (source instanceof Component) { // MenuComponent doesn't do foreground - return ((Component) source).getForeground(); - } else { - return null; - } - } - - /** - * Set the foreground {@code Color} of this object. - * - * @param c the new {@code Color} for the foreground - */ - public void setForeground(Color c) { - if (source instanceof Component) { // MenuComponent doesn't do foreground - ((Component) source).setForeground(c); - } - } - - /** - * Get the {@code Cursor} of this object. - * - * @return if supported, the Cursor of the object; otherwise, null - */ - public Cursor getCursor() { - if (source instanceof Component) { // MenuComponent doesn't do cursor - return ((Component) source).getCursor(); - } else { - return null; - } - } - - /** - * Set the {@code Cursor} of this object. - * @param c the new {@code Cursor} for the object - */ - public void setCursor(Cursor c) { - if (source instanceof Component) { // MenuComponent doesn't do cursor - ((Component) source).setCursor(c); - } - } - - /** - * Get the {@code Font} of this object. - * - * @return if supported, the {@code Font} for the object; otherwise, null - */ - public Font getFont() { - if (source instanceof Component) { - return ((Component) source).getFont(); - } else if (source instanceof MenuComponent) { - return ((MenuComponent) source).getFont(); - } else { - return null; - } - } - - /** - * Set the {@code Font} of this object. - * - * @param f the new {@code Font} for the object - */ - public void setFont(Font f) { - if (source instanceof Component) { - ((Component) source).setFont(f); - } else if (source instanceof MenuComponent) { - ((MenuComponent) source).setFont(f); - } - } - - /** - * Get the {@code FontMetrics} of this object. - * - * @param f the {@code Font} - * @return if supported, the {@code FontMetrics} the object; otherwise, null - * @see #getFont - */ - public FontMetrics getFontMetrics(Font f) { - if (source instanceof Component) { - return ((Component) source).getFontMetrics(f); - } else { - return null; - } - } - - /** - * Determine if the object is enabled. - * - * @return true if object is enabled; otherwise, false - */ - public boolean isEnabled() { - if (source instanceof Component) { - return ((Component) source).isEnabled(); - } else if (source instanceof MenuItem) { - return ((MenuItem) source).isEnabled(); - } else { - return true; - } - } - - /** - * Set the enabled state of the object. - * - * @param b if true, enables this object; otherwise, disables it - */ - public void setEnabled(boolean b) { - if (source instanceof Component) { - ((Component) source).setEnabled(b); - } else if (source instanceof MenuItem) { - ((MenuItem) source).setEnabled(b); - } - } - - /** - * Determine if the object is visible. - * - * @return true if object is visible; otherwise, false - */ - public boolean isVisible() { - if (source instanceof Component) { - return ((Component) source).isVisible(); - } else { - return false; - } - } - - /** - * Set the visible state of the object. - * - * @param b if true, shows this object; otherwise, hides it - */ - public void setVisible(boolean b) { - if (source instanceof Component) { - ((Component) source).setVisible(b); - } - } - - /** - * Determine if the object is showing. This is determined by checking - * the visibility of the object and ancestors of the object. - * - * @return true if object is showing; otherwise, false - */ - public boolean isShowing() { - if (source instanceof Component) { - return ((Component) source).isShowing(); - } else { - return false; - } - } - - /** - * Checks whether the specified {@code Point} is within this - * object's bounds, where the {@code Point} is relative to the coordinate - * system of the object. - * - * @param p the {@code Point} relative to the coordinate system of the object - * @return true if object contains {@code Point}; otherwise false - */ - public boolean contains(Point p) { - if (source instanceof Component) { - return ((Component) source).contains(p); - } else { - return false; - } - } - - /** - * Returns the location of the object on the screen. - * - * @return location of object on screen; can be null if this object - * is not on the screen - */ - public Point getLocationOnScreen() { - if (source instanceof Component) { - return ((Component) source).getLocationOnScreen(); - } else { - return null; - } - } - - /** - * Returns the location of the object relative to parent. - * - * @return location of object relative to parent; can be null if - * this object or its parent are not on the screen - */ - public Point getLocation() { - if (source instanceof Component) { - return ((Component) source).getLocation(); - } else { - return null; - } - } - - /** - * Sets the location of the object relative to parent. - */ - public void setLocation(Point p) { - if (source instanceof Component) { - ((Component) source).setLocation(p); - } - } - - /** - * Returns the current bounds of this object. - * - * @return current bounds of object; can be null if this object - * is not on the screen - */ - public Rectangle getBounds() { - if (source instanceof Component) { - return ((Component) source).getBounds(); - } else { - return null; - } - } - - /** - * Sets the current bounds of this object. - */ - public void setBounds(Rectangle r) { - if (source instanceof Component) { - ((Component) source).setBounds(r); - } - } - - /** - * Returns the current size of this object. - * - * @return current size of object; can be null if this object is - * not on the screen - */ - public Dimension getSize() { - if (source instanceof Component) { - return ((Component) source).getSize(); - } else { - return null; - } - } - - /** - * Sets the current size of this object. - */ - public void setSize(Dimension d) { - if (source instanceof Component) { - ((Component) source).setSize(d); - } - } - - /** - * Returns the accessible child contained at the local coordinate - * Point, if one exists. - * - * @return the Accessible at the specified location, if it exists - */ - public Accessible getAccessibleAt(Point p) { - if (source instanceof Component) { - Component c = ((Component) source).getComponentAt(p); - if (c != null) { - return (getAccessible(c)); - } - } - return null; - } - - /** - * Returns whether this object can accept focus or not. - * - * @return true if object can accept focus; otherwise false - */ - public boolean isFocusTraversable() { - if (source instanceof Component) { - return ((Component) source).isFocusTraversable(); - } else { - return false; - } - } - - /** - * Requests focus for this object. - */ - public void requestFocus() { - if (source instanceof Component) { - ((Component) source).requestFocus(); - } - } - - /** - * Adds the specified {@code FocusListener} to receive focus events from - * this component. - * - * @param l the focus listener - */ - public synchronized void addFocusListener(FocusListener l) { - if (source instanceof Component) { - ((Component) source).addFocusListener(l); - } - } - - /** - * Removes the specified focus listener so it no longer receives focus - * events from this component. - * - * @param l the focus listener; this method performs no function, nor does it - * throw an exception if the listener specified was not previously added - * to this component; if listener is null, no exception is thrown and no - * action is performed. - */ - public synchronized void removeFocusListener(FocusListener l) { - if (source instanceof Component) { - ((Component) source).removeFocusListener(l); - } - } -} diff -r e5171238515c -r ec8f5229c8e9 src/windows/classes/com/sun/java/accessibility/util/java/awt/ButtonTranslator.java --- a/src/windows/classes/com/sun/java/accessibility/util/java/awt/ButtonTranslator.java Fri May 29 10:15:38 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.java.accessibility.util.java.awt; - -import java.lang.*; -import java.util.*; -import java.awt.*; -import java.awt.image.*; -import javax.accessibility.*; -import com.sun.java.accessibility.util.*; - -/** - *

The Translator class provides a translation to interface Accessible - * for objects that do not implement interface Accessible. Assistive - * technologies can use the 'getAccessible' class method of Translator to - * obtain an object that implements interface Accessible. If the object - * passed in already implements interface Accessible, getAccessible merely - * returns the object. - * - *

An example of how an assistive technology might use the Translator - * class is as follows: - * - *

- *    Accessible accessible = Translator.getAccessible(someObj);
- *    // obtain information from the 'accessible' object.
- * 
- * - *

This class extends the Translator class to provide specific support - * for the Button class. Translator.getAccessible() will automatically - * load this class when an assistive technology asks for an accessible - * translator for Button. - * - */ -public class ButtonTranslator extends Translator { - - /** - * Get the name of this object. - * @return the name of the object -- can be null if this object does - * not have a name - */ - public String getAccessibleName() { - return ((Button) source).getLabel(); - } - - /** - * Set the name of this object. - */ - public void setAccessibleName(String s) { - ((Button) source).setLabel(s); - } - - public AccessibleRole getAccessibleRole() { - return AccessibleRole.PUSH_BUTTON; - } -} diff -r e5171238515c -r ec8f5229c8e9 src/windows/classes/com/sun/java/accessibility/util/java/awt/CheckboxTranslator.java --- a/src/windows/classes/com/sun/java/accessibility/util/java/awt/CheckboxTranslator.java Fri May 29 10:15:38 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.java.accessibility.util.java.awt; - -import java.lang.*; -import java.util.*; -import java.awt.*; -import java.awt.image.*; -import javax.accessibility.*; -import com.sun.java.accessibility.util.*; - -/** - *

The Translator class provides a translation to interface Accessible - * for objects that do not implement interface Accessible. Assistive - * technologies can use the 'getAccessible' class method of Translator to - * obtain an object that implements interface Accessible. If the object - * passed in already implements interface Accessible, getAccessible merely - * returns the object. - * - *

An example of how an assistive technology might use the Translator - * class is as follows: - * - *

- *    Accessible accessible = Translator.getAccessible(someObj);
- *    // obtain information from the 'accessible' object.
- * 
- * - *

This class extends the Translator class to provide specific support - * for the Checkbox class. Translator.getAccessible() will automatically - * load this class when an assistive technology asks for an accessible - * translator for Checkbox. - * - */ -public class CheckboxTranslator extends Translator { - - /** - * Get the state of this object. - * @return an instance of AccessibleState containing the current state of the object - * @see AccessibleState - */ - public AccessibleStateSet getAccessibleStateSet() { - AccessibleStateSet states = super.getAccessibleStateSet(); - if (((Checkbox) source).getState()) { - states.add(AccessibleState.CHECKED); - } - return states; - } - - /** - * Get the name of this object. - * @return the name of the object -- can be null if this object does - * not have a name - */ - public String getAccessibleName() { - return ((Checkbox) source).getLabel(); - } - - /** - * Set the name of this object. - */ - public void setAccessibleName(String s) { - ((Checkbox) source).setLabel(s); - } - - public AccessibleRole getAccessibleRole() { - return AccessibleRole.CHECK_BOX; - } -} diff -r e5171238515c -r ec8f5229c8e9 src/windows/classes/com/sun/java/accessibility/util/java/awt/ChoiceTranslator.java --- a/src/windows/classes/com/sun/java/accessibility/util/java/awt/ChoiceTranslator.java Fri May 29 10:15:38 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.java.accessibility.util.java.awt; - -import java.lang.*; -import java.util.*; -import java.awt.*; -import java.awt.image.*; -import javax.accessibility.*; -import com.sun.java.accessibility.util.*; - -/** - *

The Translator class provides a translation to interface Accessible - * for objects that do not implement interface Accessible. Assistive - * technologies can use the 'getAccessible' class method of Translator to - * obtain an object that implements interface Accessible. If the object - * passed in already implements interface Accessible, getAccessible merely - * returns the object. - * - *

An example of how an assistive technology might use the Translator - * class is as follows: - * - *

- *    Accessible accessible = Translator.getAccessible(someObj);
- *    // obtain information from the 'accessible' object.
- * 
- * - *

This class extends the Translator class to provide specific support - * for the Choice class. Translator.getAccessible() will automatically - * load this class when an assistive technology asks for an accessible - * translator for Choice. - * - */ -public class ChoiceTranslator extends Translator { - - /** - * Get the state of this object. - * @return an instance of AccessibleState containing the current state of the object - * @see AccessibleState - */ - public AccessibleStateSet getAccessibleStateSet() { - AccessibleStateSet states = super.getAccessibleStateSet(); - states.add(AccessibleState.SELECTED); - return states; - } - - public AccessibleRole getAccessibleRole() { - return AccessibleRole.CHOICE; - } -} diff -r e5171238515c -r ec8f5229c8e9 src/windows/classes/com/sun/java/accessibility/util/java/awt/LabelTranslator.java --- a/src/windows/classes/com/sun/java/accessibility/util/java/awt/LabelTranslator.java Fri May 29 10:15:38 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.java.accessibility.util.java.awt; - -import java.lang.*; -import java.util.*; -import java.awt.*; -import java.awt.image.*; -import javax.accessibility.*; -import com.sun.java.accessibility.util.*; - -/** - *

The Translator class provides a translation to interface Accessible - * for objects that do not implement interface Accessible. Assistive - * technologies can use the 'getAccessible' class method of Translator to - * obtain an object that implements interface Accessible. If the object - * passed in already implements interface Accessible, getAccessible merely - * returns the object. - * - *

An example of how an assistive technology might use the Translator - * class is as follows: - * - *

- *    Accessible accessible = Translator.getAccessible(someObj);
- *    // obtain information from the 'accessible' object.
- * 
- * - *

This class extends the Translator class to provide specific support - * for the Label class. Translator.getAccessible() will automatically - * load this class when an assistive technology asks for an accessible - * translator for Label. - * - */ -public class LabelTranslator extends Translator { - - public String getAccessibleName() { - return ((Label) source).getText(); - } - - /** - * Set the name of this object. - */ - public void setAccessibleName(String s) { - ((Label) source).setText(s); - } - - public AccessibleRole getAccessibleRole() { - return AccessibleRole.LABEL; - } -} diff -r e5171238515c -r ec8f5229c8e9 src/windows/classes/com/sun/java/accessibility/util/java/awt/ListTranslator.java --- a/src/windows/classes/com/sun/java/accessibility/util/java/awt/ListTranslator.java Fri May 29 10:15:38 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.java.accessibility.util.java.awt; - -import java.lang.*; -import java.util.*; -import java.awt.*; -import java.awt.image.*; -import javax.accessibility.*; -import com.sun.java.accessibility.util.*; - -/** - *

The Translator class provides a translation to interface Accessible - * for objects that do not implement interface Accessible. Assistive - * technologies can use the 'getAccessible' class method of Translator to - * obtain an object that implements interface Accessible. If the object - * passed in already implements interface Accessible, getAccessible merely - * returns the object. - * - *

An example of how an assistive technology might use the Translator - * class is as follows: - * - *

- *    Accessible accessible = Translator.getAccessible(someObj);
- *    // obtain information from the 'accessible' object.
- * 
- * - *

This class extends the Translator class to provide specific support - * for the List class. Translator.getAccessible() will automatically - * load this class when an assistive technology asks for an accessible - * translator for List. - * - */ -public class ListTranslator extends Translator { - - /** - * Get the state of this object. - * @return an instance of AccessibleState containing the current state of the object - * @see AccessibleState - */ - public AccessibleStateSet getAccessibleStateSet() { - AccessibleStateSet states = super.getAccessibleStateSet(); - if (((java.awt.List) source).isMultipleMode()) { - states.add(AccessibleState.MULTISELECTABLE); - } - if (((java.awt.List) source).getSelectedItems().length > 0) { - states.add(AccessibleState.SELECTED); - } - return states; - } - - public AccessibleRole getAccessibleRole() { - return AccessibleRole.LIST; - } -} diff -r e5171238515c -r ec8f5229c8e9 src/windows/classes/com/sun/java/accessibility/util/java/awt/TextComponentTranslator.java --- a/src/windows/classes/com/sun/java/accessibility/util/java/awt/TextComponentTranslator.java Fri May 29 10:15:38 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.java.accessibility.util.java.awt; - -import java.lang.*; -import java.util.*; -import java.awt.*; -import java.awt.image.*; -import javax.accessibility.*; -import com.sun.java.accessibility.util.*; - -/** - *

The Translator class provides a translation to interface Accessible - * for objects that do not implement interface Accessible. Assistive - * technologies can use the 'getAccessible' class method of Translator to - * obtain an object that implements interface Accessible. If the object - * passed in already implements interface Accessible, getAccessible merely - * returns the object. - * - *

An example of how an assistive technology might use the Translator - * class is as follows: - * - *

- *    Accessible accessible = Translator.getAccessible(someObj);
- *    // obtain information from the 'accessible' object.
- * 
- * - *

This class extends the Translator class to provide specific support - * for the TextComponent class. Translator.getAccessible() will automatically - * load this class when an assistive technology asks for an accessible - * translator for TextComponent. - * - */ -public class TextComponentTranslator extends Translator { - - public AccessibleRole getAccessibleRole() { - return AccessibleRole.TEXT; - } -} diff -r e5171238515c -r ec8f5229c8e9 src/windows/classes/com/sun/java/accessibility/util/package-info.java --- a/src/windows/classes/com/sun/java/accessibility/util/package-info.java Fri May 29 10:15:38 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2013, 2015 Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * Provides a collection of interfaces and classes that compose the Java Accessibility - * Utilities. The classes are used by Assistive Technologies, such as the screen - * readers which are used by those who are blind, and help provide access to GUI - * toolkits that implement the Java Accessibility API. An overview of the important - * classes follows. - * - *

The class {@code AccessibilityEventMonitor} implements a PropertyChange - * listener on every UI object that implements interface {@code Accessible} in the Java - * Virtual Machine. - * - *

The class {@code AWTEventMonitor} implements a suite of listeners that are - * conditionally installed on every AWT component instance in the Java Virtual Machine. - * - *

The class {@code EventQueueMonitor} provides key core functionality for - * Assistive Technologies (and other system-level technologies that need some of - * the same things that Assistive Technology needs). - * - *

The class {@code GUIInitializedMulticaster} is used to maintain a list of - * {@code GUIInitializedListener} classes which are used by the {@code EventQueueMonitor} - * class to notify an interested party when the GUI subsystem has been initialized. - * Note that this class is intended to be used primarily for internal support in - * the {@code EventQueueMonitor} class, and is not intended to be used by classes - * outside the Java Accessibility Utility package. - * - *

The class {@code SwingEventMonitor} extends {@code AWTEventMonitor} by adding - * a suite of listeners conditionally installed on every Swing component instance - * in the Java Virtual Machine. - * - *

The class {@code TopLevelWindowMulticaster} is used to maintain a list of - * {@code TopLevelWindowListener} classes which are used by the {@code EventQueueMonitor} - * class to notify an interested party when a top level window is created or destroyed - * in the Java Virtual Machine Note that this class is intended to be used primarily - * for internal support in the {@code EventQueueMonitor} class, and is not intended - * to be used by classes outside the Java Accessibility Utility package. - * - *

The class {@code Translator} provides a translation to interface {@code Accessible} - * for objects that do not implement interface {@code Accessible}. - * - * @since JDK1.7 - */ -package com.sun.java.accessibility.util; diff -r e5171238515c -r ec8f5229c8e9 src/windows/classes/java/util/prefs/WindowsPreferences.java --- a/src/windows/classes/java/util/prefs/WindowsPreferences.java Fri May 29 10:15:38 2015 -0700 +++ b/src/windows/classes/java/util/prefs/WindowsPreferences.java Wed Jun 03 20:28:57 2015 -0700 @@ -53,8 +53,8 @@ /** * Windows registry path to Preferences's root nodes. */ - private static final byte[] WINDOWS_ROOT_PATH - = stringToByteArray("Software\\JavaSoft\\Prefs"); + private static final byte[] WINDOWS_ROOT_PATH = + stringToByteArray("Software\\JavaSoft\\Prefs"); /** * Windows handles to HKEY_CURRENT_USER and @@ -138,12 +138,12 @@ * Java wrapper for Windows registry API RegOpenKey() */ private static native int[] WindowsRegOpenKey(int hKey, byte[] subKey, - int securityMask); + int securityMask); /** * Retries RegOpenKey() MAX_ATTEMPTS times before giving up. */ private static int[] WindowsRegOpenKey1(int hKey, byte[] subKey, - int securityMask) { + int securityMask) { int[] result = WindowsRegOpenKey(hKey, subKey, securityMask); if (result[ERROR_CODE] == ERROR_SUCCESS) { return result; @@ -158,16 +158,16 @@ } else if (result[ERROR_CODE] != ERROR_ACCESS_DENIED) { long sleepTime = INIT_SLEEP_TIME; for (int i = 0; i < MAX_ATTEMPTS; i++) { - try { - Thread.sleep(sleepTime); - } catch(InterruptedException e) { - return result; - } - sleepTime *= 2; - result = WindowsRegOpenKey(hKey, subKey, securityMask); - if (result[ERROR_CODE] == ERROR_SUCCESS) { - return result; - } + try { + Thread.sleep(sleepTime); + } catch(InterruptedException e) { + return result; + } + sleepTime *= 2; + result = WindowsRegOpenKey(hKey, subKey, securityMask); + if (result[ERROR_CODE] == ERROR_SUCCESS) { + return result; + } } } return result; @@ -189,10 +189,10 @@ private static int[] WindowsRegCreateKeyEx1(int hKey, byte[] subKey) { int[] result = WindowsRegCreateKeyEx(hKey, subKey); if (result[ERROR_CODE] == ERROR_SUCCESS) { - return result; - } else { - long sleepTime = INIT_SLEEP_TIME; - for (int i = 0; i < MAX_ATTEMPTS; i++) { + return result; + } else { + long sleepTime = INIT_SLEEP_TIME; + for (int i = 0; i < MAX_ATTEMPTS; i++) { try { Thread.sleep(sleepTime); } catch(InterruptedException e) { @@ -201,7 +201,7 @@ sleepTime *= 2; result = WindowsRegCreateKeyEx(hKey, subKey); if (result[ERROR_CODE] == ERROR_SUCCESS) { - return result; + return result; } } } @@ -223,10 +223,10 @@ private static int WindowsRegFlushKey1(int hKey) { int result = WindowsRegFlushKey(hKey); if (result == ERROR_SUCCESS) { - return result; - } else { - long sleepTime = INIT_SLEEP_TIME; - for (int i = 0; i < MAX_ATTEMPTS; i++) { + return result; + } else { + long sleepTime = INIT_SLEEP_TIME; + for (int i = 0; i < MAX_ATTEMPTS; i++) { try { Thread.sleep(sleepTime); } catch(InterruptedException e) { @@ -235,7 +235,7 @@ sleepTime *= 2; result = WindowsRegFlushKey(hKey); if (result == ERROR_SUCCESS) { - return result; + return result; } } } @@ -246,23 +246,23 @@ * Java wrapper for Windows registry API RegQueryValueEx() */ private static native byte[] WindowsRegQueryValueEx(int hKey, - byte[] valueName); + byte[] valueName); /** * Java wrapper for Windows registry API RegSetValueEx() */ private static native int WindowsRegSetValueEx(int hKey, byte[] valueName, - byte[] value); + byte[] value); /** * Retries RegSetValueEx() MAX_ATTEMPTS times before giving up. */ private static int WindowsRegSetValueEx1(int hKey, byte[] valueName, - byte[] value) { + byte[] value) { int result = WindowsRegSetValueEx(hKey, valueName, value); if (result == ERROR_SUCCESS) { - return result; - } else { - long sleepTime = INIT_SLEEP_TIME; - for (int i = 0; i < MAX_ATTEMPTS; i++) { + return result; + } else { + long sleepTime = INIT_SLEEP_TIME; + for (int i = 0; i < MAX_ATTEMPTS; i++) { try { Thread.sleep(sleepTime); } catch(InterruptedException e) { @@ -271,7 +271,7 @@ sleepTime *= 2; result = WindowsRegSetValueEx(hKey, valueName, value); if (result == ERROR_SUCCESS) { - return result; + return result; } } } @@ -294,10 +294,10 @@ private static int[] WindowsRegQueryInfoKey1(int hKey) { int[] result = WindowsRegQueryInfoKey(hKey); if (result[ERROR_CODE] == ERROR_SUCCESS) { - return result; - } else { - long sleepTime = INIT_SLEEP_TIME; - for (int i = 0; i < MAX_ATTEMPTS; i++) { + return result; + } else { + long sleepTime = INIT_SLEEP_TIME; + for (int i = 0; i < MAX_ATTEMPTS; i++) { try { Thread.sleep(sleepTime); } catch(InterruptedException e) { @@ -306,7 +306,7 @@ sleepTime *= 2; result = WindowsRegQueryInfoKey(hKey); if (result[ERROR_CODE] == ERROR_SUCCESS) { - return result; + return result; } } } @@ -317,19 +317,19 @@ * Java wrapper for Windows registry API RegEnumKeyEx() */ private static native byte[] WindowsRegEnumKeyEx(int hKey, int subKeyIndex, - int maxKeyLength); + int maxKeyLength); /** * Retries RegEnumKeyEx() MAX_ATTEMPTS times before giving up. */ private static byte[] WindowsRegEnumKeyEx1(int hKey, int subKeyIndex, - int maxKeyLength) { + int maxKeyLength) { byte[] result = WindowsRegEnumKeyEx(hKey, subKeyIndex, maxKeyLength); if (result != null) { - return result; - } else { - long sleepTime = INIT_SLEEP_TIME; - for (int i = 0; i < MAX_ATTEMPTS; i++) { + return result; + } else { + long sleepTime = INIT_SLEEP_TIME; + for (int i = 0; i < MAX_ATTEMPTS; i++) { try { Thread.sleep(sleepTime); } catch(InterruptedException e) { @@ -338,7 +338,7 @@ sleepTime *= 2; result = WindowsRegEnumKeyEx(hKey, subKeyIndex, maxKeyLength); if (result != null) { - return result; + return result; } } } @@ -349,19 +349,19 @@ * Java wrapper for Windows registry API RegEnumValue() */ private static native byte[] WindowsRegEnumValue(int hKey, int valueIndex, - int maxValueNameLength); + int maxValueNameLength); /** * Retries RegEnumValueEx() MAX_ATTEMPTS times before giving up. */ private static byte[] WindowsRegEnumValue1(int hKey, int valueIndex, - int maxValueNameLength) { + int maxValueNameLength) { byte[] result = WindowsRegEnumValue(hKey, valueIndex, - maxValueNameLength); + maxValueNameLength); if (result != null) { - return result; - } else { - long sleepTime = INIT_SLEEP_TIME; - for (int i = 0; i < MAX_ATTEMPTS; i++) { + return result; + } else { + long sleepTime = INIT_SLEEP_TIME; + for (int i = 0; i < MAX_ATTEMPTS; i++) { try { Thread.sleep(sleepTime); } catch(InterruptedException e) { @@ -369,9 +369,9 @@ } sleepTime *= 2; result = WindowsRegEnumValue(hKey, valueIndex, - maxValueNameLength); + maxValueNameLength); if (result != null) { - return result; + return result; } } } @@ -395,11 +395,11 @@ int[] result = WindowsRegCreateKeyEx1(parentNativeHandle, toWindowsName(name)); if (result[ERROR_CODE] != ERROR_SUCCESS) { - logger().warning("Could not create windows registry " - + "node " + byteArrayToString(windowsAbsolutePath()) + - " at root 0x" + Integer.toHexString(rootNativeHandle()) + - ". Windows RegCreateKeyEx(...) returned error code " + - result[ERROR_CODE] + "."); + logger().warning("Could not create windows registry node " + + byteArrayToString(windowsAbsolutePath()) + + " at root 0x" + Integer.toHexString(rootNativeHandle()) + + ". Windows RegCreateKeyEx(...) returned error code " + + result[ERROR_CODE] + "."); isBackingStoreAvailable = false; return; } @@ -417,15 +417,15 @@ * @param rootDirectory Path to root directory, as a byte-encoded string. */ private WindowsPreferences(int rootNativeHandle, byte[] rootDirectory) { - super(null,""); + super(null, ""); int[] result = WindowsRegCreateKeyEx1(rootNativeHandle, rootDirectory); if (result[ERROR_CODE] != ERROR_SUCCESS) { logger().warning("Could not open/create prefs root node " + - byteArrayToString(windowsAbsolutePath()) + " at root 0x" + - Integer.toHexString(rootNativeHandle()) + - ". Windows RegCreateKeyEx(...) returned error code " + - result[ERROR_CODE] + "."); + byteArrayToString(windowsAbsolutePath()) + + " at root 0x" + Integer.toHexString(rootNativeHandle()) + + ". Windows RegCreateKeyEx(...) returned error code " + + result[ERROR_CODE] + "."); isBackingStoreAvailable = false; return; } @@ -442,7 +442,7 @@ private byte[] windowsAbsolutePath() { ByteArrayOutputStream bstream = new ByteArrayOutputStream(); bstream.write(WINDOWS_ROOT_PATH, 0, WINDOWS_ROOT_PATH.length-1); - StringTokenizer tokenizer = new StringTokenizer(absolutePath(),"/"); + StringTokenizer tokenizer = new StringTokenizer(absolutePath(), "/"); while (tokenizer.hasMoreTokens()) { bstream.write((byte)'\\'); String nextName = tokenizer.nextToken(); @@ -496,27 +496,30 @@ /* Check if key's path is short enough be opened at once otherwise use a path-splitting procedure */ if (windowsAbsolutePath.length <= MAX_WINDOWS_PATH_LENGTH + 1) { - int[] result = WindowsRegOpenKey1(rootNativeHandle(), - windowsAbsolutePath, mask1); - if (result[ERROR_CODE] == ERROR_ACCESS_DENIED && mask2 != mask1) - result = WindowsRegOpenKey1(rootNativeHandle(), - windowsAbsolutePath, mask2); + int[] result = WindowsRegOpenKey1(rootNativeHandle(), + windowsAbsolutePath, mask1); + if (result[ERROR_CODE] == ERROR_ACCESS_DENIED && mask2 != mask1) + result = WindowsRegOpenKey1(rootNativeHandle(), + windowsAbsolutePath, mask2); - if (result[ERROR_CODE] != ERROR_SUCCESS) { - logger().warning("Could not open windows " - + "registry node " + byteArrayToString(windowsAbsolutePath()) + - " at root 0x" + Integer.toHexString(rootNativeHandle()) + - ". Windows RegOpenKey(...) returned error code " + - result[ERROR_CODE] + "."); + if (result[ERROR_CODE] != ERROR_SUCCESS) { + logger().warning("Could not open windows registry node " + + byteArrayToString(windowsAbsolutePath()) + + " at root 0x" + + Integer.toHexString(rootNativeHandle()) + + ". Windows RegOpenKey(...) returned error code " + + result[ERROR_CODE] + "."); result[NATIVE_HANDLE] = NULL_NATIVE_HANDLE; if (result[ERROR_CODE] == ERROR_ACCESS_DENIED) { - throw new SecurityException("Could not open windows " - + "registry node " + byteArrayToString(windowsAbsolutePath()) + - " at root 0x" + Integer.toHexString(rootNativeHandle()) + - ": Access denied"); + throw new SecurityException( + "Could not open windows registry node " + + byteArrayToString(windowsAbsolutePath()) + + " at root 0x" + + Integer.toHexString(rootNativeHandle()) + + ": Access denied"); } - } - return result[NATIVE_HANDLE]; + } + return result[NATIVE_HANDLE]; } else { return openKey(rootNativeHandle(), windowsAbsolutePath, mask1, mask2); } @@ -539,21 +542,21 @@ int mask1, int mask2) { /* If the path is short enough open at once. Otherwise split the path */ if (windowsRelativePath.length <= MAX_WINDOWS_PATH_LENGTH + 1 ) { - int[] result = WindowsRegOpenKey1(nativeHandle, - windowsRelativePath, mask1); - if (result[ERROR_CODE] == ERROR_ACCESS_DENIED && mask2 != mask1) - result = WindowsRegOpenKey1(nativeHandle, - windowsRelativePath, mask2); + int[] result = WindowsRegOpenKey1(nativeHandle, + windowsRelativePath, mask1); + if (result[ERROR_CODE] == ERROR_ACCESS_DENIED && mask2 != mask1) + result = WindowsRegOpenKey1(nativeHandle, + windowsRelativePath, mask2); - if (result[ERROR_CODE] != ERROR_SUCCESS) { - logger().warning("Could not open windows " - + "registry node " + byteArrayToString(windowsAbsolutePath()) + - " at root 0x" + Integer.toHexString(nativeHandle) + - ". Windows RegOpenKey(...) returned error code " + - result[ERROR_CODE] + "."); + if (result[ERROR_CODE] != ERROR_SUCCESS) { + logger().warning("Could not open windows registry node " + + byteArrayToString(windowsAbsolutePath()) + + " at root 0x" + Integer.toHexString(nativeHandle) + + ". Windows RegOpenKey(...) returned error code " + + result[ERROR_CODE] + "."); result[NATIVE_HANDLE] = NULL_NATIVE_HANDLE; - } - return result[NATIVE_HANDLE]; + } + return result[NATIVE_HANDLE]; } else { int separatorPosition = -1; // Be greedy - open the longest possible path @@ -595,10 +598,12 @@ private void closeKey(int nativeHandle) { int result = WindowsRegCloseKey(nativeHandle); if (result != ERROR_SUCCESS) { - logger().warning("Could not close windows " - + "registry node " + byteArrayToString(windowsAbsolutePath()) + - " at root 0x" + Integer.toHexString(rootNativeHandle()) + - ". Windows RegCloseKey(...) returned error code " + result + "."); + logger().warning("Could not close windows registry node " + + byteArrayToString(windowsAbsolutePath()) + + " at root 0x" + + Integer.toHexString(rootNativeHandle()) + + ". Windows RegCloseKey(...) returned error code " + + result + "."); } } @@ -609,22 +614,25 @@ * @see #getSpi(String) */ protected void putSpi(String javaName, String value) { - int nativeHandle = openKey(KEY_SET_VALUE); - if (nativeHandle == NULL_NATIVE_HANDLE) { - isBackingStoreAvailable = false; - return; - } - int result = WindowsRegSetValueEx1(nativeHandle, - toWindowsName(javaName), toWindowsValueString(value)); - if (result != ERROR_SUCCESS) { - logger().warning("Could not assign value to key " + - byteArrayToString(toWindowsName(javaName))+ " at Windows registry node " - + byteArrayToString(windowsAbsolutePath()) + " at root 0x" - + Integer.toHexString(rootNativeHandle()) + - ". Windows RegSetValueEx(...) returned error code " + result + "."); - isBackingStoreAvailable = false; + int nativeHandle = openKey(KEY_SET_VALUE); + if (nativeHandle == NULL_NATIVE_HANDLE) { + isBackingStoreAvailable = false; + return; } - closeKey(nativeHandle); + int result = WindowsRegSetValueEx1(nativeHandle, + toWindowsName(javaName), toWindowsValueString(value)); + if (result != ERROR_SUCCESS) { + logger().warning("Could not assign value to key " + + byteArrayToString(toWindowsName(javaName)) + + " at Windows registry node " + + byteArrayToString(windowsAbsolutePath()) + + " at root 0x" + + Integer.toHexString(rootNativeHandle()) + + ". Windows RegSetValueEx(...) returned error code " + + result + "."); + isBackingStoreAvailable = false; + } + closeKey(nativeHandle); } /** @@ -663,12 +671,12 @@ int result = WindowsRegDeleteValue(nativeHandle, toWindowsName(key)); if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) { - logger().warning("Could not delete windows registry " - + "value " + byteArrayToString(windowsAbsolutePath())+ "\\" + - toWindowsName(key) + " at root 0x" + - Integer.toHexString(rootNativeHandle()) + - ". Windows RegDeleteValue(...) returned error code " + - result + "."); + logger().warning("Could not delete windows registry value " + + byteArrayToString(windowsAbsolutePath()) + "\\" + + toWindowsName(key) + " at root 0x" + + Integer.toHexString(rootNativeHandle()) + + ". Windows RegDeleteValue(...) returned error code " + + result + "."); isBackingStoreAvailable = false; } closeKey(nativeHandle); @@ -684,17 +692,20 @@ // Find out the number of values int nativeHandle = openKey(KEY_QUERY_VALUE); if (nativeHandle == NULL_NATIVE_HANDLE) { - throw new BackingStoreException("Could not open windows" - + "registry node " + byteArrayToString(windowsAbsolutePath()) + - " at root 0x" + Integer.toHexString(rootNativeHandle()) + "."); + throw new BackingStoreException( + "Could not open windows registry node " + + byteArrayToString(windowsAbsolutePath()) + + " at root 0x" + + Integer.toHexString(rootNativeHandle()) + "."); } int[] result = WindowsRegQueryInfoKey1(nativeHandle); if (result[ERROR_CODE] != ERROR_SUCCESS) { - String info = "Could not query windows" - + "registry node " + byteArrayToString(windowsAbsolutePath()) + - " at root 0x" + Integer.toHexString(rootNativeHandle()) + - ". Windows RegQueryInfoKeyEx(...) returned error code " + - result[ERROR_CODE] + "."; + String info = "Could not query windows registry node " + + byteArrayToString(windowsAbsolutePath()) + + " at root 0x" + + Integer.toHexString(rootNativeHandle()) + + ". Windows RegQueryInfoKeyEx(...) returned error code " + + result[ERROR_CODE] + "."; logger().warning(info); throw new BackingStoreException(info); } @@ -703,17 +714,17 @@ if (valuesNumber == 0) { closeKey(nativeHandle); return new String[0]; - } - // Get the values - String[] valueNames = new String[valuesNumber]; - for (int i = 0; i < valuesNumber; i++) { + } + // Get the values + String[] valueNames = new String[valuesNumber]; + for (int i = 0; i < valuesNumber; i++) { byte[] windowsName = WindowsRegEnumValue1(nativeHandle, i, - maxValueNameLength+1); + maxValueNameLength+1); if (windowsName == null) { String info = - "Could not enumerate value #" + i + " of windows node " + - byteArrayToString(windowsAbsolutePath()) + " at root 0x" + - Integer.toHexString(rootNativeHandle()) + "."; + "Could not enumerate value #" + i + " of windows node " + + byteArrayToString(windowsAbsolutePath()) + " at root 0x" + + Integer.toHexString(rootNativeHandle()) + "."; logger().warning(info); throw new BackingStoreException(info); } @@ -731,20 +742,22 @@ */ protected String[] childrenNamesSpi() throws BackingStoreException { // Open key - int nativeHandle = openKey(KEY_ENUMERATE_SUB_KEYS| KEY_QUERY_VALUE); + int nativeHandle = openKey(KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE); if (nativeHandle == NULL_NATIVE_HANDLE) { - throw new BackingStoreException("Could not open windows" - + "registry node " + byteArrayToString(windowsAbsolutePath()) + - " at root 0x" + Integer.toHexString(rootNativeHandle()) + "."); + throw new BackingStoreException( + "Could not open windows registry node " + + byteArrayToString(windowsAbsolutePath()) + + " at root 0x" + + Integer.toHexString(rootNativeHandle()) + "."); } // Get number of children int[] result = WindowsRegQueryInfoKey1(nativeHandle); if (result[ERROR_CODE] != ERROR_SUCCESS) { - String info = "Could not query windows" - + "registry node " + byteArrayToString(windowsAbsolutePath()) + - " at root 0x" + Integer.toHexString(rootNativeHandle()) + - ". Windows RegQueryInfoKeyEx(...) returned error code " + - result[ERROR_CODE] + "."; + String info = "Could not query windows registry node " + + byteArrayToString(windowsAbsolutePath()) + + " at root 0x" + Integer.toHexString(rootNativeHandle()) + + ". Windows RegQueryInfoKeyEx(...) returned error code " + + result[ERROR_CODE] + "."; logger().warning(info); throw new BackingStoreException(info); } @@ -759,12 +772,12 @@ // Get children for (int i = 0; i < subKeysNumber; i++) { byte[] windowsName = WindowsRegEnumKeyEx1(nativeHandle, i, - maxKeyLength+1); + maxKeyLength+1); if (windowsName == null) { String info = - "Could not enumerate key #" + i + " of windows node " + - byteArrayToString(windowsAbsolutePath()) + " at root 0x" + - Integer.toHexString(rootNativeHandle()) + ". "; + "Could not enumerate key #" + i + " of windows node " + + byteArrayToString(windowsAbsolutePath()) + " at root 0x" + + Integer.toHexString(rootNativeHandle()) + ". "; logger().warning(info); throw new BackingStoreException(info); } @@ -789,20 +802,24 @@ } if (!isBackingStoreAvailable) { throw new BackingStoreException( - "flush(): Backing store not available."); + "flush(): Backing store not available."); } int nativeHandle = openKey(KEY_READ); if (nativeHandle == NULL_NATIVE_HANDLE) { - throw new BackingStoreException("Could not open windows" - + "registry node " + byteArrayToString(windowsAbsolutePath()) + - " at root 0x" + Integer.toHexString(rootNativeHandle()) + "."); + throw new BackingStoreException( + "Could not open windows registry node " + + byteArrayToString(windowsAbsolutePath()) + + " at root 0x" + + Integer.toHexString(rootNativeHandle()) + "."); } int result = WindowsRegFlushKey1(nativeHandle); if (result != ERROR_SUCCESS) { - String info = "Could not flush windows " - + "registry node " + byteArrayToString(windowsAbsolutePath()) - + " at root 0x" + Integer.toHexString(rootNativeHandle()) + - ". Windows RegFlushKey(...) returned error code " + result + "."; + String info = "Could not flush windows registry node " + + byteArrayToString(windowsAbsolutePath()) + + " at root 0x" + + Integer.toHexString(rootNativeHandle()) + + ". Windows RegFlushKey(...) returned error code " + + result + "."; logger().warning(info); throw new BackingStoreException(info); } @@ -829,7 +846,7 @@ * Logs a warning message, if Windows Registry is unavailable. */ protected AbstractPreferences childSpi(String name) { - return new WindowsPreferences(this, name); + return new WindowsPreferences(this, name); } /** @@ -840,20 +857,22 @@ */ public void removeNodeSpi() throws BackingStoreException { int parentNativeHandle = - ((WindowsPreferences)parent()).openKey(DELETE); + ((WindowsPreferences)parent()).openKey(DELETE); if (parentNativeHandle == NULL_NATIVE_HANDLE) { - throw new BackingStoreException("Could not open parent windows" - + "registry node of " + byteArrayToString(windowsAbsolutePath()) + - " at root 0x" + Integer.toHexString(rootNativeHandle()) + "."); + throw new BackingStoreException( + "Could not open parent windows registry node of " + + byteArrayToString(windowsAbsolutePath()) + + " at root 0x" + + Integer.toHexString(rootNativeHandle()) + "."); } int result = WindowsRegDeleteKey(parentNativeHandle, toWindowsName(name())); if (result != ERROR_SUCCESS) { - String info = "Could not delete windows " - + "registry node " + byteArrayToString(windowsAbsolutePath()) + - " at root 0x" + Integer.toHexString(rootNativeHandle()) + - ". Windows RegDeleteKeyEx(...) returned error code " + - result + "."; + String info = "Could not delete windows registry node " + + byteArrayToString(windowsAbsolutePath()) + + " at root 0x" + Integer.toHexString(rootNativeHandle()) + + ". Windows RegDeleteKeyEx(...) returned error code " + + result + "."; logger().warning(info); throw new BackingStoreException(info); } @@ -870,23 +889,25 @@ private static String toJavaName(byte[] windowsNameArray) { String windowsName = byteArrayToString(windowsNameArray); // check if Alt64 - if ((windowsName.length()>1) && - (windowsName.substring(0,2).equals("/!"))) { + if ((windowsName.length() > 1) && + (windowsName.substring(0, 2).equals("/!"))) { return toJavaAlt64Name(windowsName); } - StringBuffer javaName = new StringBuffer(); + StringBuilder javaName = new StringBuilder(); char ch; // Decode from simple encoding - for (int i = 0; i < windowsName.length(); i++){ + for (int i = 0; i < windowsName.length(); i++) { if ((ch = windowsName.charAt(i)) == '/') { char next = ' '; if ((windowsName.length() > i + 1) && - ((next = windowsName.charAt(i+1)) >= 'A') && (next <= 'Z')) { - ch = next; - i++; - } else if ((windowsName.length() > i + 1) && (next == '/')) { - ch = '\\'; - i++; + ((next = windowsName.charAt(i+1)) >= 'A') && + (next <= 'Z')) { + ch = next; + i++; + } else if ((windowsName.length() > i + 1) && + (next == '/')) { + ch = '\\'; + i++; } } else if (ch == '\\') { ch = '/'; @@ -905,8 +926,8 @@ private static String toJavaAlt64Name(String windowsName) { byte[] byteBuffer = - Base64.altBase64ToByteArray(windowsName.substring(2)); - StringBuffer result = new StringBuffer(); + Base64.altBase64ToByteArray(windowsName.substring(2)); + StringBuilder result = new StringBuilder(); for (int i = 0; i < byteBuffer.length; i++) { int firstbyte = (byteBuffer[i++] & 0xff); int secondbyte = (byteBuffer[i] & 0xff); @@ -936,10 +957,10 @@ * Base64 class. */ private static byte[] toWindowsName(String javaName) { - StringBuffer windowsName = new StringBuffer(); + StringBuilder windowsName = new StringBuilder(); for (int i = 0; i < javaName.length(); i++) { - char ch =javaName.charAt(i); - if ((ch < 0x0020)||(ch > 0x007f)) { + char ch = javaName.charAt(i); + if ((ch < 0x0020) || (ch > 0x007f)) { // If a non-trivial character encountered, use altBase64 return toWindowsAlt64Name(javaName); } @@ -948,7 +969,7 @@ } else if (ch == '/') { windowsName.append('\\'); } else if ((ch >= 'A') && (ch <='Z')) { - windowsName.append("/" + ch); + windowsName.append('/').append(ch); } else { windowsName.append(ch); } @@ -967,13 +988,13 @@ // Convert to byte pairs int counter = 0; for (int i = 0; i < javaName.length();i++) { - int ch = javaName.charAt(i); - javaNameArray[counter++] = (byte)(ch >>> 8); - javaNameArray[counter++] = (byte)ch; + int ch = javaName.charAt(i); + javaNameArray[counter++] = (byte)(ch >>> 8); + javaNameArray[counter++] = (byte)ch; } - return stringToByteArray( - "/!" + Base64.byteArrayToAltBase64(javaNameArray)); + return stringToByteArray("/!" + + Base64.byteArrayToAltBase64(javaNameArray)); } /** @@ -985,30 +1006,31 @@ private static String toJavaValueString(byte[] windowsNameArray) { // Use modified native2ascii algorithm String windowsName = byteArrayToString(windowsNameArray); - StringBuffer javaName = new StringBuffer(); + StringBuilder javaName = new StringBuilder(); char ch; for (int i = 0; i < windowsName.length(); i++){ if ((ch = windowsName.charAt(i)) == '/') { char next = ' '; if (windowsName.length() > i + 1 && - (next = windowsName.charAt(i + 1)) == 'u') { - if (windowsName.length() < i + 6){ + (next = windowsName.charAt(i + 1)) == 'u') { + if (windowsName.length() < i + 6) { break; } else { - ch = (char)Integer.parseInt - (windowsName.substring(i + 2, i + 6), 16); + ch = (char)Integer.parseInt( + windowsName.substring(i + 2, i + 6), 16); i += 5; } } else if ((windowsName.length() > i + 1) && - ((windowsName.charAt(i+1)) >= 'A') && (next <= 'Z')) { - ch = next; - i++; - } else if ((windowsName.length() > i + 1) && - (next == '/')) { - ch = '\\'; - i++; + ((windowsName.charAt(i+1)) >= 'A') && + (next <= 'Z')) { + ch = next; + i++; + } else if ((windowsName.length() > i + 1) && + (next == '/')) { + ch = '\\'; + i++; } } else if (ch == '\\') { ch = '/'; @@ -1028,14 +1050,14 @@ * to convert java string to a byte array of ASCII characters. */ private static byte[] toWindowsValueString(String javaName) { - StringBuffer windowsName = new StringBuffer(); + StringBuilder windowsName = new StringBuilder(); for (int i = 0; i < javaName.length(); i++) { - char ch =javaName.charAt(i); - if ((ch < 0x0020)||(ch > 0x007f)){ + char ch = javaName.charAt(i); + if ((ch < 0x0020) || (ch > 0x007f)){ // write \udddd windowsName.append("/u"); String hex = Integer.toHexString(javaName.charAt(i)); - StringBuffer hex4 = new StringBuffer(hex); + StringBuilder hex4 = new StringBuilder(hex); hex4.reverse(); int len = 4 - hex4.length(); for (int j = 0; j < len; j++){ @@ -1049,7 +1071,7 @@ } else if (ch == '/') { windowsName.append('\\'); } else if ((ch >= 'A') && (ch <='Z')) { - windowsName.append("/" + ch); + windowsName.append('/').append(ch); } else { windowsName.append(ch); } @@ -1061,8 +1083,9 @@ * Returns native handle for the top Windows node for this node. */ private int rootNativeHandle() { - return (isUserNode()? USER_ROOT_NATIVE_HANDLE : - SYSTEM_ROOT_NATIVE_HANDLE); + return (isUserNode() + ? USER_ROOT_NATIVE_HANDLE + : SYSTEM_ROOT_NATIVE_HANDLE); } /** @@ -1081,7 +1104,7 @@ * Converts a null-terminated byte array to java string */ private static String byteArrayToString(byte[] array) { - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); for (int i = 0; i < array.length - 1; i++) { result.append((char)array[i]); } diff -r e5171238515c -r ec8f5229c8e9 src/windows/native/sun/java2d/d3d/D3DPipelineManager.cpp --- a/src/windows/native/sun/java2d/d3d/D3DPipelineManager.cpp Fri May 29 10:15:38 2015 -0700 +++ b/src/windows/native/sun/java2d/d3d/D3DPipelineManager.cpp Wed Jun 03 20:28:57 2015 -0700 @@ -828,7 +828,7 @@ return 0; } - HWND hWnd = CreateWindow(L"D3DFocusWindow", L"D3DFocusWindow", 0, + HWND hWnd = CreateWindow(L"D3DFocusWindow", L"D3DFocusWindow", WS_POPUP, mi.rcMonitor.left, mi.rcMonitor.top, 1, 1, NULL, NULL, GetModuleHandle(NULL), NULL); if (hWnd == 0) { diff -r e5171238515c -r ec8f5229c8e9 test/TEST.ROOT --- a/test/TEST.ROOT Fri May 29 10:15:38 2015 -0700 +++ b/test/TEST.ROOT Wed Jun 03 20:28:57 2015 -0700 @@ -8,7 +8,7 @@ othervm.dirs=java/awt java/beans java/rmi javax/accessibility javax/imageio javax/sound javax/print javax/management com/sun/awt sun/awt sun/java2d sun/pisces sun/rmi # Tests that cannot run concurrently -exclusiveAccess.dirs=java/rmi/Naming java/util/Currency java/util/prefs sun/management/jmxremote sun/tools/jstatd sun/security/mscapi +exclusiveAccess.dirs=java/rmi/Naming java/util/Currency java/util/prefs sun/management/jmxremote sun/tools/jstatd sun/security/mscapi javax/rmi # Group definitions groups=TEST.groups [closed/TEST.groups] diff -r e5171238515c -r ec8f5229c8e9 test/TEST.groups --- a/test/TEST.groups Fri May 29 10:15:38 2015 -0700 +++ b/test/TEST.groups Wed Jun 03 20:28:57 2015 -0700 @@ -111,7 +111,6 @@ jdk_rmi = \ java/rmi \ - javax/rmi/ssl \ sun/rmi jdk_security1 = \ @@ -195,6 +194,7 @@ jdk_other = \ java/sql \ javax/sql \ + javax/rmi \ javax/naming \ javax/script \ javax/smartcardio \ diff -r e5171238515c -r ec8f5229c8e9 test/java/awt/event/MouseWheelEvent/WheelModifier/WheelModifier.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/event/MouseWheelEvent/WheelModifier/WheelModifier.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + @bug 8041470 + @summary JButtons stay pressed after they have lost focus if you use the mouse wheel + @author Anton Nashatyrev +*/ +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +import java.util.concurrent.CountDownLatch; + +public class WheelModifier { + + JFrame f; + JButton fb; + + CountDownLatch pressSema = new CountDownLatch(1); + CountDownLatch exitSema = new CountDownLatch(1); + CountDownLatch releaseSema = new CountDownLatch(1); + volatile CountDownLatch wheelSema; + + void createGui() { + f = new JFrame("frame"); + fb = new JButton("frame_button"); + fb.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + System.out.println("WheelModifier.mouseReleased: " + e); + releaseSema.countDown(); + } + + @Override + public void mouseEntered(MouseEvent e) { + System.out.println("WheelModifier.mouseEntered: " + e); + + } + + @Override + public void mouseExited(MouseEvent e) { + System.out.println("WheelModifier.mouseExited: " + e); + exitSema.countDown(); + } + + @Override + public void mousePressed(MouseEvent e) { + System.out.println("WheelModifier.mousePressed: " + e); + pressSema.countDown(); + } + + @Override + public void mouseDragged(MouseEvent e) { + System.out.println("WheelModifier.mouseDragged: " + e); + } + }); + + Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { + @Override + public void eventDispatched(AWTEvent event) { + System.out.println("WheelModifier.mouseWheel: " + event); + wheelSema.countDown(); + } + }, MouseEvent.MOUSE_WHEEL_EVENT_MASK); + + f.setLayout(new FlowLayout()); + f.add(fb); + f.setSize(200, 200); + f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + f.setVisible(true); + } + + void run() throws Exception { + Robot r = new Robot(); + r.waitForIdle(); + System.out.println("# Started"); + + Point sLoc = fb.getLocationOnScreen(); + Dimension bSize = fb.getSize(); + r.mouseMove(sLoc.x + bSize.width / 2, sLoc.y + bSize.height / 2); + r.mousePress(MouseEvent.BUTTON1_MASK); + pressSema.await(); + System.out.println("# Pressed"); + + r.mouseMove(sLoc.x + bSize.width / 2, sLoc.y + bSize.height * 2); + exitSema.await(); + System.out.println("# Exited"); + + wheelSema = new CountDownLatch(1); + r.mouseWheel(1); + wheelSema.await(); + System.out.println("# Wheeled 1"); + + wheelSema = new CountDownLatch(1); + r.mouseWheel(-1); + wheelSema.await(); + System.out.println("# Wheeled 2"); + + r.mouseRelease(MouseEvent.BUTTON1_MASK); + releaseSema.await(); + System.out.println("# Released!"); + } + + public static void main(String[] args) throws Exception { + WheelModifier test = new WheelModifier(); + + SwingUtilities.invokeAndWait(() -> test.createGui()); + test.run(); + + System.out.println("Done."); + } +} diff -r e5171238515c -r ec8f5229c8e9 test/java/awt/geom/Path2D/Path2DCopyConstructor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/geom/Path2D/Path2DCopyConstructor.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,537 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +import java.awt.Rectangle; +import java.awt.geom.AffineTransform; +import java.awt.geom.GeneralPath; +import java.awt.geom.IllegalPathStateException; +import java.awt.geom.Path2D; +import java.awt.geom.PathIterator; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.util.Arrays; + +/** + * @test + * @bug 8076419 + * @summary Check Path2D copy constructor (trims arrays) + * and constructor with zero capacity + * @run main Path2DCopyConstructor + */ +public class Path2DCopyConstructor { + + private final static float EPSILON = 5e-6f; + private final static float FLATNESS = 1e-2f; + + private final static AffineTransform at + = AffineTransform.getScaleInstance(1.3, 2.4); + + private final static Rectangle2D.Double rect2d + = new Rectangle2D.Double(3.2, 4.1, 5.0, 10.0); + + private final static Point2D.Double pt2d + = new Point2D.Double(2.0, 2.5); + + public static boolean verbose; + + static void log(String msg) { + if (verbose) { + System.out.println(msg); + } + } + + public static void main(String argv[]) { + verbose = (argv.length != 0); + + testEmptyDoublePaths(); + testDoublePaths(); + + testEmptyFloatPaths(); + testFloatPaths(); + + testEmptyGeneralPath(); + testGeneralPath(); + } + + static void testEmptyDoublePaths() { + log("\n - Test(Path2D.Double[0]) ---"); + test(() -> new Path2D.Double(Path2D.WIND_NON_ZERO, 0)); + } + + static void testDoublePaths() { + log("\n - Test(Path2D.Double) ---"); + test(() -> new Path2D.Double()); + } + + static void testEmptyFloatPaths() { + log("\n - Test(Path2D.Float[0]) ---"); + test(() -> new Path2D.Float(Path2D.WIND_NON_ZERO, 0)); + } + + static void testFloatPaths() { + log("\n - Test(Path2D.Float) ---"); + test(() -> new Path2D.Float()); + } + + static void testEmptyGeneralPath() { + log("\n - Test(GeneralPath[0]) ---"); + test(() -> new GeneralPath(Path2D.WIND_NON_ZERO, 0)); + } + + static void testGeneralPath() { + log("\n - Test(GeneralPath) ---"); + test(() -> new GeneralPath()); + } + + interface PathFactory { + Path2D makePath(); + } + + static void test(PathFactory pf) { + log("\n --- test: path(empty) ---"); + test(pf.makePath(), true); + log("\n\n --- test: path(addMove) ---"); + test(addMove(pf.makePath()), false); + log("\n\n --- test: path(addMoveAndLines) ---"); + test(addMoveAndLines(pf.makePath()), false); + log("\n\n --- test: path(addMoveAndQuads) ---"); + test(addMoveAndQuads(pf.makePath()), false); + log("\n\n --- test: path(addMoveAndCubics) ---"); + test(addMoveAndCubics(pf.makePath()), false); + log("\n\n --- test: path(addMoveAndClose) ---"); + test(addMoveAndClose(pf.makePath()), false); + } + + static Path2D addMove(Path2D p2d) { + p2d.moveTo(1.0, 0.5); + return p2d; + } + + static Path2D addMoveAndLines(Path2D p2d) { + addMove(p2d); + addLines(p2d); + return p2d; + } + + static Path2D addLines(Path2D p2d) { + for (int i = 0; i < 10; i++) { + p2d.lineTo(1.1 * i, 2.3 * i); + } + return p2d; + } + + static Path2D addMoveAndCubics(Path2D p2d) { + addMove(p2d); + addCubics(p2d); + return p2d; + } + + static Path2D addCubics(Path2D p2d) { + for (int i = 0; i < 10; i++) { + p2d.curveTo(1.1 * i, 1.2 * i, 1.3 * i, 1.4 * i, 1.5 * i, 1.6 * i); + } + return p2d; + } + + static Path2D addMoveAndQuads(Path2D p2d) { + addMove(p2d); + addQuads(p2d); + return p2d; + } + + static Path2D addQuads(Path2D p2d) { + for (int i = 0; i < 10; i++) { + p2d.quadTo(1.1 * i, 1.2 * i, 1.3 * i, 1.4 * i); + } + return p2d; + } + + static Path2D addMoveAndClose(Path2D p2d) { + addMove(p2d); + addClose(p2d); + return p2d; + } + + static Path2D addClose(Path2D p2d) { + p2d.closePath(); + return p2d; + } + + static void test(Path2D p2d, boolean isEmpty) { + testEqual(new Path2D.Float(p2d), p2d); + testEqual(new Path2D.Double(p2d), p2d); + testEqual(new GeneralPath(p2d), p2d); + + testIterator(new Path2D.Float(p2d), p2d); + testIterator(new Path2D.Double(p2d), p2d); + testIterator((Path2D) p2d.clone(), p2d); + + testFlattening(new Path2D.Float(p2d), p2d); + testFlattening(new Path2D.Double(p2d), p2d); + testFlattening((Path2D) p2d.clone(), p2d); + + testAddMove(new Path2D.Float(p2d)); + testAddMove(new Path2D.Double(p2d)); + testAddMove((Path2D) p2d.clone()); + + // These should expect exception if empty + testAddLine(new Path2D.Float(p2d), isEmpty); + testAddLine(new Path2D.Double(p2d), isEmpty); + testAddLine((Path2D) p2d.clone(), isEmpty); + + testAddQuad(new Path2D.Float(p2d), isEmpty); + testAddQuad(new Path2D.Double(p2d), isEmpty); + testAddQuad((Path2D) p2d.clone(), isEmpty); + + testAddCubic(new Path2D.Float(p2d), isEmpty); + testAddCubic(new Path2D.Double(p2d), isEmpty); + testAddCubic((Path2D) p2d.clone(), isEmpty); + + testAddClose(new Path2D.Float(p2d), isEmpty); + testAddClose(new Path2D.Double(p2d), isEmpty); + testAddClose((Path2D) p2d.clone(), isEmpty); + + testGetBounds(new Path2D.Float(p2d), p2d); + testGetBounds(new Path2D.Double(p2d), p2d); + testGetBounds((Path2D) p2d.clone(), p2d); + + testTransform(new Path2D.Float(p2d)); + testTransform(new Path2D.Double(p2d)); + testTransform((Path2D) p2d.clone()); + + testIntersect(new Path2D.Float(p2d), p2d); + testIntersect(new Path2D.Double(p2d), p2d); + testIntersect((Path2D) p2d.clone(), p2d); + + testContains(new Path2D.Float(p2d), p2d); + testContains(new Path2D.Double(p2d), p2d); + testContains((Path2D) p2d.clone(), p2d); + + testGetCurrentPoint(new Path2D.Float(p2d), p2d); + testGetCurrentPoint(new Path2D.Double(p2d), p2d); + testGetCurrentPoint((Path2D) p2d.clone(), p2d); + } + + static void testEqual(Path2D pathA, Path2D pathB) { + final PathIterator itA = pathA.getPathIterator(null); + final PathIterator itB = pathB.getPathIterator(null); + + float[] coordsA = new float[6]; + float[] coordsB = new float[6]; + + int n = 0; + for (; !itA.isDone() && !itB.isDone(); itA.next(), itB.next(), n++) { + int typeA = itA.currentSegment(coordsA); + int typeB = itB.currentSegment(coordsB); + + if (typeA != typeB) { + throw new IllegalStateException("Path-segment[" + n + "] " + + " type are not equals [" + typeA + "|" + typeB + "] !"); + } + if (!equalsArray(coordsA, coordsB, getLength(typeA))) { + throw new IllegalStateException("Path-segment[" + n + "] coords" + + " are not equals [" + Arrays.toString(coordsA) + "|" + + Arrays.toString(coordsB) + "] !"); + } + } + if (!itA.isDone() || !itB.isDone()) { + throw new IllegalStateException("Paths do not have same lengths !"); + } + log("testEqual: " + n + " segments."); + } + + static void testIterator(Path2D pathA, Path2D pathB) { + final PathIterator itA = pathA.getPathIterator(at); + final PathIterator itB = pathB.getPathIterator(at); + + float[] coordsA = new float[6]; + float[] coordsB = new float[6]; + + int n = 0; + for (; !itA.isDone() && !itB.isDone(); itA.next(), itB.next(), n++) { + int typeA = itA.currentSegment(coordsA); + int typeB = itB.currentSegment(coordsB); + + if (typeA != typeB) { + throw new IllegalStateException("Path-segment[" + n + "] " + + "type are not equals [" + typeA + "|" + typeB + "] !"); + } + // Take care of floating-point precision: + if (!equalsArrayEps(coordsA, coordsB, getLength(typeA))) { + throw new IllegalStateException("Path-segment[" + n + "] coords" + + " are not equals [" + Arrays.toString(coordsA) + "|" + + Arrays.toString(coordsB) + "] !"); + } + } + if (!itA.isDone() || !itB.isDone()) { + throw new IllegalStateException("Paths do not have same lengths !"); + } + log("testIterator: " + n + " segments."); + } + + static void testFlattening(Path2D pathA, Path2D pathB) { + final PathIterator itA = pathA.getPathIterator(at, FLATNESS); + final PathIterator itB = pathB.getPathIterator(at, FLATNESS); + + float[] coordsA = new float[6]; + float[] coordsB = new float[6]; + + int n = 0; + for (; !itA.isDone() && !itB.isDone(); itA.next(), itB.next(), n++) { + int typeA = itA.currentSegment(coordsA); + int typeB = itB.currentSegment(coordsB); + + if (typeA != typeB) { + throw new IllegalStateException("Path-segment[" + n + "] " + + "type are not equals [" + typeA + "|" + typeB + "] !"); + } + // Take care of floating-point precision: + if (!equalsArrayEps(coordsA, coordsB, getLength(typeA))) { + throw new IllegalStateException("Path-segment[" + n + "] coords" + + " are not equals [" + Arrays.toString(coordsA) + "|" + + Arrays.toString(coordsB) + "] !"); + } + } + if (!itA.isDone() || !itB.isDone()) { + throw new IllegalStateException("Paths do not have same lengths !"); + } + log("testFlattening: " + n + " segments."); + } + + static void testAddMove(Path2D pathA) { + addMove(pathA); + log("testAddMove: passed."); + } + + static void testAddLine(Path2D pathA, boolean isEmpty) { + try { + addLines(pathA); + } + catch (IllegalPathStateException ipse) { + if (isEmpty) { + log("testAddLine: passed " + + "(expected IllegalPathStateException catched)."); + return; + } else { + throw ipse; + } + } + if (isEmpty) { + throw new IllegalStateException("IllegalPathStateException not thrown !"); + } + log("testAddLine: passed."); + } + + static void testAddQuad(Path2D pathA, boolean isEmpty) { + try { + addQuads(pathA); + } + catch (IllegalPathStateException ipse) { + if (isEmpty) { + log("testAddQuad: passed " + + "(expected IllegalPathStateException catched)."); + return; + } else { + throw ipse; + } + } + if (isEmpty) { + throw new IllegalStateException("IllegalPathStateException not thrown !"); + } + log("testAddQuad: passed."); + } + + static void testAddCubic(Path2D pathA, boolean isEmpty) { + try { + addCubics(pathA); + } + catch (IllegalPathStateException ipse) { + if (isEmpty) { + log("testAddCubic: passed " + + "(expected IllegalPathStateException catched)."); + return; + } else { + throw ipse; + } + } + if (isEmpty) { + throw new IllegalStateException("IllegalPathStateException not thrown !"); + } + log("testAddCubic: passed."); + } + + static void testAddClose(Path2D pathA, boolean isEmpty) { + try { + addClose(pathA); + } + catch (IllegalPathStateException ipse) { + if (isEmpty) { + log("testAddClose: passed " + + "(expected IllegalPathStateException catched)."); + return; + } else { + throw ipse; + } + } + if (isEmpty) { + throw new IllegalStateException("IllegalPathStateException not thrown !"); + } + log("testAddClose: passed."); + } + + static void testGetBounds(Path2D pathA, Path2D pathB) { + final Rectangle rA = pathA.getBounds(); + final Rectangle rB = pathB.getBounds(); + + if (!rA.equals(rB)) { + throw new IllegalStateException("Bounds are not equals [" + rA + + "|" + rB + "] !"); + } + final Rectangle2D r2dA = pathA.getBounds2D(); + final Rectangle2D r2dB = pathB.getBounds2D(); + + if (!equalsRectangle2D(r2dA, r2dB)) { + throw new IllegalStateException("Bounds2D are not equals [" + + r2dA + "|" + r2dB + "] !"); + } + log("testGetBounds: passed."); + } + + static void testTransform(Path2D pathA) { + pathA.transform(at); + log("testTransform: passed."); + } + + static void testIntersect(Path2D pathA, Path2D pathB) { + boolean resA = pathA.intersects(rect2d); + boolean resB = pathB.intersects(rect2d); + if (resA != resB) { + throw new IllegalStateException("Intersects(rect2d) are not equals [" + + resA + "|" + resB + "] !"); + } + resA = pathA.intersects(1.0, 2.0, 13.0, 17.0); + resB = pathB.intersects(1.0, 2.0, 13.0, 17.0); + if (resA != resB) { + throw new IllegalStateException("Intersects(doubles) are not equals [" + + resA + "|" + resB + "] !"); + } + log("testIntersect: passed."); + } + + static void testContains(Path2D pathA, Path2D pathB) { + boolean resA = pathA.contains(pt2d); + boolean resB = pathB.contains(pt2d); + if (resA != resB) { + throw new IllegalStateException("Contains(pt) are not equals [" + + resA + "|" + resB + "] !"); + } + resA = pathA.contains(pt2d.getX(), pt2d.getY()); + resB = pathB.contains(pt2d.getX(), pt2d.getY()); + if (resA != resB) { + throw new IllegalStateException("Contains(x,y) are not equals [" + + resA + "|" + resB + "] !"); + } + resA = pathA.contains(rect2d); + resB = pathB.contains(rect2d); + if (resA != resB) { + throw new IllegalStateException("Contains(rect2d) are not equals [" + + resA + "|" + resB + "] !"); + } + resA = pathA.contains(1.0, 2.0, 13.0, 17.0); + resB = pathB.contains(1.0, 2.0, 13.0, 17.0); + if (resA != resB) { + throw new IllegalStateException("Contains(doubles) are not equals [" + + resA + "|" + resB + "] !"); + } + log("testContains: passed."); + } + + static void testGetCurrentPoint(Path2D pathA, Path2D pathB) { + final Point2D ptA = pathA.getCurrentPoint(); + final Point2D ptB = pathA.getCurrentPoint(); + if (((ptA == null) && (ptB != null)) + || ((ptA != null) && !ptA.equals(ptB))) + { + throw new IllegalStateException("getCurrentPoint() are not equals [" + + ptA + "|" + ptB + "] !"); + } + log("testGetCurrentPoint: passed."); + } + + static int getLength(int type) { + switch(type) { + case PathIterator.SEG_CUBICTO: + return 6; + case PathIterator.SEG_QUADTO: + return 4; + case PathIterator.SEG_LINETO: + case PathIterator.SEG_MOVETO: + return 2; + case PathIterator.SEG_CLOSE: + return 0; + default: + throw new IllegalStateException("Invalid type: " + type); + } + } + + + // Custom equals methods --- + + public static boolean equalsArray(float[] a, float[] a2, final int len) { + for (int i = 0; i < len; i++) { + if (Float.floatToIntBits(a[i]) != Float.floatToIntBits(a2[i])) { + return false; + } + } + return true; + } + + static boolean equalsArrayEps(float[] a, float[] a2, final int len) { + for (int i = 0; i < len; i++) { + if (!equalsEps(a[i], a2[i])) { + return false; + } + } + + return true; + } + + static boolean equalsRectangle2D(Rectangle2D a, Rectangle2D b) { + if (a == b) { + return true; + } + return equalsEps(a.getX(), b.getX()) + && equalsEps(a.getY(), b.getY()) + && equalsEps(a.getWidth(), b.getWidth()) + && equalsEps(a.getHeight(), b.getHeight()); + } + + static boolean equalsEps(float a, float b) { + return (Math.abs(a - b) <= EPSILON); + } + + static boolean equalsEps(double a, double b) { + return (Math.abs(a - b) <= EPSILON); + } +} diff -r e5171238515c -r ec8f5229c8e9 test/java/awt/geom/Path2D/Path2DGrow.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/geom/Path2D/Path2DGrow.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,188 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.geom.GeneralPath; +import java.awt.geom.Path2D; + +/** + * @test + * @bug 8078464 + * @summary Check the growth algorithm (needRoom) in Path2D implementations + * @run main Path2DGrow + */ +public class Path2DGrow { + + public static final int N = 1000 * 1000; + + public static boolean verbose = false; + public static boolean force = false; + + static void echo(String msg) { + System.out.println(msg); + } + + static void log(String msg) { + if (verbose || force) { + echo(msg); + } + } + + public static void main(String argv[]) { + verbose = (argv.length != 0); + + testEmptyDoublePaths(); + testDoublePaths(); + + testEmptyFloatPaths(); + testFloatPaths(); + + testEmptyGeneralPath(); + testGeneralPath(); + } + + static void testEmptyDoublePaths() { + echo("\n - Test(Path2D.Double[0]) ---"); + test(() -> new Path2D.Double(Path2D.WIND_NON_ZERO, 0)); + } + + static void testDoublePaths() { + echo("\n - Test(Path2D.Double) ---"); + test(() -> new Path2D.Double()); + } + + static void testEmptyFloatPaths() { + echo("\n - Test(Path2D.Float[0]) ---"); + test(() -> new Path2D.Float(Path2D.WIND_NON_ZERO, 0)); + } + + static void testFloatPaths() { + echo("\n - Test(Path2D.Float) ---"); + test(() -> new Path2D.Float()); + } + + static void testEmptyGeneralPath() { + echo("\n - Test(GeneralPath[0]) ---"); + test(() -> new GeneralPath(Path2D.WIND_NON_ZERO, 0)); + } + + static void testGeneralPath() { + echo("\n - Test(GeneralPath) ---"); + test(() -> new GeneralPath()); + } + + interface PathFactory { + Path2D makePath(); + } + + static void test(PathFactory pf) { + long start, end; + + for (int n = 1; n <= N; n *= 10) { + force = (n == N); + + start = System.nanoTime(); + testAddMoves(pf.makePath(), n); + end = System.nanoTime(); + log("testAddMoves[" + n + "] duration= " + + (1e-6 * (end - start)) + " ms."); + + start = System.nanoTime(); + testAddLines(pf.makePath(), n); + end = System.nanoTime(); + log("testAddLines[" + n + "] duration= " + + (1e-6 * (end - start)) + " ms."); + + start = System.nanoTime(); + testAddQuads(pf.makePath(), n); + end = System.nanoTime(); + log("testAddQuads[" + n + "] duration= " + + (1e-6 * (end - start)) + " ms."); + + start = System.nanoTime(); + testAddCubics(pf.makePath(), n); + end = System.nanoTime(); + log("testAddCubics[" + n + "] duration= " + + (1e-6 * (end - start)) + " ms."); + + start = System.nanoTime(); + testAddMoveAndCloses(pf.makePath(), n); + end = System.nanoTime(); + log("testAddMoveAndCloses[" + n + "] duration= " + + (1e-6 * (end - start)) + " ms."); + } + } + + static void addMove(Path2D p2d, int i) { + p2d.moveTo(1.0 * i, 0.5 * i); + } + + static void addLine(Path2D p2d, int i) { + p2d.lineTo(1.1 * i, 2.3 * i); + } + + static void addCubic(Path2D p2d, int i) { + p2d.curveTo(1.1 * i, 1.2 * i, 1.3 * i, 1.4 * i, 1.5 * i, 1.6 * i); + } + + static void addQuad(Path2D p2d, int i) { + p2d.quadTo(1.1 * i, 1.2 * i, 1.3 * i, 1.4 * i); + } + + static void addClose(Path2D p2d) { + p2d.closePath(); + } + + static void testAddMoves(Path2D pathA, int n) { + for (int i = 0; i < n; i++) { + addMove(pathA, i); + } + } + + static void testAddLines(Path2D pathA, int n) { + addMove(pathA, 0); + for (int i = 0; i < n; i++) { + addLine(pathA, i); + } + } + + static void testAddQuads(Path2D pathA, int n) { + addMove(pathA, 0); + for (int i = 0; i < n; i++) { + addQuad(pathA, i); + } + } + + static void testAddCubics(Path2D pathA, int n) { + addMove(pathA, 0); + for (int i = 0; i < n; i++) { + addCubic(pathA, i); + } + } + + static void testAddMoveAndCloses(Path2D pathA, int n) { + for (int i = 0; i < n; i++) { + addMove(pathA, i); + addClose(pathA); + } + } +} diff -r e5171238515c -r ec8f5229c8e9 test/java/security/KeyStore/TestKeystoreCompat.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/security/KeyStore/TestKeystoreCompat.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,235 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8062552 + * @run main/othervm TestKeystoreCompat + * @summary test compatibility mode for JKS and PKCS12 keystores + */ + +import java.io.*; +import java.security.*; +import java.security.KeyStore.*; +import java.security.cert.*; +import javax.crypto.*; +import javax.security.auth.callback.*; + +public class TestKeystoreCompat { + private static final char[] PASSWORD = "changeit".toCharArray(); + private static final String DIR = System.getProperty("test.src", "."); + // This is an arbitrary X.509 certificate + private static final String CERT_FILE = "trusted.pem"; + + public static final void main(String[] args) throws Exception { + + // Testing empty keystores + + init("empty.jks", "JKS"); + init("empty.jceks", "JCEKS"); + init("empty.p12", "PKCS12"); + + load("empty.jks", "JKS"); + load("empty.jceks", "JCEKS"); + load("empty.p12", "PKCS12"); + load("empty.p12", "JKS"); // test compatibility mode + load("empty.jks", "PKCS12", true); // test without compatibility mode + load("empty.jks", "JKS", false); // test without compatibility mode + load("empty.p12", "JKS", true); // test without compatibility mode + load("empty.p12", "PKCS12", false); // test without compatibility mode + + build("empty.jks", "JKS", true); + build("empty.jks", "JKS", false); + build("empty.jceks", "JCEKS", true); + build("empty.jceks", "JCEKS", false); + build("empty.p12", "PKCS12", true); + build("empty.p12", "PKCS12", false); + + // Testing keystores containing an X.509 certificate + + X509Certificate cert = loadCertificate(CERT_FILE); + init("onecert.jks", "JKS", cert); + init("onecert.jceks", "JCEKS", cert); + init("onecert.p12", "PKCS12", cert); + + load("onecert.jks", "JKS"); + load("onecert.jceks", "JCEKS"); + load("onecert.p12", "PKCS12"); + load("onecert.p12", "JKS"); // test compatibility mode + load("onecert.jks", "PKCS12", true); // test without compatibility mode + load("onecert.jks", "JKS", false); // test without compatibility mode + load("onecert.p12", "JKS", true); // test without compatibility mode + load("onecert.p12", "PKCS12", false); // test without compatibility mode + + build("onecert.jks", "JKS", true); + build("onecert.jks", "JKS", false); + build("onecert.jceks", "JCEKS", true); + build("onecert.jceks", "JCEKS", false); + build("onecert.p12", "PKCS12", true); + build("onecert.p12", "PKCS12", false); + + // Testing keystores containing a secret key + + SecretKey key = generateSecretKey("AES", 128); + init("onekey.jceks", "JCEKS", key); + init("onekey.p12", "PKCS12", key); + + load("onekey.jceks", "JCEKS"); + load("onekey.p12", "PKCS12"); + load("onekey.p12", "JKS"); // test compatibility mode + load("onekey.p12", "JKS", true); // test without compatibility mode + load("onekey.p12", "PKCS12", false); // test without compatibility mode + + build("onekey.jceks", "JCEKS", true); + build("onekey.jceks", "JCEKS", false); + build("onekey.p12", "PKCS12", true); + build("onekey.p12", "PKCS12", false); + + System.out.println("OK."); + } + + // Instantiate an empty keystore using the supplied keystore type + private static void init(String file, String type) throws Exception { + KeyStore ks = KeyStore.getInstance(type); + ks.load(null, null); + try (OutputStream stream = new FileOutputStream(file)) { + ks.store(stream, PASSWORD); + } + System.out.println("Created a " + type + " keystore named '" + file + "'"); + } + + // Instantiate a keystore using the supplied keystore type & create an entry + private static void init(String file, String type, X509Certificate cert) + throws Exception { + KeyStore ks = KeyStore.getInstance(type); + ks.load(null, null); + ks.setEntry("mycert", new KeyStore.TrustedCertificateEntry(cert), null); + try (OutputStream stream = new FileOutputStream(file)) { + ks.store(stream, PASSWORD); + } + System.out.println("Created a " + type + " keystore named '" + file + "'"); + } + + // Instantiate a keystore using the supplied keystore type & create an entry + private static void init(String file, String type, SecretKey key) + throws Exception { + KeyStore ks = KeyStore.getInstance(type); + ks.load(null, null); + ks.setEntry("mykey", new KeyStore.SecretKeyEntry(key), + new PasswordProtection(PASSWORD)); + try (OutputStream stream = new FileOutputStream(file)) { + ks.store(stream, PASSWORD); + } + System.out.println("Created a " + type + " keystore named '" + file + "'"); + } + + // Instantiate a keystore by probing the supplied file for the keystore type + private static void build(String file, String type, boolean usePassword) + throws Exception { + + Builder builder; + if (usePassword) { + builder = Builder.newInstance(type, null, new File(file), + new PasswordProtection(PASSWORD)); + } else { + builder = Builder.newInstance(type, null, new File(file), + new CallbackHandlerProtection(new DummyHandler())); + } + KeyStore ks = builder.getKeyStore(); + if (!type.equalsIgnoreCase(ks.getType())) { + throw new Exception("ERROR: expected a " + type + " keystore, " + + "got a " + ks.getType() + " keystore instead"); + } else { + System.out.println("Built a " + type + " keystore named '" + file + "'"); + } + } + + // Load the keystore entries + private static void load(String file, String type) throws Exception { + KeyStore ks = KeyStore.getInstance(type); + try (InputStream stream = new FileInputStream(file)) { + ks.load(stream, PASSWORD); + } + if (!type.equalsIgnoreCase(ks.getType())) { + throw new Exception("ERROR: expected a " + type + " keystore, " + + "got a " + ks.getType() + " keystore instead"); + } else { + System.out.println("Loaded a " + type + " keystore named '" + file + "'"); + } + } + + // Load the keystore entries (with compatibility mode disabled) + private static void load(String file, String type, boolean expectFailure) + throws Exception { + Security.setProperty("keystore.type.compat", "false"); + try { + load(file, type); + if (expectFailure) { + throw new Exception("ERROR: expected load to fail but it didn't"); + } + } catch (IOException e) { + if (expectFailure) { + System.out.println("Failed to load a " + type + " keystore named '" + file + "' (as expected)"); + } else { + throw e; + } + } finally { + Security.setProperty("keystore.type.compat", "true"); + } + } + + // Read an X.509 certificate from the supplied file + private static X509Certificate loadCertificate(String certFile) + throws Exception { + X509Certificate cert = null; + try (FileInputStream certStream = + new FileInputStream(DIR + "/" + certFile)) { + CertificateFactory factory = + CertificateFactory.getInstance("X.509"); + return (X509Certificate) factory.generateCertificate(certStream); + } + } + + // Generate a secret key using the supplied algorithm name and key size + private static SecretKey generateSecretKey(String algorithm, int size) + throws NoSuchAlgorithmException { + KeyGenerator generator = KeyGenerator.getInstance(algorithm); + generator.init(size); + return generator.generateKey(); + } + + private static class DummyHandler implements CallbackHandler { + public void handle(Callback[] callbacks) + throws IOException, UnsupportedCallbackException { + System.out.println("** Callbackhandler invoked"); + for (int i = 0; i < callbacks.length; i++) { + Callback cb = callbacks[i]; + if (cb instanceof PasswordCallback) { + PasswordCallback pcb = (PasswordCallback)cb; + pcb.setPassword(PASSWORD); + break; + } + } + } + } +} diff -r e5171238515c -r ec8f5229c8e9 test/java/security/KeyStore/trusted.pem --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/security/KeyStore/trusted.pem Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,29 @@ +-----BEGIN CERTIFICATE----- +MIIF5DCCBMygAwIBAgIQGVCD3zqdD1ZMZZ/zLAPnQzANBgkqhkiG9w0BAQUFADCBvDELMAkGA1UE +BhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBO +ZXR3b3JrMTswOQYDVQQLEzJUZXJtcyBvZiB1c2UgYXQgaHR0cHM6Ly93d3cudmVyaXNpZ24uY29t +L3JwYSAoYykxMDE2MDQGA1UEAxMtVmVyaVNpZ24gQ2xhc3MgMyBJbnRlcm5hdGlvbmFsIFNlcnZl +ciBDQSAtIEczMB4XDTEyMDcxMDAwMDAwMFoXDTEzMDczMTIzNTk1OVowgbgxCzAJBgNVBAYTAlVT +MRMwEQYDVQQIEwpDYWxpZm9ybmlhMRcwFQYDVQQHFA5SZWR3b29kIFNob3JlczEbMBkGA1UEChQS +T3JhY2xlIENvcnBvcmF0aW9uMRIwEAYDVQQLFAlHbG9iYWwgSVQxMzAxBgNVBAsUKlRlcm1zIG9m +IHVzZSBhdCB3d3cudmVyaXNpZ24uY29tL3JwYSAoYykwNTEVMBMGA1UEAxQMKi5vcmFjbGUuY29t +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz/dOCGrWzPj62q0ZkF59Oj9Fli4wHAuX +U4/S0yBXF8j6K7TKWFTQkGZt3+08KUhmLm1CE1DbbyRJT292YNXYXunNaKdABob8kaBO/NESUOEJ +0SZh7fd0xCSJAAPiwOMrM5jLeb/dEpU6nP74Afrhu5ffvKdcvTRGguj9H2oVsisTK8Z1HsiiwcJG +JXcrjvdCZoPU4FHvK03XZPAqPHKNSaJOrux6kRIWYjQMlmL+qDOb0nNHa6gBdi+VqqJHJHeAM677 +dcUd0jn2m2OWtUnrM3MJZQof7/z27RTdX5J8np0ChkUgm63biDgRZO7uZP0DARQ0I6lZMlrarT8/ +sct3twIDAQABo4IB4jCCAd4wFwYDVR0RBBAwDoIMKi5vcmFjbGUuY29tMAkGA1UdEwQCMAAwCwYD +VR0PBAQDAgWgMEQGA1UdIAQ9MDswOQYLYIZIAYb4RQEHFwMwKjAoBggrBgEFBQcCARYcaHR0cHM6 +Ly93d3cudmVyaXNpZ24uY29tL3JwYTAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwbgYI +KwYBBQUHAQwEYjBgoV6gXDBaMFgwVhYJaW1hZ2UvZ2lmMCEwHzAHBgUrDgMCGgQUS2u5KJYGDLvQ +UjibKaxLB4shBRgwJhYkaHR0cDovL2xvZ28udmVyaXNpZ24uY29tL3ZzbG9nbzEuZ2lmMHIGCCsG +AQUFBwEBBGYwZDAkBggrBgEFBQcwAYYYaHR0cDovL29jc3AudmVyaXNpZ24uY29tMDwGCCsGAQUF +BzAChjBodHRwOi8vc3ZyaW50bC1nMy1haWEudmVyaXNpZ24uY29tL1NWUkludGxHMy5jZXIwQQYD +VR0fBDowODA2oDSgMoYwaHR0cDovL3N2cmludGwtZzMtY3JsLnZlcmlzaWduLmNvbS9TVlJJbnRs +RzMuY3JsMB8GA1UdIwQYMBaAFNebfNgioBX33a1fzimbWMO8RgC1MA0GCSqGSIb3DQEBBQUAA4IB +AQAITRBlEo+qXLwCL53Db2BGnhDgnSomjne8aCmU7Yt4Kp91tzJdhNuaC/wwDuzD2dPJqzemae3s +wKiOXrmDQZDj9NNTdkrXHnCvDR4TpOynWe3zBa0bwKnV2cIRKcv482yV53u0kALyFZbagYPwOOz3 +YJA/2SqdcDn9Ztc/ABQ1SkyXyA5j4LJdf2g7BtYrFxjy0RG6We2iM781WSB/9MCNKyHgiwd3KpLf +urdSKLzy1elNAyt1P3UHwBIIvZ6sJIr/eeELc54Lxt6PtQCXx8qwxYTYXWPXbLgKBHdebgrmAbPK +TfD69wysvjk6vwSHjmvaqB4R4WRcgkuT+1gxx+ve +-----END CERTIFICATE----- diff -r e5171238515c -r ec8f5229c8e9 test/java/time/TEST.properties --- a/test/java/time/TEST.properties Fri May 29 10:15:38 2015 -0700 +++ b/test/java/time/TEST.properties Wed Jun 03 20:28:57 2015 -0700 @@ -1,3 +1,4 @@ # Threeten test uses TestNG TestNG.dirs = . othervm.dirs = tck/java/time/chrono test/java/time/chrono test/java/time/format +lib.dirs = ../../lib/testlibrary diff -r e5171238515c -r ec8f5229c8e9 test/java/time/test/java/time/format/TestZoneTextPrinterParser.java --- a/test/java/time/test/java/time/format/TestZoneTextPrinterParser.java Fri May 29 10:15:38 2015 -0700 +++ b/test/java/time/test/java/time/format/TestZoneTextPrinterParser.java Wed Jun 03 20:28:57 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,10 +42,17 @@ import java.util.Random; import java.util.Set; import java.util.TimeZone; +import jdk.testlibrary.RandomFactory; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; +/* + * @test + * @bug 8081022 + * @key randomness + */ + /** * Test ZoneTextPrinterParser */ @@ -59,8 +66,8 @@ } public void test_printText() { - Random r = new Random(); - int N = 50; + Random r = RandomFactory.getRandom(); + int N = 8; Locale[] locales = Locale.getAvailableLocales(); Set zids = ZoneRulesProvider.getAvailableZoneIds(); ZonedDateTime zdt = ZonedDateTime.now(); diff -r e5171238515c -r ec8f5229c8e9 test/javax/rmi/PortableRemoteObject/ConcurrentHashMapTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/rmi/PortableRemoteObject/ConcurrentHashMapTest.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8068721 + * @summary test RMI-IIOP call with ConcurrentHashMap as an argument + * @library /lib/testlibrary + * @build jdk.testlibrary.* + * @build Test HelloInterface HelloServer HelloClient HelloImpl _HelloImpl_Tie _HelloInterface_Stub ConcurrentHashMapTest + * @run main/othervm -Djava.naming.provider.url=iiop://localhost:1050 -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory ConcurrentHashMapTest + */ + + +import java.io.DataInputStream; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.CountDownLatch; +import jdk.testlibrary.JDKToolFinder; +import jdk.testlibrary.JDKToolLauncher; + +public class ConcurrentHashMapTest { + + static final String ORBD = JDKToolFinder.getTestJDKTool("orbd"); + static final String JAVA = JDKToolFinder.getTestJDKTool("java"); + static final JDKToolLauncher orbdLauncher = JDKToolLauncher.createUsingTestJDK("orbd"); + static final String CLASSPATH = System.getProperty("java.class.path"); + static final int FIVE_SECONDS = 5000; + + private static Exception clientException; + private static boolean exceptionInClient; + private static Process orbdProcess; + private static Process rmiServerProcess; + + public static void main(String[] args) throws Exception { + startTestComponents(); + stopTestComponents(); + System.err.println("Test completed OK "); + } + + static void startTestComponents () throws Exception { + startOrbd(); + Thread.sleep(FIVE_SECONDS); + startRmiIiopServer(); + Thread.sleep(FIVE_SECONDS); + executeRmiIiopClient(); + } + + private static void stopTestComponents() throws Exception { + stopRmiIiopServer(); + stopOrbd(); + if (exceptionInClient) { + throw new RuntimeException(clientException); + } else if (!isResponseReceived()) { + throw new RuntimeException("Expected Response not received"); + } + } + + static void startOrbd() throws Exception { + System.out.println("\nStarting orbd on port 1050 "); + + //orbd -ORBInitialHost localhost -ORBInitialPort 1050 + orbdLauncher.addToolArg("-ORBInitialHost").addToolArg("localhost") + .addToolArg("-ORBInitialPort").addToolArg("1050"); + + System.out.println("ConcurrentHashMapTest: Executing: " + Arrays.asList(orbdLauncher.getCommand())); + ProcessBuilder pb = new ProcessBuilder(orbdLauncher.getCommand()); + pb.redirectError(ProcessBuilder.Redirect.INHERIT); + orbdProcess = pb.start(); + } + + + static void startRmiIiopServer() throws Exception { + System.out.println("\nStarting RmiServer"); + // java -cp . + // -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory + // -Djava.naming.provider.url=iiop://localhost:1050 HelloServer + List commands = new ArrayList<>(); + commands.add(ConcurrentHashMapTest.JAVA); + commands.add("-Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory"); + commands.add("-Djava.naming.provider.url=iiop://localhost:1050"); + commands.add("-cp"); + commands.add(ConcurrentHashMapTest.CLASSPATH); + commands.add("HelloServer"); + + System.out.println("ConcurrentHashMapTest: Executing: " + commands); + ProcessBuilder pb = new ProcessBuilder(commands); + pb.redirectError(ProcessBuilder.Redirect.INHERIT); + rmiServerProcess = pb.start(); + } + + static boolean isResponseReceived() { + return HelloClient.isResponseReceived(); + } + + static void stopRmiIiopServer() throws Exception { + rmiServerProcess.destroy(); + rmiServerProcess.waitFor(); + //rmiServerProcess.waitFor(30, TimeUnit.SECONDS); + System.out.println("serverProcess exitCode:" + + rmiServerProcess.exitValue()); + } + + static void stopOrbd() throws Exception { + orbdProcess.destroy(); + orbdProcess.waitFor(); + //orbdProcess.waitFor(30, TimeUnit.SECONDS); + System.out.println("orbd exitCode:" + + orbdProcess.exitValue()); + } + + static void executeRmiIiopClient() throws Exception { + try { + HelloClient.executeRmiClientCall(); + } catch (Exception ex) { + clientException = ex; + exceptionInClient = true; + } + } +} diff -r e5171238515c -r ec8f5229c8e9 test/javax/rmi/PortableRemoteObject/HelloClient.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/rmi/PortableRemoteObject/HelloClient.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,98 @@ +import java.rmi.RemoteException; +import java.net.InetAddress; +import java.net.MalformedURLException; +import java.rmi.NotBoundException; +import java.util.HashMap; +import java.util.Vector; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.locks.ReentrantLock; + +import javax.naming.NamingException; +import javax.naming.InitialContext; +import javax.naming.Context; +import javax.naming.NameNotFoundException; +import javax.naming.NamingException; +import javax.rmi.PortableRemoteObject; + +import org.omg.CORBA.Any; +import org.omg.CORBA.ORB; + +public class HelloClient implements Runnable { + static final int MAX_RETRY = 10; + static final int ONE_SECOND = 1000; + private static boolean responseReceived; + + public static void main(String args[]) throws Exception { + executeRmiClientCall(); + } + + @Override + public void run() { + try { + executeRmiClientCall(); + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException(e); + } + } + + + public static boolean isResponseReceived () { + return responseReceived; + } + + public static void executeRmiClientCall() throws Exception { + Context ic; + Object objref; + HelloInterface helloSvc; + String response; + int retryCount = 0; + + Test test = new Test(); + System.out.println("HelloClient.main: enter ..."); + while (retryCount < MAX_RETRY) { + try { + ic = new InitialContext(); + System.out.println("HelloClient.main: HelloService lookup ..."); + // STEP 1: Get the Object reference from the Name Service + // using JNDI call. + objref = ic.lookup("HelloService"); + System.out.println("HelloClient: Obtained a ref. to Hello server."); + + // STEP 2: Narrow the object reference to the concrete type and + // invoke the method. + helloSvc = (HelloInterface) PortableRemoteObject.narrow(objref, + HelloInterface.class); + System.out.println("HelloClient: Invoking on remote server with ConcurrentHashMap parameter"); + ConcurrentHashMap testConcurrentHashMap = new ConcurrentHashMap(); + response = helloSvc.sayHelloWithHashMap(testConcurrentHashMap); + System.out.println("HelloClient: Server says: " + response); + if (!response.contains("Hello with hashMapSize ==")) { + System.out.println("HelloClient: expected response not received"); + throw new RuntimeException("Expected Response Hello with hashMapSize == 0 not received"); + } + responseReceived = true; + break; + } catch (NameNotFoundException nnfEx) { + System.err.println("NameNotFoundException Caught .... try again"); + retryCount++; + try { + Thread.sleep(ONE_SECOND); + } catch (InterruptedException e) { + e.printStackTrace(); + } + continue; + } catch (Exception e) { + System.err.println("Exception " + e + "Caught"); + e.printStackTrace(); + throw new RuntimeException(e); + } + } + System.err.println("HelloClient terminating "); + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } +} diff -r e5171238515c -r ec8f5229c8e9 test/javax/rmi/PortableRemoteObject/HelloImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/rmi/PortableRemoteObject/HelloImpl.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,60 @@ +import java.net.InetAddress; +import java.rmi.RemoteException; +import java.util.HashMap; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.locks.ReentrantLock; + +import javax.rmi.PortableRemoteObject; + +public class HelloImpl extends PortableRemoteObject implements HelloInterface { + public HelloImpl() throws java.rmi.RemoteException { + super(); // invoke rmi linking and remote object initialization + } + + public String sayHello(String from) throws java.rmi.RemoteException { + System.out.println("Hello from " + from + "!!"); + System.out.flush(); + String reply = "Hello from us to you " + from; + return reply; + } + + @Override + public String sayHelloToTest(Test test) throws RemoteException { + return "Test says Hello"; + } + + @Override + public String sayHelloWithInetAddress(InetAddress ipAddr) + throws RemoteException { + String response = "Hello with InetAddress " + ipAddr.toString(); + return response; + } + + @Override + public String sayHelloWithHashMap(ConcurrentHashMap receivedHashMap) + throws RemoteException { + int hashMapSize = 0; + + hashMapSize = receivedHashMap.size(); + String response = "Hello with hashMapSize == " + hashMapSize; + return response; + } + + @Override + public String sayHelloWithHashMap2(HashMap receivedHashMap) + throws RemoteException { + int hashMapSize = 0; + + hashMapSize = receivedHashMap.size(); + String response = "Hello with hashMapSize == " + hashMapSize; + return response; + } + + @Override + public String sayHelloWithReentrantLock(ReentrantLock receivedLock) + throws RemoteException { + + String response = "Hello with lock == " + receivedLock.isLocked(); + return response; + } +} diff -r e5171238515c -r ec8f5229c8e9 test/javax/rmi/PortableRemoteObject/HelloInterface.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/rmi/PortableRemoteObject/HelloInterface.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,14 @@ +import java.net.InetAddress; +import java.rmi.Remote; +import java.util.HashMap; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.locks.ReentrantLock; + +public interface HelloInterface extends Remote { + public String sayHello( String from ) throws java.rmi.RemoteException; + public String sayHelloToTest( Test test ) throws java.rmi.RemoteException; + public String sayHelloWithInetAddress( InetAddress ipAddr ) throws java.rmi.RemoteException; + public String sayHelloWithHashMap(ConcurrentHashMap hashMap ) throws java.rmi.RemoteException; + public String sayHelloWithHashMap2(HashMap hashMap ) throws java.rmi.RemoteException; + public String sayHelloWithReentrantLock(ReentrantLock lock ) throws java.rmi.RemoteException; +} diff -r e5171238515c -r ec8f5229c8e9 test/javax/rmi/PortableRemoteObject/HelloServer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/rmi/PortableRemoteObject/HelloServer.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,36 @@ +import javax.naming.InitialContext; +import javax.naming.Context; + +public class HelloServer { + + static final int MAX_RETRY = 10; + static final int ONE_SECOND = 1000; + + public static void main(String[] args) { + int retryCount = 0; + while (retryCount < MAX_RETRY) { + try { + //HelloServer.set("SETTING TEST ITL"); + // Step 1: Instantiate the Hello servant + HelloImpl helloRef = new HelloImpl(); + + // Step 2: Publish the reference in the Naming Service + // using JNDI API + Context initialNamingContext = new InitialContext(); + initialNamingContext.rebind("HelloService", helloRef); + + System.out.println("Hello Server: Ready..."); + break; + } catch (Exception e) { + System.out.println("Server initialization problem: " + e); + e.printStackTrace(); + retryCount++; + try { + Thread.sleep(ONE_SECOND); + } catch (InterruptedException e1) { + e1.printStackTrace(); + } + } + } + } +} diff -r e5171238515c -r ec8f5229c8e9 test/javax/rmi/PortableRemoteObject/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/rmi/PortableRemoteObject/Test.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,6 @@ +import java.io.Serializable; + + +public class Test implements Serializable { + +} diff -r e5171238515c -r ec8f5229c8e9 test/javax/rmi/PortableRemoteObject/_HelloImpl_Tie.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/rmi/PortableRemoteObject/_HelloImpl_Tie.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,128 @@ +// Tie class generated by rmic, do not edit. +// Contents subject to change without notice. + +import java.io.Serializable; +import java.net.InetAddress; +import java.rmi.Remote; +import java.rmi.RemoteException; +import java.util.HashMap; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.locks.ReentrantLock; +import javax.rmi.CORBA.Tie; +import javax.rmi.CORBA.Util; +import org.omg.CORBA.BAD_OPERATION; +import org.omg.CORBA.ORB; +import org.omg.CORBA.SystemException; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.OutputStream; +import org.omg.CORBA.portable.ResponseHandler; +import org.omg.CORBA.portable.UnknownException; +import org.omg.CORBA_2_3.portable.ObjectImpl; + + +public class _HelloImpl_Tie extends ObjectImpl implements Tie { + + private HelloImpl target = null; + + private static final String[] _type_ids = { + "RMI:HelloInterface:0000000000000000" + }; + + public void setTarget(Remote target) { + this.target = (HelloImpl) target; + } + + public Remote getTarget() { + return target; + } + + public org.omg.CORBA.Object thisObject() { + return this; + } + + public void deactivate() { + _orb().disconnect(this); + _set_delegate(null); + target = null; + } + + public ORB orb() { + return _orb(); + } + + public void orb(ORB orb) { + orb.connect(this); + } + + public String[] _ids() { + return (String[]) _type_ids.clone(); + } + + public OutputStream _invoke(String method, InputStream _in, ResponseHandler reply) throws SystemException { + try { + org.omg.CORBA_2_3.portable.InputStream in = + (org.omg.CORBA_2_3.portable.InputStream) _in; + switch (method.length()) { + case 8: + if (method.equals("sayHello")) { + String arg0 = (String) in.read_value(String.class); + String result = target.sayHello(arg0); + org.omg.CORBA_2_3.portable.OutputStream out = + (org.omg.CORBA_2_3.portable.OutputStream) reply.createReply(); + out.write_value(result,String.class); + return out; + } + case 14: + if (method.equals("sayHelloToTest")) { + Test arg0 = (Test) in.read_value(Test.class); + String result = target.sayHelloToTest(arg0); + org.omg.CORBA_2_3.portable.OutputStream out = + (org.omg.CORBA_2_3.portable.OutputStream) reply.createReply(); + out.write_value(result,String.class); + return out; + } + case 19: + if (method.equals("sayHelloWithHashMap")) { + ConcurrentHashMap arg0 = (ConcurrentHashMap) in.read_value(ConcurrentHashMap.class); + String result = target.sayHelloWithHashMap(arg0); + org.omg.CORBA_2_3.portable.OutputStream out = + (org.omg.CORBA_2_3.portable.OutputStream) reply.createReply(); + out.write_value(result,String.class); + return out; + } + case 20: + if (method.equals("sayHelloWithHashMap2")) { + HashMap arg0 = (HashMap) in.read_value(HashMap.class); + String result = target.sayHelloWithHashMap2(arg0); + org.omg.CORBA_2_3.portable.OutputStream out = + (org.omg.CORBA_2_3.portable.OutputStream) reply.createReply(); + out.write_value(result,String.class); + return out; + } + case 23: + if (method.equals("sayHelloWithInetAddress")) { + InetAddress arg0 = (InetAddress) in.read_value(InetAddress.class); + String result = target.sayHelloWithInetAddress(arg0); + org.omg.CORBA_2_3.portable.OutputStream out = + (org.omg.CORBA_2_3.portable.OutputStream) reply.createReply(); + out.write_value(result,String.class); + return out; + } + case 25: + if (method.equals("sayHelloWithReentrantLock")) { + ReentrantLock arg0 = (ReentrantLock) in.read_value(ReentrantLock.class); + String result = target.sayHelloWithReentrantLock(arg0); + org.omg.CORBA_2_3.portable.OutputStream out = + (org.omg.CORBA_2_3.portable.OutputStream) reply.createReply(); + out.write_value(result,String.class); + return out; + } + } + throw new BAD_OPERATION(); + } catch (SystemException ex) { + throw ex; + } catch (Throwable ex) { + throw new UnknownException(ex); + } + } +} diff -r e5171238515c -r ec8f5229c8e9 test/javax/rmi/PortableRemoteObject/_HelloInterface_Stub.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/rmi/PortableRemoteObject/_HelloInterface_Stub.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,272 @@ +// Stub class generated by rmic, do not edit. +// Contents subject to change without notice. + +import java.io.Serializable; +import java.net.InetAddress; +import java.rmi.Remote; +import java.rmi.RemoteException; +import java.rmi.UnexpectedException; +import java.util.HashMap; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.locks.ReentrantLock; +import javax.rmi.CORBA.Stub; +import javax.rmi.CORBA.Util; +import org.omg.CORBA.ORB; +import org.omg.CORBA.SystemException; +import org.omg.CORBA.portable.ApplicationException; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.OutputStream; +import org.omg.CORBA.portable.RemarshalException; +import org.omg.CORBA.portable.ResponseHandler; +import org.omg.CORBA.portable.ServantObject; + + +public class _HelloInterface_Stub extends Stub implements HelloInterface { + + private static final String[] _type_ids = { + "RMI:HelloInterface:0000000000000000" + }; + + public String[] _ids() { + return (String[]) _type_ids.clone(); + } + + public String sayHello(String arg0) throws java.rmi.RemoteException { + if (!Util.isLocal(this)) { + try { + org.omg.CORBA_2_3.portable.InputStream in = null; + try { + org.omg.CORBA_2_3.portable.OutputStream out = + (org.omg.CORBA_2_3.portable.OutputStream) + _request("sayHello", true); + out.write_value(arg0,String.class); + in = (org.omg.CORBA_2_3.portable.InputStream)_invoke(out); + return (String) in.read_value(String.class); + } catch (ApplicationException ex) { + in = (org.omg.CORBA_2_3.portable.InputStream) ex.getInputStream(); + String $_id = in.read_string(); + throw new UnexpectedException($_id); + } catch (RemarshalException ex) { + return sayHello(arg0); + } finally { + _releaseReply(in); + } + } catch (SystemException ex) { + throw Util.mapSystemException(ex); + } + } else { + ServantObject so = _servant_preinvoke("sayHello",HelloInterface.class); + if (so == null) { + return sayHello(arg0); + } + try { + return ((HelloInterface)so.servant).sayHello(arg0); + } catch (Throwable ex) { + Throwable exCopy = (Throwable)Util.copyObject(ex,_orb()); + throw Util.wrapException(exCopy); + } finally { + _servant_postinvoke(so); + } + } + } + + public String sayHelloToTest(Test arg0) throws java.rmi.RemoteException { + if (!Util.isLocal(this)) { + try { + org.omg.CORBA_2_3.portable.InputStream in = null; + try { + org.omg.CORBA_2_3.portable.OutputStream out = + (org.omg.CORBA_2_3.portable.OutputStream) + _request("sayHelloToTest", true); + out.write_value(arg0,Test.class); + in = (org.omg.CORBA_2_3.portable.InputStream)_invoke(out); + return (String) in.read_value(String.class); + } catch (ApplicationException ex) { + in = (org.omg.CORBA_2_3.portable.InputStream) ex.getInputStream(); + String $_id = in.read_string(); + throw new UnexpectedException($_id); + } catch (RemarshalException ex) { + return sayHelloToTest(arg0); + } finally { + _releaseReply(in); + } + } catch (SystemException ex) { + throw Util.mapSystemException(ex); + } + } else { + ServantObject so = _servant_preinvoke("sayHelloToTest",HelloInterface.class); + if (so == null) { + return sayHelloToTest(arg0); + } + try { + Test arg0Copy = (Test) Util.copyObject(arg0,_orb()); + return ((HelloInterface)so.servant).sayHelloToTest(arg0Copy); + } catch (Throwable ex) { + Throwable exCopy = (Throwable)Util.copyObject(ex,_orb()); + throw Util.wrapException(exCopy); + } finally { + _servant_postinvoke(so); + } + } + } + + public String sayHelloWithInetAddress(InetAddress arg0) throws java.rmi.RemoteException { + if (!Util.isLocal(this)) { + try { + org.omg.CORBA_2_3.portable.InputStream in = null; + try { + org.omg.CORBA_2_3.portable.OutputStream out = + (org.omg.CORBA_2_3.portable.OutputStream) + _request("sayHelloWithInetAddress", true); + out.write_value(arg0,InetAddress.class); + in = (org.omg.CORBA_2_3.portable.InputStream)_invoke(out); + return (String) in.read_value(String.class); + } catch (ApplicationException ex) { + in = (org.omg.CORBA_2_3.portable.InputStream) ex.getInputStream(); + String $_id = in.read_string(); + throw new UnexpectedException($_id); + } catch (RemarshalException ex) { + return sayHelloWithInetAddress(arg0); + } finally { + _releaseReply(in); + } + } catch (SystemException ex) { + throw Util.mapSystemException(ex); + } + } else { + ServantObject so = _servant_preinvoke("sayHelloWithInetAddress",HelloInterface.class); + if (so == null) { + return sayHelloWithInetAddress(arg0); + } + try { + InetAddress arg0Copy = (InetAddress) Util.copyObject(arg0,_orb()); + return ((HelloInterface)so.servant).sayHelloWithInetAddress(arg0Copy); + } catch (Throwable ex) { + Throwable exCopy = (Throwable)Util.copyObject(ex,_orb()); + throw Util.wrapException(exCopy); + } finally { + _servant_postinvoke(so); + } + } + } + + public String sayHelloWithHashMap(ConcurrentHashMap arg0) throws java.rmi.RemoteException { + if (!Util.isLocal(this)) { + try { + org.omg.CORBA_2_3.portable.InputStream in = null; + try { + org.omg.CORBA_2_3.portable.OutputStream out = + (org.omg.CORBA_2_3.portable.OutputStream) + _request("sayHelloWithHashMap", true); + out.write_value(arg0,ConcurrentHashMap.class); + in = (org.omg.CORBA_2_3.portable.InputStream)_invoke(out); + return (String) in.read_value(String.class); + } catch (ApplicationException ex) { + in = (org.omg.CORBA_2_3.portable.InputStream) ex.getInputStream(); + String $_id = in.read_string(); + throw new UnexpectedException($_id); + } catch (RemarshalException ex) { + return sayHelloWithHashMap(arg0); + } finally { + _releaseReply(in); + } + } catch (SystemException ex) { + throw Util.mapSystemException(ex); + } + } else { + ServantObject so = _servant_preinvoke("sayHelloWithHashMap",HelloInterface.class); + if (so == null) { + return sayHelloWithHashMap(arg0); + } + try { + ConcurrentHashMap arg0Copy = (ConcurrentHashMap) Util.copyObject(arg0,_orb()); + return ((HelloInterface)so.servant).sayHelloWithHashMap(arg0Copy); + } catch (Throwable ex) { + Throwable exCopy = (Throwable)Util.copyObject(ex,_orb()); + throw Util.wrapException(exCopy); + } finally { + _servant_postinvoke(so); + } + } + } + + public String sayHelloWithHashMap2(HashMap arg0) throws java.rmi.RemoteException { + if (!Util.isLocal(this)) { + try { + org.omg.CORBA_2_3.portable.InputStream in = null; + try { + org.omg.CORBA_2_3.portable.OutputStream out = + (org.omg.CORBA_2_3.portable.OutputStream) + _request("sayHelloWithHashMap2", true); + out.write_value(arg0,HashMap.class); + in = (org.omg.CORBA_2_3.portable.InputStream)_invoke(out); + return (String) in.read_value(String.class); + } catch (ApplicationException ex) { + in = (org.omg.CORBA_2_3.portable.InputStream) ex.getInputStream(); + String $_id = in.read_string(); + throw new UnexpectedException($_id); + } catch (RemarshalException ex) { + return sayHelloWithHashMap2(arg0); + } finally { + _releaseReply(in); + } + } catch (SystemException ex) { + throw Util.mapSystemException(ex); + } + } else { + ServantObject so = _servant_preinvoke("sayHelloWithHashMap2",HelloInterface.class); + if (so == null) { + return sayHelloWithHashMap2(arg0); + } + try { + HashMap arg0Copy = (HashMap) Util.copyObject(arg0,_orb()); + return ((HelloInterface)so.servant).sayHelloWithHashMap2(arg0Copy); + } catch (Throwable ex) { + Throwable exCopy = (Throwable)Util.copyObject(ex,_orb()); + throw Util.wrapException(exCopy); + } finally { + _servant_postinvoke(so); + } + } + } + + public String sayHelloWithReentrantLock(ReentrantLock arg0) throws java.rmi.RemoteException { + if (!Util.isLocal(this)) { + try { + org.omg.CORBA_2_3.portable.InputStream in = null; + try { + org.omg.CORBA_2_3.portable.OutputStream out = + (org.omg.CORBA_2_3.portable.OutputStream) + _request("sayHelloWithReentrantLock", true); + out.write_value(arg0,ReentrantLock.class); + in = (org.omg.CORBA_2_3.portable.InputStream)_invoke(out); + return (String) in.read_value(String.class); + } catch (ApplicationException ex) { + in = (org.omg.CORBA_2_3.portable.InputStream) ex.getInputStream(); + String $_id = in.read_string(); + throw new UnexpectedException($_id); + } catch (RemarshalException ex) { + return sayHelloWithReentrantLock(arg0); + } finally { + _releaseReply(in); + } + } catch (SystemException ex) { + throw Util.mapSystemException(ex); + } + } else { + ServantObject so = _servant_preinvoke("sayHelloWithReentrantLock",HelloInterface.class); + if (so == null) { + return sayHelloWithReentrantLock(arg0); + } + try { + ReentrantLock arg0Copy = (ReentrantLock) Util.copyObject(arg0,_orb()); + return ((HelloInterface)so.servant).sayHelloWithReentrantLock(arg0Copy); + } catch (Throwable ex) { + Throwable exCopy = (Throwable)Util.copyObject(ex,_orb()); + throw Util.wrapException(exCopy); + } finally { + _servant_postinvoke(so); + } + } + } +} diff -r e5171238515c -r ec8f5229c8e9 test/javax/script/SimpleScriptContextNameChecksTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/script/SimpleScriptContextNameChecksTest.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8072853 + * @summary SimpleScriptContext used by NashornScriptEngine doesn't completely complies to the spec regarding exception throwing + * @run testng SimpleScriptContextNameChecksTest + */ + +import java.util.List; +import java.util.function.Consumer; +import javax.script.*; +import org.testng.annotations.Test; + +public class SimpleScriptContextNameChecksTest { + private List getFactories() { + return new ScriptEngineManager().getEngineFactories(); + } + + private void testAndExpect(Consumer c, Class clazz) { + for (ScriptEngineFactory fac : getFactories()) { + ScriptContext sc = fac.getScriptEngine().getContext(); + String name = fac.getEngineName(); + try { + c.accept(sc); + throw new RuntimeException("no exception for " + name); + } catch (NullPointerException | IllegalArgumentException e) { + if (e.getClass() == clazz) { + System.out.println("got " + e + " as expected for " + name); + } else { + throw e; + } + } + } + } + + private void testAndExpectIAE(Consumer c) { + testAndExpect(c, IllegalArgumentException.class); + } + + private void testAndExpectNPE(Consumer c) { + testAndExpect(c, NullPointerException.class); + } + + @Test + public void getAttributeEmptyName() { + testAndExpectIAE(sc -> sc.getAttribute("", ScriptContext.GLOBAL_SCOPE)); + } + + @Test + public void getAttributeNullName() { + testAndExpectNPE(sc -> sc.getAttribute(null, ScriptContext.GLOBAL_SCOPE)); + } + + @Test + public void removeAttributeEmptyName() { + testAndExpectIAE(sc -> sc.removeAttribute("", ScriptContext.GLOBAL_SCOPE)); + } + + @Test + public void removeAttributeNullName() { + testAndExpectNPE(sc -> sc.removeAttribute(null, ScriptContext.GLOBAL_SCOPE)); + } + + @Test + public void setAttributeEmptyName() { + testAndExpectIAE(sc -> sc.setAttribute("", "value", ScriptContext.GLOBAL_SCOPE)); + } + + @Test + public void setAttributeNullName() { + testAndExpectNPE(sc -> sc.setAttribute(null, "value", ScriptContext.GLOBAL_SCOPE)); + } + + @Test + public void getAttributesScopeEmptyName() { + testAndExpectIAE(sc -> sc.getAttributesScope("")); + } + + @Test + public void getAttributesScopeNullName() { + testAndExpectNPE(sc -> sc.getAttributesScope(null)); + } +} diff -r e5171238515c -r ec8f5229c8e9 test/javax/swing/JComboBox/8033069/bug8033069NoScrollBar.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/swing/JComboBox/8033069/bug8033069NoScrollBar.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.AWTException; +import java.awt.Dimension; +import java.awt.GridLayout; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.InputEvent; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.UIManager.LookAndFeelInfo; +import javax.swing.UnsupportedLookAndFeelException; + +/* @test + * @bug 8033069 + * @summary Checks that JComboBox popup does not close when mouse wheel is + * rotated over combo box and over its popup. The case where popup + * has no scroll bar. + * @library ../../regtesthelpers + * @build Util + * @run main bug8033069NoScrollBar + * @author Alexey Ivanov + */ +public class bug8033069NoScrollBar implements Runnable { + + private static final String[] NO_SCROLL_ITEMS = new String[] { + "A", "B", "C", "D", "E", "F" + }; + + private final Robot robot; + + private final String[] items; + + private JFrame frame; + private JComboBox cb1; + private JComboBox cb2; + + public static void main(String[] args) throws Exception { + iterateLookAndFeels(new bug8033069NoScrollBar(NO_SCROLL_ITEMS)); + } + + protected static void iterateLookAndFeels(final bug8033069NoScrollBar test) throws Exception { + LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels(); + for (LookAndFeelInfo info : lafInfo) { + try { + UIManager.setLookAndFeel(info.getClassName()); + System.out.println("Look and Feel: " + info.getClassName()); + test.runTest(); + } catch (UnsupportedLookAndFeelException e) { + System.out.println("Skipping unsupported LaF: " + info); + } + } + } + + public bug8033069NoScrollBar(String[] items) throws AWTException { + this.items = items; + + robot = new Robot(); + robot.setAutoDelay(200); + } + + private void setupUI() { + frame = new JFrame(); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + cb1 = new JComboBox<>(items); + cb2 = new JComboBox<>(items); + JPanel panel = new JPanel(new GridLayout(1, 2)); + panel.add(cb1); + panel.add(cb2); + + frame.add(panel); + + frame.pack(); + frame.setVisible(true); + } + + public void runTest() throws Exception { + try { + SwingUtilities.invokeAndWait(this); + + robot.waitForIdle(); + assertFalse("cb1 popup is visible", + Util.invokeOnEDT(cb1::isPopupVisible)); + + // Move mouse pointer to the center of the fist combo box + Point p = cb1.getLocationOnScreen(); + Dimension d = cb1.getSize(); + robot.mouseMove(p.x + d.width / 2, p.y + d.height / 2); + // Click it to open popup + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + + robot.waitForIdle(); + assertTrue("cb1 popup is not visible", + Util.invokeOnEDT(cb1::isPopupVisible)); + + robot.mouseWheel(1); + robot.waitForIdle(); + assertTrue("cb1 popup is not visible after mouse wheel up on combo box", + Util.invokeOnEDT(cb1::isPopupVisible)); + + robot.mouseWheel(-1); + robot.waitForIdle(); + assertTrue("cb1 popup is not visible after mouse wheel down on combo box", + Util.invokeOnEDT(cb1::isPopupVisible)); + + // Move mouse down on the popup + robot.mouseMove(p.x + d.width / 2, p.y + d.height * 3); + + robot.mouseWheel(1); + robot.waitForIdle(); + assertTrue("cb1 popup is not visible after mouse wheel up on popup", + Util.invokeOnEDT(cb1::isPopupVisible)); + + robot.mouseWheel(-1); + robot.waitForIdle(); + assertTrue("cb1 popup is not visible after mouse wheel down on popup", + Util.invokeOnEDT(cb1::isPopupVisible)); + + + // Move mouse pointer to the center of the second combo box + p = cb2.getLocationOnScreen(); + d = cb2.getSize(); + robot.mouseMove(p.x + d.width / 2, p.y + d.height / 2); + + robot.mouseWheel(1); + robot.waitForIdle(); + assertFalse("cb1 popup is visible after mouse wheel up on cb2", + Util.invokeOnEDT(cb1::isPopupVisible)); + } finally { + if (frame != null) { + frame.dispose(); + } + } + + System.out.println("Test passed"); + } + + @Override + public void run() { + setupUI(); + } + + private static void assertTrue(String message, boolean value) { + assertEquals(message, true, value); + } + + private static void assertFalse(String message, boolean value) { + assertEquals(message, false, value); + } + + private static void assertEquals(String message, boolean expected, boolean actual) { + if (expected != actual) { + throw new RuntimeException(message); + } + } +} diff -r e5171238515c -r ec8f5229c8e9 test/javax/swing/JComboBox/8033069/bug8033069ScrollBar.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/swing/JComboBox/8033069/bug8033069ScrollBar.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.AWTException; + +/* @test + * @bug 8033069 + * @summary Checks that JComboBox popup does not close when mouse wheel is + * rotated over combo box and over its popup. The case where + * popup has scroll bar. + * @library ../../regtesthelpers + * @build Util + * @run main bug8033069ScrollBar + * @author Alexey Ivanov + */ +public class bug8033069ScrollBar extends bug8033069NoScrollBar { + + private static final String[] SCROLL_ITEMS = new String[] { + "A", "B", "C", "D", "E", "F", + "G", "H", "I", "J", "K", "L", + "M", "N", "O", "P", "Q", "R" + }; + + public static void main(String[] args) throws Exception { + iterateLookAndFeels(new bug8033069ScrollBar(SCROLL_ITEMS)); + } + + public bug8033069ScrollBar(String[] items) throws AWTException { + super(items); + } + +} diff -r e5171238515c -r ec8f5229c8e9 test/javax/swing/JFileChooser/8080628/bug8080628.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/swing/JFileChooser/8080628/bug8080628.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.util.Locale; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.UIManager.LookAndFeelInfo; + +import sun.swing.SwingUtilities2; + +/* + * @test + * @bug 8080628 + * @summary No mnemonics on Open and Save buttons in JFileChooser. + * @author Alexey Ivanov + * @run main bug8080628 + */ +public class bug8080628 { + public static final String[] MNEMONIC_KEYS = new String[] { + "FileChooser.saveButtonMnemonic", + "FileChooser.openButtonMnemonic", + "FileChooser.cancelButtonMnemonic", + "FileChooser.directoryOpenButtonMnemonic" + }; + + public static final Locale[] LOCALES = new Locale[] { + new Locale("en"), + new Locale("de"), + new Locale("es"), + new Locale("fr"), + new Locale("it"), + new Locale("ja"), + new Locale("ko"), + new Locale("pt", "BR"), + new Locale("sv"), + new Locale("zh", "CN"), + new Locale("zh", "TW") + }; + + private static volatile Exception exception; + + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + runTest(); + } + }); + + if (exception != null) { + throw exception; + } + } + + private static void runTest() { + try { + LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels(); + for (LookAndFeelInfo info : lafInfo) { + UIManager.setLookAndFeel(info.getClassName()); + + for (Locale locale : LOCALES) { + for (String key : MNEMONIC_KEYS) { + int mnemonic = SwingUtilities2.getUIDefaultsInt(key, locale); + if (mnemonic != 0) { + throw new RuntimeException("No mnemonic expected (" + mnemonic + ") " + + "for '" + key + "' " + + "in locale '" + locale + "' " + + "in Look-and-Feel '" + + UIManager.getLookAndFeel().getClass().getName() + "'"); + } + } + } + } + System.out.println("Test passed"); + } catch (Exception e) { + exception = e; + } + } + +} diff -r e5171238515c -r ec8f5229c8e9 test/lib/testlibrary/jdk/testlibrary/RandomFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/lib/testlibrary/jdk/testlibrary/RandomFactory.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.testlibrary; + +import java.util.Random; +import java.util.SplittableRandom; + +/** + * Factory class which generates and prints to STDOUT a long-valued seed + * for use in initializing a PRNG. An instance of {@code Random} or + * {@code SplittableRandom} may likewise be obtained. + */ +public class RandomFactory { + /** + * Attempt to obtain the seed from the value of the "seed" property. + * @return The seed or {@code null} if the "seed" property was not set or + * could not be parsed. + */ + private static Long getSystemSeed() { + Long seed = null; + try { + // note that Long.valueOf(null) also throws a + // NumberFormatException so if the property is undefined this + // will still work correctly + seed = Long.valueOf(System.getProperty("seed")); + } catch (NumberFormatException e) { + // do nothing: seed is still null + } + + return seed; + } + + /** + * Obtain a seed from an independent PRNG. + * + * @return A random seed. + */ + private static long getRandomSeed() { + return new Random().nextLong(); + } + + /** + * Obtain and print to STDOUT a seed appropriate for initializing a PRNG. + * If the system property "seed" is set and has value which may be correctly + * parsed it is used, otherwise a seed is generated using an independent + * PRNG. + * + * @return The seed. + */ + public static long getSeed() { + Long seed = getSystemSeed(); + if (seed == null) { + seed = getRandomSeed(); + } + System.out.println("Seed from RandomFactory = "+seed+"L"); + return seed; + } + + /** + * Obtain and print to STDOUT a seed and use it to initialize a new + * {@code Random} instance which is returned. If the system + * property "seed" is set and has value which may be correctly parsed it + * is used, otherwise a seed is generated using an independent PRNG. + * + * @return The {@code Random} instance. + */ + public static Random getRandom() { + return new Random(getSeed()); + } + + /** + * Obtain and print to STDOUT a seed and use it to initialize a new + * {@code SplittableRandom} instance which is returned. If the system + * property "seed" is set and has value which may be correctly parsed it + * is used, otherwise a seed is generated using an independent PRNG. + * + * @return The {@code SplittableRandom} instance. + */ + public static SplittableRandom getSplittableRandom() { + return new SplittableRandom(getSeed()); + } +} diff -r e5171238515c -r ec8f5229c8e9 test/sun/security/krb5/ConfPlusProp.java --- a/test/sun/security/krb5/ConfPlusProp.java Fri May 29 10:15:38 2015 -0700 +++ b/test/sun/security/krb5/ConfPlusProp.java Wed Jun 03 20:28:57 2015 -0700 @@ -35,6 +35,12 @@ public class ConfPlusProp { Config config; public static void main(String[] args) throws Exception { + if (System.getenv("USERDNSDOMAIN") != null || + System.getenv("LOGONSERVER") != null) { + System.out.println( + "Looks like a Windows machine in a domain. Skip test."); + return; + } new ConfPlusProp().run(); } @@ -90,23 +96,8 @@ check("R2", "old"); check("R3", null); - int version = System.getProperty("java.version").charAt(2) - '0'; - System.out.println("JDK version is " + version); - - // Zero-config is supported since 1.7 - if (version >= 7) { - // Point to a non-existing file - System.setProperty("java.security.krb5.conf", "i-am-not-a file"); - refresh(); - - // Default realm might come from DNS - //checkDefaultRealm(null); - check("R1", null); - check("R2", null); - check("R3", null); - if (config.get("libdefaults", "forwardable") != null) { - throw new Exception("Extra config error"); - } + if (config.get("libdefaults", "forwardable") != null) { + throw new Exception("Extra config error"); } // Add prop @@ -136,14 +127,6 @@ check("R2", "k2"); check("R3", "k2"); - // Point to a non-existing file - System.setProperty("java.security.krb5.conf", "i-am-not-a file"); - refresh(); - - checkDefaultRealm("R2"); - check("R1", "k2"); - check("R2", "k2"); - check("R3", "k2"); if (config.get("libdefaults", "forwardable") != null) { throw new Exception("Extra config error"); } diff -r e5171238515c -r ec8f5229c8e9 test/sun/security/krb5/DnsFallback.java --- a/test/sun/security/krb5/DnsFallback.java Fri May 29 10:15:38 2015 -0700 +++ b/test/sun/security/krb5/DnsFallback.java Wed Jun 03 20:28:57 2015 -0700 @@ -22,8 +22,7 @@ */ /* * @test - * @bug 6673164 - * @bug 6552334 + * @bug 6673164 6552334 8077102 * @run main/othervm DnsFallback * @summary fix dns_fallback parse error, and use dns by default */ @@ -35,47 +34,66 @@ public class DnsFallback { static Method useDNS_Realm; + static Method useDNS_KDC; public static void main(String[] args) throws Exception { useDNS_Realm = Config.class.getDeclaredMethod("useDNS_Realm"); useDNS_Realm.setAccessible(true); + useDNS_KDC = Config.class.getDeclaredMethod("useDNS_KDC"); + useDNS_KDC.setAccessible(true); // for 6673164 - check("true", "true", true); - check("false", "true", false); - check("true", "false", true); - check("false", "false", false); - check("true", null, true); - check("false", null, false); - check(null, "true", true); - check(null, "false", false); + check("true", "true", true, true); + check("false", "true", false, false); + check("true", "false", true, true); + check("false", "false", false, false); + check("true", null, true, true); + check("false", null, false, false); + check(null, "true", true, true); + check(null, "false", false, false); - // for 6552334 - check(null, null, true); + // for 6552334, no longer true + //check(null, null, true, true); + + // 8077102 + check(null, null, false, true); } - static void check(String realm, String fallback, boolean output) + /** + * Sets and checks. + * + * @param u dns_lookup_XXX value set, none if null + * @param f dns_fallback value set, none if null + * @param r expected useDNS_Realm + * @param k expected useDNS_KDC + */ + static void check(String u, String f, boolean r, boolean k) throws Exception { try (PrintStream ps = new PrintStream(new FileOutputStream("dnsfallback.conf"))) { ps.println("[libdefaults]\n"); - if (realm != null) { - ps.println("dns_lookup_realm=" + realm); + if (u != null) { + ps.println("dns_lookup_realm=" + u); + ps.println("dns_lookup_kdc=" + u); } - if (fallback != null) { - ps.println("dns_fallback=" + fallback); + if (f != null) { + ps.println("dns_fallback=" + f); } } System.setProperty("java.security.krb5.conf", "dnsfallback.conf"); Config.refresh(); - System.out.println("Testing " + realm + ", " + fallback + ", " + output); + System.out.println("Testing " + u + ", " + f + ", " + r + ", " + k); - if (!useDNS_Realm.invoke(Config.getInstance()).equals(output)) { - throw new Exception("Fail"); + if (!useDNS_Realm.invoke(Config.getInstance()).equals(r)) { + throw new Exception("useDNS_Realm Fail"); + } + + if (!useDNS_KDC.invoke(Config.getInstance()).equals(k)) { + throw new Exception("useDNS_KDC Fail"); } } } diff -r e5171238515c -r ec8f5229c8e9 test/sun/security/krb5/auto/HttpNegotiateServer.java --- a/test/sun/security/krb5/auto/HttpNegotiateServer.java Fri May 29 10:15:38 2015 -0700 +++ b/test/sun/security/krb5/auto/HttpNegotiateServer.java Wed Jun 03 20:28:57 2015 -0700 @@ -40,16 +40,28 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.InetSocketAddress; import java.net.PasswordAuthentication; import java.net.Proxy; import java.net.URL; -import java.security.PrivilegedExceptionAction; +import java.net.URLConnection; +import java.security.*; import java.util.HashMap; import java.util.Map; import javax.security.auth.Subject; +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.NameCallback; +import javax.security.auth.callback.PasswordCallback; +import javax.security.auth.callback.UnsupportedCallbackException; +import javax.security.auth.login.AppConfigurationEntry; +import javax.security.auth.login.Configuration; +import javax.security.auth.login.LoginContext; +import javax.security.auth.login.LoginException; +import javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag; import org.ietf.jgss.GSSContext; import org.ietf.jgss.GSSCredential; import org.ietf.jgss.GSSManager; @@ -191,7 +203,7 @@ proxyUrl = new URL("http://nosuchplace/a/b/c"); try { - Exception e1 = null, e2 = null; + Exception e1 = null, e2 = null, e3 = null; try { test6578647(); } catch (Exception e) { @@ -204,7 +216,14 @@ e2 = e; e.printStackTrace(); } - if (e1 != null || e2 != null) { + try { + test8077155(); + } catch (Exception e) { + e3 = e; + e.printStackTrace(); + } + + if (e1 != null || e2 != null || e3 != null) { throw new RuntimeException("Test error"); } } finally { @@ -248,6 +267,121 @@ } } + static void testConnect() { + InputStream inputStream = null; + try { + URL url = webUrl; + + URLConnection conn = url.openConnection(); + conn.connect(); + inputStream = conn.getInputStream(); + byte[] b = new byte[inputStream.available()]; + for (int j = 0; j < b.length; j++) { + b[j] = (byte) inputStream.read(); + } + String s = new String(b); + System.out.println("Length: " + s.length()); + System.out.println(s); + } catch (Exception ex) { + throw new RuntimeException(ex); + } finally { + if (inputStream != null) { + try { + inputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + static void test8077155() throws Exception { + final String username = WEB_USER; + final char[] password = WEB_PASS; + + SecurityManager security = new SecurityManager(); + Policy.setPolicy(new SecurityPolicy()); + System.setSecurityManager(security); + + CallbackHandler callback = new CallbackHandler() { + @Override + public void handle(Callback[] pCallbacks) throws IOException, UnsupportedCallbackException { + for (Callback cb : pCallbacks) { + if (cb instanceof NameCallback) { + NameCallback ncb = (NameCallback)cb; + ncb.setName(username); + + } else if (cb instanceof PasswordCallback) { + PasswordCallback pwdcb = (PasswordCallback) cb; + pwdcb.setPassword(password); + } + } + } + + }; + + final String jaasConfigName = "oracle.test.kerberos.login"; + final String krb5LoginModule = "com.sun.security.auth.module.Krb5LoginModule"; + + Configuration loginConfig = new Configuration() { + @Override + public AppConfigurationEntry[] getAppConfigurationEntry(String name) { + if (! jaasConfigName.equals(name)) { + return new AppConfigurationEntry[0]; + } + + Map options = new HashMap(); + options.put("useTicketCache", Boolean.FALSE.toString()); + options.put("useKeyTab", Boolean.FALSE.toString()); + + return new AppConfigurationEntry[] { + new AppConfigurationEntry(krb5LoginModule, + LoginModuleControlFlag.REQUIRED, + options) + }; + } + }; + + // oracle context/subject/login + LoginContext context = null; + try { + context = new LoginContext("oracle.test.kerberos.login", null, callback, loginConfig); + context.login(); + + } catch (LoginException ex) { + ex.printStackTrace(); + throw new RuntimeException(ex); + } + + + Subject subject = context.getSubject(); + + final PrivilegedExceptionAction test_action = new PrivilegedExceptionAction() { + public Object run() throws Exception { + testConnect(); + return null; + } + }; + + System.err.println("\n\nExpecting to succeed when executing with the the logged in subject."); + + try { + Subject.doAs(subject, test_action); + System.err.println("\n\nConnection succeed when executing with the the logged in subject."); + } catch (PrivilegedActionException e) { + System.err.println("\n\nFailure unexpected when executing with the the logged in subject."); + e.printStackTrace(); + throw new RuntimeException("Failed to login as subject"); + } + + try { + System.err.println("\n\nExpecting to fail when running with the current user's login."); + testConnect(); + } catch (Exception ex) { + System.err.println("\nConnect failed when running with the current user's login:\n" + ex.getMessage()); + } + } + /** * Creates and starts an HTTP or proxy server that requires * Negotiate authentication. @@ -360,3 +494,22 @@ } } } + +class SecurityPolicy extends Policy { + + private static Permissions perms; + + public SecurityPolicy() { + super(); + if (perms == null) { + perms = new Permissions(); + perms.add(new AllPermission()); + } + } + + @Override + public PermissionCollection getPermissions(CodeSource codesource) { + return perms; + } + +} diff -r e5171238515c -r ec8f5229c8e9 test/sun/security/krb5/config/DNS.java --- a/test/sun/security/krb5/config/DNS.java Fri May 29 10:15:38 2015 -0700 +++ b/test/sun/security/krb5/config/DNS.java Wed Jun 03 20:28:57 2015 -0700 @@ -23,12 +23,22 @@ // See dns.sh. import sun.security.krb5.Config; +import sun.security.krb5.KrbException; public class DNS { public static void main(String[] args) throws Exception { System.setProperty("java.security.krb5.conf", - System.getProperty("test.src", ".") +"/nothing.conf"); + System.getProperty("test.src", ".") +"/no-such-file.conf"); Config config = Config.getInstance(); + try { + String r = config.getDefaultRealm(); + throw new Exception("What? There is a default realm " + r + "?"); + } catch (KrbException ke) { + ke.printStackTrace(); + if (ke.getCause() != null) { + throw new Exception("There should be no cause. Won't try DNS"); + } + } String kdcs = config.getKDCList("X"); if (!kdcs.equals("a.com.:88 b.com.:99") && !kdcs.equals("a.com. b.com.:99")) { diff -r e5171238515c -r ec8f5229c8e9 test/sun/security/krb5/confplusprop.conf --- a/test/sun/security/krb5/confplusprop.conf Fri May 29 10:15:38 2015 -0700 +++ b/test/sun/security/krb5/confplusprop.conf Wed Jun 03 20:28:57 2015 -0700 @@ -1,7 +1,7 @@ [libdefaults] default_realm = R1 forwardable = well -dns_lookup_realm = false +dns_lookup_kdc = false [realms] R1 = { diff -r e5171238515c -r ec8f5229c8e9 test/sun/security/krb5/confplusprop2.conf --- a/test/sun/security/krb5/confplusprop2.conf Fri May 29 10:15:38 2015 -0700 +++ b/test/sun/security/krb5/confplusprop2.conf Wed Jun 03 20:28:57 2015 -0700 @@ -1,5 +1,5 @@ [libdefaults] -dns_lookup_realm = false +dns_lookup_kdc = false [realms] R1 = { diff -r e5171238515c -r ec8f5229c8e9 test/tools/launcher/Arrrghs.java --- a/test/tools/launcher/Arrrghs.java Fri May 29 10:15:38 2015 -0700 +++ b/test/tools/launcher/Arrrghs.java Wed Jun 03 20:28:57 2015 -0700 @@ -24,7 +24,7 @@ /** * @test * @bug 5030233 6214916 6356475 6571029 6684582 6742159 4459600 6758881 6753938 - * 6894719 6968053 7151434 7146424 8007333 + * 6894719 6968053 7151434 7146424 8007333 8077822 * @summary Argument parsing validation. * @compile -XDignore.symbol.file Arrrghs.java * @run main/othervm Arrrghs @@ -431,6 +431,16 @@ throw new RuntimeException("Error: compiling java wildcards"); } + // test if javac (the command) can compile *.java with a vmoption + tr = doExec(javacCmd, "-cp", ".", + "-J-showversion", "-J-Dsomeproperty=foo", + libDir.getName() + File.separator + "*.java"); + if (!tr.isOK()) { + System.out.println(tr); + throw new RuntimeException("Error: compiling java wildcards with vmoptions"); + } + + // use the jar cmd to create jars using the ? wildcard File jarFoo = new File(libDir, "Foo.jar"); tr = doExec(jarCmd, "cvf", jarFoo.getAbsolutePath(), "lib" + File.separator + "F?o.class"); diff -r e5171238515c -r ec8f5229c8e9 test/tools/pack200/DefaultTimeZoneTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/pack200/DefaultTimeZoneTest.java Wed Jun 03 20:28:57 2015 -0700 @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.TimeZone; +import java.util.concurrent.CountDownLatch; +import java.util.jar.JarFile; +import java.util.jar.JarOutputStream; +import java.util.jar.Pack200; + +/* + * @test + * @bug 8066985 + * @summary multithreading packing/unpacking files can result in Timezone set to UTC + * @compile -XDignore.symbol.file Utils.java DefaultTimeZoneTest.java + * @run main/othervm DefaultTimeZoneTest + * @author mcherkas + */ + + +public class DefaultTimeZoneTest { + + private static final TimeZone tz = TimeZone.getTimeZone("Europe/Moscow"); + private static final int INIT_THREAD_COUNT = Math.min(4, Runtime.getRuntime().availableProcessors()); + private static final int MAX_THREAD_COUNT = 4 * INIT_THREAD_COUNT; + private static final long MINUTE = 60 * 1000; + + private static class NoOpOutputStream extends OutputStream { + @Override + public void write(int b) throws IOException { + // no op + } + } + + static class PackAction implements Runnable { + private Pack200.Packer packer = Pack200.newPacker(); + private JarFile jarFile; + + PackAction() throws IOException { + jarFile = new JarFile(new File("golden.jar")); + } + + @Override + public void run() { + try { + packer.pack(jarFile, new NoOpOutputStream()); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + + static class UnpackAction implements Runnable { + private Pack200.Unpacker unpacker = Pack200.newUnpacker(); + private JarOutputStream jos; + private File packedJar = new File("golden.pack"); + + UnpackAction() throws IOException { + jos = new JarOutputStream(new NoOpOutputStream()); + } + + @Override + public void run() { + try { + unpacker.unpack(packedJar, jos); + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + try { + jos.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + }; + + public static void test(final Class runnableClass) throws InterruptedException { + for (int i = INIT_THREAD_COUNT; i <= MAX_THREAD_COUNT; i*=2) { + final CountDownLatch startLatch = new CountDownLatch(i); + final CountDownLatch doneLatch = new CountDownLatch(i); + for (int j = 0; j < i; j++) { + new Thread() { + @Override + public void run() { + try { + Runnable r = runnableClass.newInstance(); + startLatch.countDown(); + startLatch.await(); + r.run(); + } catch (Exception e) { + throw new RuntimeException(e); + } finally { + doneLatch.countDown(); + } + } + }.start(); + } + doneLatch.await(); + + if(!TimeZone.getDefault().equals(tz)) { + throw new RuntimeException("FAIL: default time zone was changed"); + } + } + } + + public static void main(String args[]) throws IOException, InterruptedException { + TimeZone.setDefault(tz); + + // make a local copy of our test file + File srcFile = Utils.locateJar("golden.jar"); + final File goldenFile = new File("golden.jar"); + Utils.copyFile(srcFile, goldenFile); + + // created packed file + final JarFile goldenJarFile = new JarFile(goldenFile); + final File packFile = new File("golden.pack"); + Utils.pack(goldenJarFile, packFile); + + // before test let's unpack golden pack to warm up + // a native unpacker. That allow us to avoid JDK-8080438 + UnpackAction unpackAction = new UnpackAction(); + unpackAction.run(); + + long startTime = System.currentTimeMillis(); + while(System.currentTimeMillis() - startTime < MINUTE) { + // test packer + test(PackAction.class); + + // test unpacker + test(UnpackAction.class); + } + + Utils.cleanup(); + } +}