src/java.desktop/share/classes/sun/awt/AWTAccessor.java

Print this page




  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.awt;
  27 
  28 import sun.misc.Unsafe;
  29 
  30 import javax.accessibility.AccessibleContext;
  31 import java.awt.*;




  32 import java.awt.event.InputEvent;
  33 import java.awt.event.InvocationEvent;
  34 import java.awt.event.KeyEvent;
  35 import java.awt.geom.Point2D;
  36 import java.awt.image.BufferStrategy;
  37 import java.awt.peer.ComponentPeer;
  38 
  39 import java.awt.peer.MenuComponentPeer;
  40 import java.lang.reflect.InvocationTargetException;
  41 import java.security.AccessControlContext;
  42 
  43 import java.io.File;
  44 import java.util.ResourceBundle;
  45 import java.util.Vector;
  46 
  47 /**
  48  * The AWTAccessor utility class.
  49  * The main purpose of this class is to enable accessing
  50  * private and package-private fields of classes from
  51  * different classes/packages. See sun.misc.SharedSecretes


 768     public interface InvocationEventAccessor {
 769         void dispose(InvocationEvent event);
 770     }
 771 
 772     /*
 773      * An accessor object for the SystemColor class
 774      */
 775     public interface SystemColorAccessor {
 776         void updateSystemColors();
 777     }
 778 
 779     /*
 780      * An accessor object for the AccessibleContext class
 781      */
 782     public interface AccessibleContextAccessor {
 783         void setAppContext(AccessibleContext accessibleContext, AppContext appContext);
 784         AppContext getAppContext(AccessibleContext accessibleContext);
 785     }
 786 
 787     /*

























 788      * Accessor instances are initialized in the static initializers of
 789      * corresponding AWT classes by using setters defined below.
 790      */
 791     private static ComponentAccessor componentAccessor;
 792     private static ContainerAccessor containerAccessor;
 793     private static WindowAccessor windowAccessor;
 794     private static AWTEventAccessor awtEventAccessor;
 795     private static InputEventAccessor inputEventAccessor;
 796     private static FrameAccessor frameAccessor;
 797     private static KeyboardFocusManagerAccessor kfmAccessor;
 798     private static MenuComponentAccessor menuComponentAccessor;
 799     private static EventQueueAccessor eventQueueAccessor;
 800     private static PopupMenuAccessor popupMenuAccessor;
 801     private static FileDialogAccessor fileDialogAccessor;
 802     private static ScrollPaneAdjustableAccessor scrollPaneAdjustableAccessor;
 803     private static CheckboxMenuItemAccessor checkboxMenuItemAccessor;
 804     private static CursorAccessor cursorAccessor;
 805     private static MenuBarAccessor menuBarAccessor;
 806     private static MenuItemAccessor menuItemAccessor;
 807     private static MenuAccessor menuAccessor;
 808     private static KeyEventAccessor keyEventAccessor;
 809     private static ClientPropertyKeyAccessor clientPropertyKeyAccessor;
 810     private static SystemTrayAccessor systemTrayAccessor;
 811     private static TrayIconAccessor trayIconAccessor;
 812     private static DefaultKeyboardFocusManagerAccessor defaultKeyboardFocusManagerAccessor;
 813     private static SequencedEventAccessor sequencedEventAccessor;
 814     private static ToolkitAccessor toolkitAccessor;
 815     private static InvocationEventAccessor invocationEventAccessor;
 816     private static SystemColorAccessor systemColorAccessor;
 817     private static AccessibleContextAccessor accessibleContextAccessor;


 818 
 819     /*
 820      * Set an accessor object for the java.awt.Component class.
 821      */
 822     public static void setComponentAccessor(ComponentAccessor ca) {
 823         componentAccessor = ca;
 824     }
 825 
 826     /*
 827      * Retrieve the accessor object for the java.awt.Component class.
 828      */
 829     public static ComponentAccessor getComponentAccessor() {
 830         if (componentAccessor == null) {
 831             unsafe.ensureClassInitialized(Component.class);
 832         }
 833 
 834         return componentAccessor;
 835     }
 836 
 837     /*


1258      public static void setSystemColorAccessor(SystemColorAccessor systemColorAccessor) {
1259          AWTAccessor.systemColorAccessor = systemColorAccessor;
1260      }
1261 
1262     /*
1263      * Get the accessor object for the javax.accessibility.AccessibleContext class.
1264      */
1265     public static AccessibleContextAccessor getAccessibleContextAccessor() {
1266         if (accessibleContextAccessor == null) {
1267             unsafe.ensureClassInitialized(AccessibleContext.class);
1268         }
1269         return accessibleContextAccessor;
1270     }
1271 
1272    /*
1273     * Set the accessor object for the javax.accessibility.AccessibleContext class.
1274     */
1275     public static void setAccessibleContextAccessor(AccessibleContextAccessor accessor) {
1276         AWTAccessor.accessibleContextAccessor = accessor;
1277     }



































