mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-11 22:19:43 +00:00
6823138: Need to replace ComponentAccessor with AWTAccessor
Reviewed-by: art, anthony
This commit is contained in:
parent
7eb100548d
commit
f4e9916898
@ -871,7 +871,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
return comp.canBeFocusOwner();
|
||||
}
|
||||
|
||||
public boolean isVisible_NoClientCode(Component comp) {
|
||||
public boolean isVisible(Component comp) {
|
||||
return comp.isVisible_NoClientCode();
|
||||
}
|
||||
public void setRequestFocusController
|
||||
@ -885,6 +885,71 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
public void setAppContext(Component comp, AppContext appContext) {
|
||||
comp.appContext = appContext;
|
||||
}
|
||||
public Container getParent(Component comp) {
|
||||
return comp.getParent_NoClientCode();
|
||||
}
|
||||
public void setParent(Component comp, Container parent) {
|
||||
comp.parent = parent;
|
||||
}
|
||||
public void setSize(Component comp, int width, int height) {
|
||||
comp.width = width;
|
||||
comp.height = height;
|
||||
}
|
||||
public Point getLocation(Component comp) {
|
||||
return comp.location_NoClientCode();
|
||||
}
|
||||
public void setLocation(Component comp, int x, int y) {
|
||||
comp.x = x;
|
||||
comp.y = y;
|
||||
}
|
||||
public boolean isEnabled(Component comp) {
|
||||
return comp.isEnabledImpl();
|
||||
}
|
||||
public boolean isDisplayable(Component comp) {
|
||||
return comp.peer != null;
|
||||
}
|
||||
public Cursor getCursor(Component comp) {
|
||||
return comp.getCursor_NoClientCode();
|
||||
}
|
||||
public ComponentPeer getPeer(Component comp) {
|
||||
return comp.peer;
|
||||
}
|
||||
public void setPeer(Component comp, ComponentPeer peer) {
|
||||
comp.peer = peer;
|
||||
}
|
||||
public boolean isLightweight(Component comp) {
|
||||
return (comp.peer instanceof LightweightPeer);
|
||||
}
|
||||
public boolean getIgnoreRepaint(Component comp) {
|
||||
return comp.ignoreRepaint;
|
||||
}
|
||||
public int getWidth(Component comp) {
|
||||
return comp.width;
|
||||
}
|
||||
public int getHeight(Component comp) {
|
||||
return comp.height;
|
||||
}
|
||||
public int getX(Component comp) {
|
||||
return comp.x;
|
||||
}
|
||||
public int getY(Component comp) {
|
||||
return comp.y;
|
||||
}
|
||||
public Color getForeground(Component comp) {
|
||||
return comp.foreground;
|
||||
}
|
||||
public Color getBackground(Component comp) {
|
||||
return comp.background;
|
||||
}
|
||||
public void setBackground(Component comp, Color background) {
|
||||
comp.background = background;
|
||||
}
|
||||
public Font getFont(Component comp) {
|
||||
return comp.getFont_NoClientCode();
|
||||
}
|
||||
public void processEvent(Component comp, AWTEvent e) {
|
||||
comp.processEvent(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -8021,7 +8086,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
Container getNativeContainer() {
|
||||
Container p = parent;
|
||||
while (p != null && p.peer instanceof LightweightPeer) {
|
||||
p = p.getParent();
|
||||
p = p.getParent_NoClientCode();
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
@ -3964,6 +3964,18 @@ public class Window extends Container implements Accessible {
|
||||
public void setLWRequestStatus(Window changed, boolean status) {
|
||||
changed.syncLWRequests = status;
|
||||
}
|
||||
|
||||
public boolean isAutoRequestFocus(Window w) {
|
||||
return w.autoRequestFocus;
|
||||
}
|
||||
|
||||
public boolean isTrayIconWindow(Window w) {
|
||||
return w.isTrayIconWindow;
|
||||
}
|
||||
|
||||
public void setTrayIconWindow(Window w, boolean isTrayIconWindow) {
|
||||
w.isTrayIconWindow = isTrayIconWindow;
|
||||
}
|
||||
}); // WindowAccessor
|
||||
} // static
|
||||
|
||||
|
||||
@ -98,7 +98,7 @@ public final class AWTAccessor {
|
||||
* Returns whether the component is visible without invoking
|
||||
* any client code.
|
||||
*/
|
||||
boolean isVisible_NoClientCode(Component comp);
|
||||
boolean isVisible(Component comp);
|
||||
|
||||
/**
|
||||
* Sets the RequestFocusController.
|
||||
@ -114,6 +114,112 @@ public final class AWTAccessor {
|
||||
* Sets the appContext of the component.
|
||||
*/
|
||||
void setAppContext(Component comp, AppContext appContext);
|
||||
|
||||
/**
|
||||
* Returns the parent of the component.
|
||||
*/
|
||||
Container getParent(Component comp);
|
||||
|
||||
/**
|
||||
* Sets the parent of the component to the specified parent.
|
||||
*/
|
||||
void setParent(Component comp, Container parent);
|
||||
|
||||
/**
|
||||
* Resizes the component to the specified width and height.
|
||||
*/
|
||||
void setSize(Component comp, int width, int height);
|
||||
|
||||
/**
|
||||
* Returns the location of the component.
|
||||
*/
|
||||
Point getLocation(Component comp);
|
||||
|
||||
/**
|
||||
* Moves the component to the new location.
|
||||
*/
|
||||
void setLocation(Component comp, int x, int y);
|
||||
|
||||
/**
|
||||
* Determines whether this component is enabled.
|
||||
*/
|
||||
boolean isEnabled(Component comp);
|
||||
|
||||
/**
|
||||
* Determines whether this component is displayable.
|
||||
*/
|
||||
boolean isDisplayable(Component comp);
|
||||
|
||||
/**
|
||||
* Gets the cursor set in the component.
|
||||
*/
|
||||
Cursor getCursor(Component comp);
|
||||
|
||||
/**
|
||||
* Returns the peer of the component.
|
||||
*/
|
||||
ComponentPeer getPeer(Component comp);
|
||||
|
||||
/**
|
||||
* Sets the peer of the component to the specified peer.
|
||||
*/
|
||||
void setPeer(Component comp, ComponentPeer peer);
|
||||
|
||||
/**
|
||||
* Determines whether this component is lightweight.
|
||||
*/
|
||||
boolean isLightweight(Component comp);
|
||||
|
||||
/**
|
||||
* Returns whether or not paint messages received from
|
||||
* the operating system should be ignored.
|
||||
*/
|
||||
boolean getIgnoreRepaint(Component comp);
|
||||
|
||||
/**
|
||||
* Returns the width of the component.
|
||||
*/
|
||||
int getWidth(Component comp);
|
||||
|
||||
/**
|
||||
* Returns the height of the component.
|
||||
*/
|
||||
int getHeight(Component comp);
|
||||
|
||||
/**
|
||||
* Returns the x coordinate of the component.
|
||||
*/
|
||||
int getX(Component comp);
|
||||
|
||||
/**
|
||||
* Returns the y coordinate of the component.
|
||||
*/
|
||||
int getY(Component comp);
|
||||
|
||||
/**
|
||||
* Gets the foreground color of this component.
|
||||
*/
|
||||
Color getForeground(Component comp);
|
||||
|
||||
/**
|
||||
* Gets the background color of this component.
|
||||
*/
|
||||
Color getBackground(Component comp);
|
||||
|
||||
/**
|
||||
* Sets the background of this component to the specified color.
|
||||
*/
|
||||
void setBackground(Component comp, Color background);
|
||||
|
||||
/**
|
||||
* Gets the font of the component.
|
||||
*/
|
||||
Font getFont(Component comp);
|
||||
|
||||
/**
|
||||
* Processes events occurring on this component.
|
||||
*/
|
||||
void processEvent(Component comp, AWTEvent e);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -169,6 +275,22 @@ public final class AWTAccessor {
|
||||
* components in the specified window to the specified value.
|
||||
*/
|
||||
void setLWRequestStatus(Window changed, boolean status);
|
||||
|
||||
/**
|
||||
* Indicates whether this window should receive focus on subsequently
|
||||
* being shown, or being moved to the front.
|
||||
*/
|
||||
boolean isAutoRequestFocus(Window w);
|
||||
|
||||
/**
|
||||
* Indicates whether the specified window is an utility window for TrayIcon.
|
||||
*/
|
||||
boolean isTrayIconWindow(Window w);
|
||||
|
||||
/**
|
||||
* Marks the specified window as an utility window for TrayIcon.
|
||||
*/
|
||||
void setTrayIconWindow(Window w, boolean isTrayIconWindow);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -1,483 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2007 Sun Microsystems, Inc. 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. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package sun.awt;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.AWTEvent;
|
||||
import java.awt.Font;
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Point;
|
||||
|
||||
import java.awt.peer.ComponentPeer;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
/**
|
||||
* A collection of methods for modifying package private fields in AWT components.
|
||||
* This class is meant to be used by Peer code only. Previously peer code
|
||||
* got around this problem by modifying fields from native code. However
|
||||
* as we move away from native code to Pure-java peers we need this class.
|
||||
*
|
||||
* @author Bino George
|
||||
*/
|
||||
|
||||
|
||||
public class ComponentAccessor
|
||||
{
|
||||
private static Class componentClass;
|
||||
private static Field fieldX;
|
||||
private static Field fieldY;
|
||||
private static Field fieldWidth;
|
||||
private static Field fieldHeight;
|
||||
private static Method methodGetParentNoClientCode;
|
||||
private static Method methodGetFontNoClientCode;
|
||||
private static Method methodProcessEvent;
|
||||
private static Method methodEnableEvents;
|
||||
private static Field fieldParent;
|
||||
private static Field fieldBackground;
|
||||
private static Field fieldForeground;
|
||||
private static Field fieldFont;
|
||||
private static Field fieldPacked;
|
||||
private static Field fieldIgnoreRepaint;
|
||||
private static Field fieldPeer;
|
||||
private static Field fieldVisible;
|
||||
private static Method methodIsEnabledImpl;
|
||||
private static Method methodGetCursorNoClientCode;
|
||||
private static Method methodLocationNoClientCode;
|
||||
|
||||
private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.ComponentAccessor");
|
||||
|
||||
private ComponentAccessor() {
|
||||
}
|
||||
|
||||
static {
|
||||
AccessController.doPrivileged( new PrivilegedAction() {
|
||||
public Object run() {
|
||||
try {
|
||||
componentClass = Class.forName("java.awt.Component");
|
||||
fieldX = componentClass.getDeclaredField("x");
|
||||
fieldX.setAccessible(true);
|
||||
fieldY = componentClass.getDeclaredField("y");
|
||||
fieldY.setAccessible(true);
|
||||
fieldWidth = componentClass.getDeclaredField("width");
|
||||
fieldWidth.setAccessible(true);
|
||||
fieldHeight = componentClass.getDeclaredField("height");
|
||||
fieldHeight.setAccessible(true);
|
||||
fieldForeground = componentClass.getDeclaredField("foreground");
|
||||
fieldForeground.setAccessible(true);
|
||||
fieldBackground = componentClass.getDeclaredField("background");
|
||||
fieldBackground.setAccessible(true);
|
||||
fieldFont = componentClass.getDeclaredField("font");
|
||||
fieldFont.setAccessible(true);
|
||||
methodGetParentNoClientCode = componentClass.getDeclaredMethod("getParent_NoClientCode", (Class[]) null);
|
||||
methodGetParentNoClientCode.setAccessible(true);
|
||||
methodGetFontNoClientCode = componentClass.getDeclaredMethod("getFont_NoClientCode", (Class[]) null);
|
||||
methodGetFontNoClientCode.setAccessible(true);
|
||||
Class[] argTypes = { AWTEvent.class };
|
||||
methodProcessEvent = componentClass.getDeclaredMethod("processEvent",argTypes);
|
||||
methodProcessEvent.setAccessible(true);
|
||||
Class[] argTypesForMethodEnableEvents = { Long.TYPE };
|
||||
methodEnableEvents = componentClass.getDeclaredMethod("enableEvents",argTypesForMethodEnableEvents);
|
||||
methodEnableEvents.setAccessible(true);
|
||||
|
||||
fieldParent = componentClass.getDeclaredField("parent");
|
||||
fieldParent.setAccessible(true);
|
||||
fieldPacked = componentClass.getDeclaredField("isPacked");
|
||||
fieldPacked.setAccessible(true);
|
||||
fieldIgnoreRepaint = componentClass.getDeclaredField("ignoreRepaint");
|
||||
fieldIgnoreRepaint.setAccessible(true);
|
||||
|
||||
fieldPeer = componentClass.getDeclaredField("peer");
|
||||
fieldPeer.setAccessible(true);
|
||||
|
||||
fieldVisible = componentClass.getDeclaredField("visible");
|
||||
fieldVisible.setAccessible(true);
|
||||
|
||||
methodIsEnabledImpl = componentClass.getDeclaredMethod("isEnabledImpl", (Class[]) null);
|
||||
methodIsEnabledImpl.setAccessible(true);
|
||||
|
||||
methodGetCursorNoClientCode = componentClass.getDeclaredMethod("getCursor_NoClientCode", (Class[]) null);
|
||||
methodGetCursorNoClientCode.setAccessible(true);
|
||||
|
||||
methodLocationNoClientCode = componentClass.getDeclaredMethod("location_NoClientCode", (Class[]) null);
|
||||
methodLocationNoClientCode.setAccessible(true);
|
||||
}
|
||||
catch (NoSuchFieldException e) {
|
||||
log.fine("Unable to initialize ComponentAccessor", e);
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
log.fine("Unable to initialize ComponentAccessor", e);
|
||||
}
|
||||
catch (NoSuchMethodException e) {
|
||||
log.fine("Unable to initialize ComponentAccessor", e);
|
||||
}
|
||||
// to please javac
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void setX(Component c, int x)
|
||||
{
|
||||
try {
|
||||
fieldX.setInt(c,x);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
log.fine("Unable to access the Component object", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setY(Component c, int y)
|
||||
{
|
||||
try {
|
||||
fieldY.setInt(c,y);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
log.fine("Unable to access the Component object", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setWidth(Component c, int width)
|
||||
{
|
||||
try {
|
||||
fieldWidth.setInt(c,width);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
log.fine("Unable to access the Component object", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setHeight(Component c, int height)
|
||||
{
|
||||
try {
|
||||
fieldHeight.setInt(c,height);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
log.fine("Unable to access the Component object", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setBounds(Component c, int x, int y, int width, int height)
|
||||
{
|
||||
try {
|
||||
fieldX.setInt(c,x);
|
||||
fieldY.setInt(c,y);
|
||||
fieldWidth.setInt(c,width);
|
||||
fieldHeight.setInt(c,height);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
log.fine("Unable to access the Component object", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getX(Component c) {
|
||||
try {
|
||||
return fieldX.getInt(c);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
log.fine("Unable to access the Component object", e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int getY(Component c) {
|
||||
try {
|
||||
return fieldY.getInt(c);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
log.fine("Unable to access the Component object", e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int getWidth(Component c) {
|
||||
try {
|
||||
return fieldWidth.getInt(c);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
log.fine("Unable to access the Component object", e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int getHeight(Component c) {
|
||||
try {
|
||||
return fieldHeight.getInt(c);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
log.fine("Unable to access the Component object", e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static boolean getIsPacked(Component c) {
|
||||
try {
|
||||
return fieldPacked.getBoolean(c);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
log.fine("Unable to access the Component object", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Container getParent_NoClientCode(Component c) {
|
||||
Container parent=null;
|
||||
|
||||
try {
|
||||
parent = (Container) methodGetParentNoClientCode.invoke(c, (Object[]) null);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
log.fine("Unable to access the Component object", e);
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
log.fine("Unable to invoke on the Component object", e);
|
||||
}
|
||||
|
||||
return parent;
|
||||
}
|
||||
|
||||
public static Font getFont_NoClientCode(Component c) {
|
||||
Font font=null;
|
||||
|
||||
try {
|
||||
font = (Font) methodGetFontNoClientCode.invoke(c, (Object[]) null);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
log.fine("Unable to access the Component object", e);
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
log.fine("Unable to invoke on the Component object", e);
|
||||
}
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
public static void processEvent(Component c, AWTEvent event) {
|
||||
Font font=null;
|
||||
|
||||
try {
|
||||
Object[] args = new Object[1];
|
||||
args[0] = event;
|
||||
methodProcessEvent.invoke(c,args);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
log.fine("Unable to access the Component object", e);
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
log.fine("Unable to invoke on the Component object", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void enableEvents(Component c, long event_mask) {
|
||||
try {
|
||||
Object[] args = new Object[1];
|
||||
args[0] = Long.valueOf(event_mask);
|
||||
methodEnableEvents.invoke(c,args);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
log.fine("Unable to access the Component object", e);
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
log.fine("Unable to invoke on the Component object", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setParent(Component c, Container parent)
|
||||
{
|
||||
try {
|
||||
fieldParent.set(c,parent);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
log.fine("Unable to access the Component object", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Color getForeground(Component c)
|
||||
{
|
||||
Color color = null;
|
||||
try {
|
||||
color = (Color) fieldForeground.get(c);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
log.fine("Unable to access the Component object", e);
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
public static Color getBackground(Component c)
|
||||
{
|
||||
Color color = null;
|
||||
try {
|
||||
color = (Color) fieldBackground.get(c);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
log.fine("Unable to access the Component object", e);
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
public static void setBackground(Component c, Color color) {
|
||||
try {
|
||||
fieldBackground.set(c, color);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
log.fine("Unable to access the Component object", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Font getFont(Component c)
|
||||
{
|
||||
Font f = null;
|
||||
try {
|
||||
f = (Font) fieldFont.get(c);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
log.fine("Unable to access the Component object", e);
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
public static ComponentPeer getPeer(Component c) {
|
||||
ComponentPeer peer = null;
|
||||
try {
|
||||
peer = (ComponentPeer)fieldPeer.get(c);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
log.fine("Unable to access the Component object", e);
|
||||
}
|
||||
return peer;
|
||||
}
|
||||
|
||||
public static void setPeer(Component c, ComponentPeer peer) {
|
||||
try {
|
||||
fieldPeer.set(c, peer);
|
||||
} catch (IllegalAccessException e)
|
||||
{
|
||||
log.fine("Unable to access the Component object", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean getIgnoreRepaint(Component comp) {
|
||||
try {
|
||||
return fieldIgnoreRepaint.getBoolean(comp);
|
||||
}
|
||||
catch (IllegalAccessException e) {
|
||||
log.fine("Unable to access the Component object", e);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean getVisible(Component c) {
|
||||
try {
|
||||
return fieldVisible.getBoolean(c);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
log.fine("Unable to access the Component object", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isEnabledImpl(Component c) {
|
||||
boolean enabled = true;
|
||||
try {
|
||||
enabled = (Boolean) methodIsEnabledImpl.invoke(c, (Object[]) null);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
log.fine("Unable to access the Component object", e);
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
log.fine("Unable to invoke on the Component object", e);
|
||||
}
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public static Cursor getCursor_NoClientCode(Component c) {
|
||||
Cursor cursor = null;
|
||||
|
||||
try {
|
||||
cursor = (Cursor) methodGetCursorNoClientCode.invoke(c, (Object[]) null);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
log.fine("Unable to access the Component object", e);
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
log.fine("Unable to invoke on the Component object", e);
|
||||
}
|
||||
|
||||
return cursor;
|
||||
}
|
||||
|
||||
public static Point getLocation_NoClientCode(Component c) {
|
||||
Point loc = null;
|
||||
|
||||
try {
|
||||
loc = (Point) methodLocationNoClientCode.invoke(c, (Object[]) null);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
log.fine("Unable to access the Component object", e);
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
log.fine("Unable to invoke on the Component object", e);
|
||||
}
|
||||
|
||||
return loc;
|
||||
}
|
||||
|
||||
}
|
||||
@ -183,7 +183,7 @@ public abstract class GlobalCursorManager {
|
||||
}
|
||||
|
||||
if (comp instanceof Window) {
|
||||
p = ComponentAccessor.getLocation_NoClientCode(comp);
|
||||
p = AWTAccessor.getComponentAccessor().getLocation(comp);
|
||||
} else if (comp instanceof Container) {
|
||||
p = getLocationOnScreen(comp);
|
||||
}
|
||||
@ -202,7 +202,7 @@ public abstract class GlobalCursorManager {
|
||||
}
|
||||
}
|
||||
|
||||
setCursor(comp, ComponentAccessor.getCursor_NoClientCode(comp), useCache);
|
||||
setCursor(comp, AWTAccessor.getComponentAccessor().getCursor(comp), useCache);
|
||||
|
||||
} catch (IllegalComponentStateException e) {
|
||||
// Shouldn't happen, but if it does, abort.
|
||||
|
||||
@ -1118,6 +1118,18 @@ public abstract class SunToolkit extends Toolkit
|
||||
return Toolkit.getNativeContainer(c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives native peers the ability to query the closest HW component.
|
||||
* If the given component is heavyweight, then it returns this. Otherwise,
|
||||
* it goes one level up in the hierarchy and tests next component.
|
||||
*/
|
||||
public static Component getHeavyweightComponent(Component c) {
|
||||
while (c != null && AWTAccessor.getComponentAccessor().isLightweight(c)) {
|
||||
c = AWTAccessor.getComponentAccessor().getParent(c);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new input method window, with behavior as specified in
|
||||
* {@link java.awt.im.spi.InputMethodContext#createInputMethodWindow}.
|
||||
|
||||
@ -1,96 +0,0 @@
|
||||
/*
|
||||
* Copyright 2007 Sun Microsystems, Inc. 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. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package sun.awt;
|
||||
|
||||
import java.awt.Window;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
public class WindowAccessor {
|
||||
|
||||
private static Class windowClass;
|
||||
private static Field fieldIsAutoRequestFocus;
|
||||
private static Field fieldIsTrayIconWindow;
|
||||
|
||||
private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.WindowAccessor");
|
||||
|
||||
private WindowAccessor() {
|
||||
}
|
||||
|
||||
static {
|
||||
AccessController.doPrivileged( new PrivilegedAction() {
|
||||
public Object run() {
|
||||
try {
|
||||
windowClass = Class.forName("java.awt.Window");
|
||||
fieldIsAutoRequestFocus = windowClass.getDeclaredField("autoRequestFocus");
|
||||
fieldIsAutoRequestFocus.setAccessible(true);
|
||||
fieldIsTrayIconWindow = windowClass.getDeclaredField("isTrayIconWindow");
|
||||
fieldIsTrayIconWindow.setAccessible(true);
|
||||
|
||||
} catch (NoSuchFieldException e) {
|
||||
log.fine("Unable to initialize WindowAccessor: ", e);
|
||||
} catch (ClassNotFoundException e) {
|
||||
log.fine("Unable to initialize WindowAccessor: ", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean isAutoRequestFocus(Window w) {
|
||||
try {
|
||||
return fieldIsAutoRequestFocus.getBoolean(w);
|
||||
|
||||
} catch (IllegalAccessException e) {
|
||||
log.fine("Unable to access the Window object", e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isTrayIconWindow(Window w) {
|
||||
try {
|
||||
return fieldIsTrayIconWindow.getBoolean(w);
|
||||
|
||||
} catch (IllegalAccessException e) {
|
||||
log.fine("Unable to access the Window object", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void setTrayIconWindow(Window w, boolean isTrayIconWindow) {
|
||||
try {
|
||||
fieldIsTrayIconWindow.set(w, isTrayIconWindow);
|
||||
|
||||
} catch (IllegalAccessException e) {
|
||||
log.fine("Unable to access the Window object", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -212,27 +212,6 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget
|
||||
return true;
|
||||
}
|
||||
|
||||
static XComponentPeer getNativeContainer(Component comp) {
|
||||
if (comp == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
synchronized(comp.getTreeLock()) {
|
||||
while (comp != null && (ComponentAccessor.getPeer(comp) instanceof LightweightPeer)) {
|
||||
comp = ComponentAccessor.getParent_NoClientCode(comp);
|
||||
}
|
||||
|
||||
if (comp != null) {
|
||||
ComponentPeer peer = ComponentAccessor.getPeer(comp);
|
||||
if (peer != null && peer instanceof XComponentPeer) {
|
||||
return (XComponentPeer)peer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
* FOCUS STUFF
|
||||
*************************************************/
|
||||
@ -508,13 +487,14 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget
|
||||
}
|
||||
|
||||
XWindowPeer getParentTopLevel() {
|
||||
Container parent = (target instanceof Container) ? ((Container)target) : (ComponentAccessor.getParent_NoClientCode(target));
|
||||
AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
|
||||
Container parent = (target instanceof Container) ? ((Container)target) : (compAccessor.getParent(target));
|
||||
// Search for parent window
|
||||
while (parent != null && !(parent instanceof Window)) {
|
||||
parent = ComponentAccessor.getParent_NoClientCode(parent);
|
||||
parent = compAccessor.getParent(parent);
|
||||
}
|
||||
if (parent != null) {
|
||||
return (XWindowPeer)ComponentAccessor.getPeer(parent);
|
||||
return (XWindowPeer)compAccessor.getPeer(parent);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -828,7 +808,7 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget
|
||||
|
||||
public void endLayout() {
|
||||
if (!paintPending && !paintArea.isEmpty()
|
||||
&& !ComponentAccessor.getIgnoreRepaint(target))
|
||||
&& !AWTAccessor.getComponentAccessor().getIgnoreRepaint(target))
|
||||
{
|
||||
// if not waiting for native painting repaint damaged area
|
||||
postEvent(new PaintEvent(target, PaintEvent.PAINT,
|
||||
@ -1239,11 +1219,11 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget
|
||||
// End of multi-buffering
|
||||
|
||||
public void notifyTextComponentChange(boolean add){
|
||||
Container parent = ComponentAccessor.getParent_NoClientCode(target);
|
||||
Container parent = AWTAccessor.getComponentAccessor().getParent(target);
|
||||
while(!(parent == null ||
|
||||
parent instanceof java.awt.Frame ||
|
||||
parent instanceof java.awt.Dialog)) {
|
||||
parent = ComponentAccessor.getParent_NoClientCode(parent);
|
||||
parent = AWTAccessor.getComponentAccessor().getParent(parent);
|
||||
}
|
||||
|
||||
/* FIX ME - FIX ME need to implement InputMethods
|
||||
|
||||
@ -32,7 +32,7 @@ import java.awt.event.ComponentEvent;
|
||||
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
import sun.awt.ComponentAccessor;
|
||||
import sun.awt.AWTAccessor;
|
||||
|
||||
/**
|
||||
* This class implements window which serves as content window for decorated frames.
|
||||
@ -135,8 +135,7 @@ public final class XContentWindow extends XWindow {
|
||||
// NOTE: This method may be called by privileged threads.
|
||||
// DO NOT INVOKE CLIENT CODE ON THIS THREAD!
|
||||
public void handleResize(Rectangle bounds) {
|
||||
ComponentAccessor.setWidth((Component)target, bounds.width);
|
||||
ComponentAccessor.setHeight((Component)target, bounds.height);
|
||||
AWTAccessor.getComponentAccessor().setSize((Component)target, bounds.width, bounds.height);
|
||||
postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_RESIZED));
|
||||
}
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ import java.awt.event.WindowEvent;
|
||||
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
import sun.awt.ComponentAccessor;
|
||||
import sun.awt.AWTAccessor;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
abstract class XDecoratedPeer extends XWindowPeer {
|
||||
@ -167,10 +167,11 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
}
|
||||
|
||||
public Graphics getGraphics() {
|
||||
AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
|
||||
return getGraphics(content.surfaceData,
|
||||
ComponentAccessor.getForeground(target),
|
||||
ComponentAccessor.getBackground(target),
|
||||
ComponentAccessor.getFont_NoClientCode(target));
|
||||
compAccessor.getForeground(target),
|
||||
compAccessor.getBackground(target),
|
||||
compAccessor.getFont(target));
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
@ -404,8 +405,7 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
|
||||
public void handleMoved(WindowDimensions dims) {
|
||||
Point loc = dims.getLocation();
|
||||
ComponentAccessor.setX((Component)target, loc.x);
|
||||
ComponentAccessor.setY((Component)target, loc.y);
|
||||
AWTAccessor.getComponentAccessor().setLocation((Component)target, loc.x, loc.y);
|
||||
postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_MOVED));
|
||||
}
|
||||
|
||||
@ -511,8 +511,8 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
// its location changes.
|
||||
Point oldLocation = getLocation();
|
||||
|
||||
Point newLocation = new Point(ComponentAccessor.getX((Component)target),
|
||||
ComponentAccessor.getY((Component)target));
|
||||
Point newLocation = new Point(AWTAccessor.getComponentAccessor().getX((Component)target),
|
||||
AWTAccessor.getComponentAccessor().getY((Component)target));
|
||||
|
||||
if (!newLocation.equals(oldLocation)) {
|
||||
handleMoved(newDimensions);
|
||||
@ -710,10 +710,7 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
updateChildrenSizes();
|
||||
|
||||
// Bounds of the window
|
||||
Rectangle targetBounds = new Rectangle(ComponentAccessor.getX((Component)target),
|
||||
ComponentAccessor.getY((Component)target),
|
||||
ComponentAccessor.getWidth((Component)target),
|
||||
ComponentAccessor.getHeight((Component)target));
|
||||
Rectangle targetBounds = AWTAccessor.getComponentAccessor().getBounds((Component)target);
|
||||
|
||||
Point newLocation = targetBounds.getLocation();
|
||||
if (xe.get_send_event() || runningWM == XWM.NO_WM || XWM.isNonReparentingWM()) {
|
||||
@ -1042,10 +1039,11 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
}
|
||||
|
||||
final void dumpTarget() {
|
||||
int getWidth = ComponentAccessor.getWidth((Component)target);
|
||||
int getHeight = ComponentAccessor.getHeight((Component)target);
|
||||
int getTargetX = ComponentAccessor.getX((Component)target);
|
||||
int getTargetY = ComponentAccessor.getY((Component)target);
|
||||
AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
|
||||
int getWidth = compAccessor.getWidth((Component)target);
|
||||
int getHeight = compAccessor.getHeight((Component)target);
|
||||
int getTargetX = compAccessor.getX((Component)target);
|
||||
int getTargetY = compAccessor.getY((Component)target);
|
||||
System.err.println(">>> Target: " + getTargetX + ", " + getTargetY + ", " + getWidth + ", " + getHeight);
|
||||
}
|
||||
|
||||
@ -1208,7 +1206,7 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
Window owner = XWindowPeer.getDecoratedOwner(actualFocusedWindow);
|
||||
|
||||
if (owner != null && owner == target) {
|
||||
setActualFocusedWindow((XWindowPeer) ComponentAccessor.getPeer(actualFocusedWindow));
|
||||
setActualFocusedWindow((XWindowPeer) AWTAccessor.getComponentAccessor().getPeer(actualFocusedWindow));
|
||||
}
|
||||
}
|
||||
super.handleWindowFocusOut(oppositeWindow, serial);
|
||||
|
||||
@ -28,7 +28,7 @@ import java.util.*;
|
||||
import java.awt.*;
|
||||
import java.awt.peer.*;
|
||||
import java.awt.event.*;
|
||||
import sun.awt.ComponentAccessor;
|
||||
import sun.awt.AWTAccessor;
|
||||
|
||||
import sun.awt.*;
|
||||
|
||||
@ -117,7 +117,7 @@ class XDialogPeer extends XDecoratedPeer implements DialogPeer {
|
||||
try {
|
||||
javaToplevels = XWindowPeer.collectJavaToplevels();
|
||||
for (Window w : toBlock) {
|
||||
XWindowPeer wp = (XWindowPeer)ComponentAccessor.getPeer(w);
|
||||
XWindowPeer wp = (XWindowPeer)AWTAccessor.getComponentAccessor().getPeer(w);
|
||||
if (wp != null) {
|
||||
wp.setModalBlocked((Dialog)target, true, javaToplevels);
|
||||
}
|
||||
@ -139,7 +139,7 @@ class XDialogPeer extends XDecoratedPeer implements DialogPeer {
|
||||
XWindowPeer focusedWindowPeer = null;
|
||||
|
||||
if (focusedWindow != null) {
|
||||
focusedWindowPeer = (XWindowPeer)ComponentAccessor.getPeer(focusedWindow);
|
||||
focusedWindowPeer = (XWindowPeer)AWTAccessor.getComponentAccessor().getPeer(focusedWindow);
|
||||
} else {
|
||||
/*
|
||||
* For the case when a potential blocked window is not yet focused
|
||||
|
||||
@ -39,11 +39,10 @@ import java.util.*;
|
||||
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
import sun.awt.ComponentAccessor;
|
||||
|
||||
import sun.awt.dnd.SunDragSourceContextPeer;
|
||||
import sun.awt.dnd.SunDropTargetContextPeer;
|
||||
import sun.awt.SunToolkit;
|
||||
import sun.awt.AWTAccessor;
|
||||
|
||||
/**
|
||||
* The XDragSourceContextPeer class is the class responsible for handling
|
||||
@ -117,7 +116,7 @@ public final class XDragSourceContextPeer
|
||||
XWindowPeer wpeer = null;
|
||||
|
||||
for (c = component; c != null && !(c instanceof Window);
|
||||
c = ComponentAccessor.getParent_NoClientCode(c));
|
||||
c = AWTAccessor.getComponentAccessor().getParent(c));
|
||||
|
||||
if (c instanceof Window) {
|
||||
wpeer = (XWindowPeer)c.getPeer();
|
||||
|
||||
@ -27,7 +27,7 @@ package sun.awt.X11;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Toolkit;
|
||||
import sun.awt.ComponentAccessor;
|
||||
import sun.awt.AWTAccessor;
|
||||
|
||||
public class XEmbedChildProxy extends Component {
|
||||
long handle;
|
||||
@ -39,8 +39,9 @@ public class XEmbedChildProxy extends Component {
|
||||
|
||||
public void addNotify() {
|
||||
synchronized(getTreeLock()) {
|
||||
if (ComponentAccessor.getPeer(this) == null) {
|
||||
ComponentAccessor.setPeer(this, ((XToolkit)Toolkit.getDefaultToolkit()).createEmbedProxy(this));
|
||||
if (AWTAccessor.getComponentAccessor().getPeer(this) == null) {
|
||||
AWTAccessor.getComponentAccessor().
|
||||
setPeer(this,((XToolkit)Toolkit.getDefaultToolkit()).createEmbedProxy(this));
|
||||
}
|
||||
super.addNotify();
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ import java.awt.peer.LightweightPeer;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import sun.awt.ComponentAccessor;
|
||||
import sun.awt.AWTAccessor;
|
||||
|
||||
import sun.awt.GlobalCursorManager;
|
||||
import sun.awt.SunToolkit;
|
||||
@ -94,11 +94,11 @@ public final class XGlobalCursorManager extends GlobalCursorManager {
|
||||
nc = nativeContainer.get();
|
||||
}
|
||||
} else {
|
||||
nc = getNativeContainer(comp);
|
||||
nc = SunToolkit.getHeavyweightComponent(comp);
|
||||
}
|
||||
|
||||
if (nc != null) {
|
||||
ComponentPeer nc_peer = ComponentAccessor.getPeer(nc);
|
||||
ComponentPeer nc_peer = AWTAccessor.getComponentAccessor().getPeer(nc);
|
||||
if (nc_peer instanceof XComponentPeer) {
|
||||
synchronized (this) {
|
||||
nativeContainer = new WeakReference<Component>(nc);
|
||||
@ -133,13 +133,6 @@ public final class XGlobalCursorManager extends GlobalCursorManager {
|
||||
updateGrabbedCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
|
||||
private Component getNativeContainer(Component comp) {
|
||||
while (comp != null && ComponentAccessor.getPeer(comp) instanceof LightweightPeer) {
|
||||
comp = ComponentAccessor.getParent_NoClientCode(comp);
|
||||
}
|
||||
return comp;
|
||||
}
|
||||
|
||||
protected void getCursorPos(Point p) {
|
||||
|
||||
if (!((XToolkit)Toolkit.getDefaultToolkit()).getLastCursorPos(p)) {
|
||||
@ -186,27 +179,29 @@ public final class XGlobalCursorManager extends GlobalCursorManager {
|
||||
}
|
||||
|
||||
private Cursor getCapableCursor(Component comp) {
|
||||
AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
|
||||
|
||||
Component c = comp;
|
||||
while ((c != null) && !(c instanceof Window)
|
||||
&& ComponentAccessor.isEnabledImpl(c)
|
||||
&& ComponentAccessor.getVisible(c)
|
||||
&& ComponentAccessor.getPeer(c) != null)
|
||||
&& compAccessor.isEnabled(c)
|
||||
&& compAccessor.isVisible(c)
|
||||
&& compAccessor.isDisplayable(c))
|
||||
{
|
||||
c = ComponentAccessor.getParent_NoClientCode(c);
|
||||
c = compAccessor.getParent(c);
|
||||
}
|
||||
if (c instanceof Window) {
|
||||
return (ComponentAccessor.isEnabledImpl(c)
|
||||
&& ComponentAccessor.getVisible(c)
|
||||
&& (ComponentAccessor.getPeer(c) != null)
|
||||
&& ComponentAccessor.isEnabledImpl(comp))
|
||||
return (compAccessor.isEnabled(c)
|
||||
&& compAccessor.isVisible(c)
|
||||
&& compAccessor.isDisplayable(c)
|
||||
&& compAccessor.isEnabled(comp))
|
||||
?
|
||||
ComponentAccessor.getCursor_NoClientCode(comp)
|
||||
compAccessor.getCursor(comp)
|
||||
:
|
||||
Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
|
||||
} else if (c == null) {
|
||||
return null;
|
||||
}
|
||||
return getCapableCursor(ComponentAccessor.getParent_NoClientCode(c));
|
||||
return getCapableCursor(compAccessor.getParent(c));
|
||||
}
|
||||
|
||||
/* This methods needs to be called from within XToolkit.awtLock / XToolkit.awtUnlock section. */
|
||||
|
||||
@ -60,7 +60,7 @@ import javax.swing.text.JTextComponent;
|
||||
import javax.swing.plaf.BorderUIResource;
|
||||
import java.awt.im.InputMethodRequests;
|
||||
import sun.awt.CausedFocusEvent;
|
||||
import sun.awt.ComponentAccessor;
|
||||
import sun.awt.AWTAccessor;
|
||||
|
||||
|
||||
class XTextAreaPeer extends XComponentPeer implements TextAreaPeer {
|
||||
@ -119,13 +119,14 @@ class XTextAreaPeer extends XComponentPeer implements TextAreaPeer {
|
||||
textPane.setVisible(true);
|
||||
textPane.validate();
|
||||
|
||||
foreground = ComponentAccessor.getForeground(target);
|
||||
AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
|
||||
foreground = compAccessor.getForeground(target);
|
||||
if (foreground == null) {
|
||||
foreground = SystemColor.textText;
|
||||
}
|
||||
setForeground(foreground);
|
||||
|
||||
background = ComponentAccessor.getBackground(target);
|
||||
background = compAccessor.getBackground(target);
|
||||
if (background == null) {
|
||||
if (target.isEditable()) background = SystemColor.text;
|
||||
else background = SystemColor.control;
|
||||
@ -134,8 +135,8 @@ class XTextAreaPeer extends XComponentPeer implements TextAreaPeer {
|
||||
|
||||
if (!target.isBackgroundSet()) {
|
||||
// This is a way to set the background color of the TextArea
|
||||
// without calling setBackground - go through reflection
|
||||
ComponentAccessor.setBackground(target, background);
|
||||
// without calling setBackground - go through accessor
|
||||
compAccessor.setBackground(target, background);
|
||||
}
|
||||
if (!target.isForegroundSet()) {
|
||||
target.setForeground(SystemColor.textText);
|
||||
@ -311,13 +312,13 @@ class XTextAreaPeer extends XComponentPeer implements TextAreaPeer {
|
||||
}
|
||||
|
||||
void handleJavaKeyEvent(KeyEvent e) {
|
||||
ComponentAccessor.processEvent(jtext,e);
|
||||
AWTAccessor.getComponentAccessor().processEvent(jtext,e);
|
||||
}
|
||||
|
||||
public boolean handlesWheelScrolling() { return true; }
|
||||
|
||||
void handleJavaMouseWheelEvent(MouseWheelEvent e) {
|
||||
ComponentAccessor.processEvent(textPane,e);
|
||||
AWTAccessor.getComponentAccessor().processEvent(textPane,e);
|
||||
}
|
||||
|
||||
public void handleJavaMouseEvent( MouseEvent e ) {
|
||||
@ -1111,7 +1112,7 @@ class XTextAreaPeer extends XComponentPeer implements TextAreaPeer {
|
||||
this.xwin = xwin;
|
||||
setDoubleBuffered(true);
|
||||
jt.addFocusListener(this);
|
||||
ComponentAccessor.setParent(this,parent);
|
||||
AWTAccessor.getComponentAccessor().setParent(this,parent);
|
||||
setViewportBorder(new BevelBorder(false,SystemColor.controlDkShadow,SystemColor.controlLtHighlight) );
|
||||
this.jtext = jt;
|
||||
setFocusable(false);
|
||||
@ -1308,7 +1309,7 @@ class XTextAreaPeer extends XComponentPeer implements TextAreaPeer {
|
||||
c = current.getButton();
|
||||
p = toLocalSpace( c, p );
|
||||
}
|
||||
ComponentAccessor.processEvent( c, newMouseEvent( c, p, event ) );
|
||||
AWTAccessor.getComponentAccessor().processEvent( c, newMouseEvent( c, p, event ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ import java.awt.im.InputMethodRequests;
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
import sun.awt.CausedFocusEvent;
|
||||
import sun.awt.ComponentAccessor;
|
||||
import sun.awt.AWTAccessor;
|
||||
|
||||
public class XTextFieldPeer extends XComponentPeer implements TextFieldPeer {
|
||||
private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XTextField");
|
||||
@ -115,13 +115,14 @@ public class XTextFieldPeer extends XComponentPeer implements TextFieldPeer {
|
||||
|
||||
setBounds(x, y, width, height, SET_BOUNDS);
|
||||
|
||||
foreground = ComponentAccessor.getForeground(target);
|
||||
AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
|
||||
foreground = compAccessor.getForeground(target);
|
||||
if (foreground == null)
|
||||
foreground = SystemColor.textText;
|
||||
|
||||
setForeground(foreground);
|
||||
|
||||
background = ComponentAccessor.getBackground(target);
|
||||
background = compAccessor.getBackground(target);
|
||||
if (background == null) {
|
||||
if (((TextField)target).isEditable()) background = SystemColor.text;
|
||||
else background = SystemColor.control;
|
||||
@ -130,8 +131,8 @@ public class XTextFieldPeer extends XComponentPeer implements TextFieldPeer {
|
||||
|
||||
if (!target.isBackgroundSet()) {
|
||||
// This is a way to set the background color of the TextArea
|
||||
// without calling setBackground - go through reflection
|
||||
ComponentAccessor.setBackground(target, background);
|
||||
// without calling setBackground - go through accessor
|
||||
compAccessor.setBackground(target, background);
|
||||
}
|
||||
if (!target.isForegroundSet()) {
|
||||
target.setForeground(SystemColor.textText);
|
||||
@ -392,7 +393,7 @@ public class XTextFieldPeer extends XComponentPeer implements TextFieldPeer {
|
||||
}
|
||||
|
||||
void handleJavaKeyEvent(KeyEvent e) {
|
||||
ComponentAccessor.processEvent(xtext,e);
|
||||
AWTAccessor.getComponentAccessor().processEvent(xtext,e);
|
||||
}
|
||||
|
||||
|
||||
@ -620,7 +621,7 @@ public class XTextFieldPeer extends XComponentPeer implements TextFieldPeer {
|
||||
this.peer = peer;
|
||||
setDoubleBuffered(true);
|
||||
setFocusable(false);
|
||||
ComponentAccessor.setParent(this,parent);
|
||||
AWTAccessor.getComponentAccessor().setParent(this,parent);
|
||||
setBackground(peer.getPeerBackground());
|
||||
setForeground(peer.getPeerForeground());
|
||||
setFont(peer.getPeerFont());
|
||||
|
||||
@ -626,7 +626,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
|
||||
Component owner =
|
||||
XKeyboardFocusManagerPeer.getCurrentNativeFocusOwner();
|
||||
if (owner != null) {
|
||||
XWindow ownerWindow = (XWindow) ComponentAccessor.getPeer(owner);
|
||||
XWindow ownerWindow = (XWindow) AWTAccessor.getComponentAccessor().getPeer(owner);
|
||||
if (ownerWindow != null) {
|
||||
w = ownerWindow.getContentWindow();
|
||||
}
|
||||
|
||||
@ -295,7 +295,7 @@ public class XTrayIconPeer implements TrayIconPeer,
|
||||
}
|
||||
|
||||
public static void suppressWarningString(Window w) {
|
||||
WindowAccessor.setTrayIconWindow(w, true);
|
||||
AWTAccessor.getWindowAccessor().setTrayIconWindow(w, true);
|
||||
}
|
||||
|
||||
public void setToolTip(String tooltip) {
|
||||
|
||||
@ -325,9 +325,9 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
|
||||
if (!(target instanceof Container) || win == null || win.getTarget() == null) {
|
||||
return false;
|
||||
}
|
||||
Container parent = ComponentAccessor.getParent_NoClientCode(win.target);
|
||||
Container parent = AWTAccessor.getComponentAccessor().getParent(win.target);
|
||||
while (parent != null && parent != target) {
|
||||
parent = ComponentAccessor.getParent_NoClientCode(parent);
|
||||
parent = AWTAccessor.getComponentAccessor().getParent(parent);
|
||||
}
|
||||
return (parent == target);
|
||||
}
|
||||
@ -560,10 +560,11 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
|
||||
int h = xe.get_height();
|
||||
|
||||
Component target = (Component)getEventSource();
|
||||
AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
|
||||
|
||||
if (!ComponentAccessor.getIgnoreRepaint(target)
|
||||
&& ComponentAccessor.getWidth(target) != 0
|
||||
&& ComponentAccessor.getHeight(target) != 0)
|
||||
if (!compAccessor.getIgnoreRepaint(target)
|
||||
&& compAccessor.getWidth(target) != 0
|
||||
&& compAccessor.getHeight(target) != 0)
|
||||
{
|
||||
handleExposeEvent(target, x, y, w, h);
|
||||
}
|
||||
@ -950,7 +951,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
|
||||
XAwtState.setComponentMouseEntered(null);
|
||||
}
|
||||
} else {
|
||||
((XComponentPeer) ComponentAccessor.getPeer(target))
|
||||
((XComponentPeer) AWTAccessor.getComponentAccessor().getPeer(target))
|
||||
.pSetCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
}
|
||||
@ -1387,7 +1388,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
|
||||
Component comp = target;
|
||||
|
||||
while (comp != null && !(comp instanceof Window)) {
|
||||
comp = ComponentAccessor.getParent_NoClientCode(comp);
|
||||
comp = AWTAccessor.getComponentAccessor().getParent(comp);
|
||||
}
|
||||
|
||||
// applets, embedded, etc - translate directly
|
||||
|
||||
@ -51,8 +51,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
import sun.awt.AWTAccessor;
|
||||
import sun.awt.ComponentAccessor;
|
||||
import sun.awt.WindowAccessor;
|
||||
import sun.awt.DisplayChangedListener;
|
||||
import sun.awt.SunToolkit;
|
||||
import sun.awt.X11GraphicsDevice;
|
||||
@ -254,7 +252,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
if (((Window)target).getWarningString() != null) {
|
||||
// accessSystemTray permission allows to display TrayIcon, TrayIcon tooltip
|
||||
// and TrayIcon balloon windows without a warning window.
|
||||
if (!WindowAccessor.isTrayIconWindow((Window)target)) {
|
||||
if (!AWTAccessor.getWindowAccessor().isTrayIconWindow((Window)target)) {
|
||||
warningWindow = new XWarningWindow((Window)target, getWindow(), this);
|
||||
}
|
||||
}
|
||||
@ -546,7 +544,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
|
||||
boolean isAutoRequestFocus() {
|
||||
if (XToolkit.isToolkitThread()) {
|
||||
return WindowAccessor.isAutoRequestFocus((Window)target);
|
||||
return AWTAccessor.getWindowAccessor().isAutoRequestFocus((Window)target);
|
||||
} else {
|
||||
return ((Window)target).isAutoRequestFocus();
|
||||
}
|
||||
@ -1086,10 +1084,11 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
if (warningWindow != null) {
|
||||
// We can't use the coordinates stored in the XBaseWindow since
|
||||
// they are zeros for decorated frames.
|
||||
int x = ComponentAccessor.getX(target);
|
||||
int y = ComponentAccessor.getY(target);
|
||||
int width = ComponentAccessor.getWidth(target);
|
||||
int height = ComponentAccessor.getHeight(target);
|
||||
AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
|
||||
int x = compAccessor.getX(target);
|
||||
int y = compAccessor.getY(target);
|
||||
int width = compAccessor.getWidth(target);
|
||||
int height = compAccessor.getHeight(target);
|
||||
warningWindow.reposition(x, y, width, height);
|
||||
}
|
||||
}
|
||||
@ -1172,7 +1171,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
if (isSimpleWindow()) {
|
||||
if (target == XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow()) {
|
||||
Window owner = getDecoratedOwner((Window)target);
|
||||
((XWindowPeer)ComponentAccessor.getPeer(owner)).requestWindowFocus();
|
||||
((XWindowPeer)AWTAccessor.getComponentAccessor().getPeer(owner)).requestWindowFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1399,7 +1398,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
XToolkit.awtLock();
|
||||
try {
|
||||
if (isReparented() && delayedModalBlocking) {
|
||||
addToTransientFors((XDialogPeer) ComponentAccessor.getPeer(modalBlocker));
|
||||
addToTransientFors((XDialogPeer) AWTAccessor.getComponentAccessor().getPeer(modalBlocker));
|
||||
delayedModalBlocking = false;
|
||||
}
|
||||
} finally {
|
||||
@ -1483,7 +1482,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
try {
|
||||
// State lock should always be after awtLock
|
||||
synchronized(getStateLock()) {
|
||||
XDialogPeer blockerPeer = (XDialogPeer) ComponentAccessor.getPeer(d);
|
||||
XDialogPeer blockerPeer = (XDialogPeer) AWTAccessor.getComponentAccessor().getPeer(d);
|
||||
if (blocked) {
|
||||
log.fine("{0} is blocked by {1}", this, blockerPeer);
|
||||
modalBlocker = d;
|
||||
@ -1763,7 +1762,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
// current chain iterator in the order from next to prev
|
||||
XWindowPeer chainToSplit = prevTransientFor;
|
||||
while (chainToSplit != null) {
|
||||
XWindowPeer blocker = (XWindowPeer) ComponentAccessor.getPeer(chainToSplit.modalBlocker);
|
||||
XWindowPeer blocker = (XWindowPeer) AWTAccessor.getComponentAccessor().getPeer(chainToSplit.modalBlocker);
|
||||
if (thisChainBlockers.contains(blocker)) {
|
||||
// add to this dialog's chain
|
||||
setToplevelTransientFor(thisChain, chainToSplit, true, false);
|
||||
@ -1791,7 +1790,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
|
||||
static Window getDecoratedOwner(Window window) {
|
||||
while ((null != window) && !(window instanceof Frame || window instanceof Dialog)) {
|
||||
window = (Window) ComponentAccessor.getParent_NoClientCode(window);
|
||||
window = (Window) AWTAccessor.getComponentAccessor().getParent(window);
|
||||
}
|
||||
return window;
|
||||
}
|
||||
@ -1824,7 +1823,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
}
|
||||
focusLog.fine("Parent window is not active");
|
||||
|
||||
XDecoratedPeer wpeer = (XDecoratedPeer)ComponentAccessor.getPeer(ownerWindow);
|
||||
XDecoratedPeer wpeer = (XDecoratedPeer)AWTAccessor.getComponentAccessor().getPeer(ownerWindow);
|
||||
if (wpeer != null && wpeer.requestWindowFocus(this, time, timeProvided)) {
|
||||
focusLog.fine("Parent window accepted focus request - generating focus for this window");
|
||||
return true;
|
||||
@ -2154,9 +2153,9 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
if (toplevel != null) {
|
||||
Window w = (Window)toplevel.target;
|
||||
while (w != null && toplevel != this && !(toplevel instanceof XDialogPeer)) {
|
||||
w = (Window) ComponentAccessor.getParent_NoClientCode(w);
|
||||
w = (Window) AWTAccessor.getComponentAccessor().getParent(w);
|
||||
if (w != null) {
|
||||
toplevel = (XWindowPeer) ComponentAccessor.getPeer(w);
|
||||
toplevel = (XWindowPeer) AWTAccessor.getComponentAccessor().getPeer(w);
|
||||
}
|
||||
}
|
||||
if (w == null || (w != this.target && w instanceof Dialog)) {
|
||||
|
||||
@ -28,8 +28,6 @@ import java.awt.*;
|
||||
import java.awt.peer.*;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.Method;
|
||||
import sun.awt.AWTAccessor;
|
||||
import sun.awt.ComponentAccessor;
|
||||
import sun.awt.SunToolkit;
|
||||
import sun.awt.Win32GraphicsDevice;
|
||||
import sun.awt.PaintEventDispatcher;
|
||||
|
||||
@ -57,7 +57,7 @@ import sun.awt.event.IgnorePaintEvent;
|
||||
|
||||
import java.awt.dnd.DropTarget;
|
||||
import java.awt.dnd.peer.DropTargetPeer;
|
||||
import sun.awt.ComponentAccessor;
|
||||
import sun.awt.AWTAccessor;
|
||||
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
@ -817,7 +817,7 @@ public abstract class WComponentPeer extends WObjectPeer
|
||||
}
|
||||
|
||||
private void postPaintIfNecessary(int x, int y, int w, int h) {
|
||||
if ( !ComponentAccessor.getIgnoreRepaint( (Component) target) ) {
|
||||
if ( !AWTAccessor.getComponentAccessor().getIgnoreRepaint( (Component) target) ) {
|
||||
PaintEvent event = PaintEventDispatcher.getPaintEventDispatcher().
|
||||
createPaintEvent((Component)target, x, y, w, h);
|
||||
if (event != null) {
|
||||
|
||||
@ -98,7 +98,7 @@ class WDialogPeer extends WWindowPeer implements DialogPeer {
|
||||
|
||||
public void blockWindows(java.util.List<Window> toBlock) {
|
||||
for (Window w : toBlock) {
|
||||
WWindowPeer wp = (WWindowPeer)ComponentAccessor.getPeer(w);
|
||||
WWindowPeer wp = (WWindowPeer)AWTAccessor.getComponentAccessor().getPeer(w);
|
||||
if (wp != null) {
|
||||
wp.setModalBlocked((Dialog)target, true);
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ import java.util.ResourceBundle;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.Vector;
|
||||
import sun.awt.AppContext;
|
||||
import sun.awt.ComponentAccessor;
|
||||
import sun.awt.AWTAccessor;
|
||||
|
||||
public class WFileDialogPeer extends WWindowPeer implements FileDialogPeer {
|
||||
|
||||
@ -187,7 +187,7 @@ public class WFileDialogPeer extends WWindowPeer implements FileDialogPeer {
|
||||
|
||||
public void blockWindows(java.util.List<Window> toBlock) {
|
||||
for (Window w : toBlock) {
|
||||
WWindowPeer wp = (WWindowPeer)ComponentAccessor.getPeer(w);
|
||||
WWindowPeer wp = (WWindowPeer)AWTAccessor.getComponentAccessor().getPeer(w);
|
||||
if (wp != null) {
|
||||
blockWindow(wp);
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ import java.awt.peer.ComponentPeer;
|
||||
import java.awt.dnd.DropTarget;
|
||||
import java.util.Vector;
|
||||
import sun.awt.AppContext;
|
||||
import sun.awt.ComponentAccessor;
|
||||
import sun.awt.AWTAccessor;
|
||||
|
||||
public class WPrintDialogPeer extends WWindowPeer implements DialogPeer {
|
||||
|
||||
@ -103,7 +103,7 @@ public class WPrintDialogPeer extends WWindowPeer implements DialogPeer {
|
||||
|
||||
public void blockWindows(java.util.List<Window> toBlock) {
|
||||
for (Window w : toBlock) {
|
||||
WWindowPeer wp = (WWindowPeer)ComponentAccessor.getPeer(w);
|
||||
WWindowPeer wp = (WWindowPeer)AWTAccessor.getComponentAccessor().getPeer(w);
|
||||
if (wp != null) {
|
||||
blockWindow(wp);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user