1278 }


  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.awt;
  27 
  28 import sun.misc.Unsafe;
  29 
  30 import javax.accessibility.AccessibleContext;
  31 import java.awt.*;
  32 import java.awt.dnd.DragSourceContext;
  33 import java.awt.dnd.DropTargetContext;
  34 import java.awt.dnd.peer.DragSourceContextPeer;
  35 import java.awt.dnd.peer.DropTargetContextPeer;
  36 import java.awt.event.InputEvent;
  37 import java.awt.event.InvocationEvent;
  38 import java.awt.event.KeyEvent;
  39 import java.awt.geom.Point2D;
  40 import java.awt.image.BufferStrategy;
  41 import java.awt.peer.ComponentPeer;
  42 
  43 import java.awt.peer.MenuComponentPeer;
  44 import java.lang.reflect.InvocationTargetException;
  45 import java.security.AccessControlContext;
  46 
  47 import java.io.File;
  48 import java.util.ResourceBundle;
  49 import java.util.Vector;
  50 
  51 /**
  52  * The AWTAccessor utility class.
  53  * The main purpose of this class is to enable accessing
  54  * private and package-private fields of classes from
  55  * different classes/packages. See sun.misc.SharedSecretes


 772     public interface InvocationEventAccessor {
 773         void dispose(InvocationEvent event);
 774     }
 775 
 776     /*
 777      * An accessor object for the SystemColor class
 778      */
 779     public interface SystemColorAccessor {
 780         void updateSystemColors();
 781     }
 782 
 783     /*
 784      * An accessor object for the AccessibleContext class
 785      */
 786     public interface AccessibleContextAccessor {
 787         void setAppContext(AccessibleContext accessibleContext, AppContext appContext);
 788         AppContext getAppContext(AccessibleContext accessibleContext);
 789     }
 790 
 791     /*
 792      * An accessor object for the DragSourceContext class
 793      */
 794     public interface DragSourceContextAccessor {
 795         /**
 796          * Returns the peer of the DragSourceContext.
 797          */
 798         DragSourceContextPeer getPeer(DragSourceContext dsc);
 799     }
 800 
 801     /*
 802      * An accessor object for the DropTargetContext class
 803      */
 804     public interface DropTargetContextAccessor {
 805         /**
 806          * Resets the DropTargetContext.
 807          */
 808         void reset(DropTargetContext dtc);
 809         /**
 810          * Sets the {@code DropTargetContextPeer}
 811          */
 812         void setDropTargetContextPeer(DropTargetContext dtc,
 813                                       DropTargetContextPeer dtcp);
 814     }
 815 
 816     /*
 817      * Accessor instances are initialized in the static initializers of
 818      * corresponding AWT classes by using setters defined below.
 819      */
 820     private static ComponentAccessor componentAccessor;
 821     private static ContainerAccessor containerAccessor;
 822     private static WindowAccessor windowAccessor;
 823     private static AWTEventAccessor awtEventAccessor;
 824     private static InputEventAccessor inputEventAccessor;
 825     private static FrameAccessor frameAccessor;
 826     private static KeyboardFocusManagerAccessor kfmAccessor;
 827     private static MenuComponentAccessor menuComponentAccessor;
 828     private static EventQueueAccessor eventQueueAccessor;
 829     private static PopupMenuAccessor popupMenuAccessor;
 830     private static FileDialogAccessor fileDialogAccessor;
 831     private static ScrollPaneAdjustableAccessor scrollPaneAdjustableAccessor;
 832     private static CheckboxMenuItemAccessor checkboxMenuItemAccessor;
 833     private static CursorAccessor cursorAccessor;
 834     private static MenuBarAccessor menuBarAccessor;
 835     private static MenuItemAccessor menuItemAccessor;
 836     private static MenuAccessor menuAccessor;
 837     private static KeyEventAccessor keyEventAccessor;
 838     private static ClientPropertyKeyAccessor clientPropertyKeyAccessor;
 839     private static SystemTrayAccessor systemTrayAccessor;
 840     private static TrayIconAccessor trayIconAccessor;
 841     private static DefaultKeyboardFocusManagerAccessor defaultKeyboardFocusManagerAccessor;
 842     private static SequencedEventAccessor sequencedEventAccessor;
 843     private static ToolkitAccessor toolkitAccessor;
 844     private static InvocationEventAccessor invocationEventAccessor;
 845     private static SystemColorAccessor systemColorAccessor;
 846     private static AccessibleContextAccessor accessibleContextAccessor;
 847     private static DragSourceContextAccessor dragSourceContextAccessor;
 848     private static DropTargetContextAccessor dropTargetContextAccessor;
 849 
 850     /*
 851      * Set an accessor object for the java.awt.Component class.
 852      */
 853     public static void setComponentAccessor(ComponentAccessor ca) {
 854         componentAccessor = ca;
 855     }
 856 
 857     /*
 858      * Retrieve the accessor object for the java.awt.Component class.
 859      */
 860     public static ComponentAccessor getComponentAccessor() {
 861         if (componentAccessor == null) {
 862             unsafe.ensureClassInitialized(Component.class);
 863         }
 864 
 865         return componentAccessor;
 866     }
 867 
 868     /*


1289      public static void setSystemColorAccessor(SystemColorAccessor systemColorAccessor) {
1290          AWTAccessor.systemColorAccessor = systemColorAccessor;
1291      }
1292 
1293     /*
1294      * Get the accessor object for the javax.accessibility.AccessibleContext class.
1295      */
1296     public static AccessibleContextAccessor getAccessibleContextAccessor() {
1297         if (accessibleContextAccessor == null) {
1298             unsafe.ensureClassInitialized(AccessibleContext.class);
1299         }
1300         return accessibleContextAccessor;
1301     }
1302 
1303    /*
1304     * Set the accessor object for the javax.accessibility.AccessibleContext class.
1305     */
1306     public static void setAccessibleContextAccessor(AccessibleContextAccessor accessor) {
1307         AWTAccessor.accessibleContextAccessor = accessor;
1308     }
1309 
1310     /*
1311      * Get the accessor object for the java.awt.dnd.DragSourceContext class.
1312      */
1313     public static DragSourceContextAccessor getDragSourceContextAccessor() {
1314         if (dragSourceContextAccessor == null) {
1315             unsafe.ensureClassInitialized(DragSourceContext.class);
1316         }
1317         return dragSourceContextAccessor;
1318     }
1319 
1320     /*
1321      * Set the accessor object for the java.awt.dnd.DragSourceContext class.
1322      */
1323     public static void setDragSourceContextAccessor(DragSourceContextAccessor accessor) {
1324         AWTAccessor.dragSourceContextAccessor = accessor;
1325     }
1326 
1327     /*
1328      * Get the accessor object for the java.awt.dnd.DropTargetContext class.
1329      */
1330     public static DropTargetContextAccessor getDropTargetContextAccessor() {
1331         if (dropTargetContextAccessor == null) {
1332             unsafe.ensureClassInitialized(DropTargetContext.class);
1333         }
1334         return dropTargetContextAccessor;
1335     }
1336 
1337     /*
1338      * Set the accessor object for the java.awt.dnd.DropTargetContext class.
1339      */
1340     public static void setDropTargetContextAccessor(DropTargetContextAccessor accessor) {
1341         AWTAccessor.dropTargetContextAccessor = accessor;
1342     }
1343 
1344 }