mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 02:54:35 +02:00
8074763: Remove API references to java.awt.dnd.peer
Reviewed-by: alanb, ant, prr
This commit is contained in:
parent
b9aead1b2c
commit
677097c128
8 changed files with 170 additions and 88 deletions
|
@ -1085,7 +1085,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||||
DropTarget old;
|
DropTarget old;
|
||||||
|
|
||||||
if ((old = dropTarget) != null) {
|
if ((old = dropTarget) != null) {
|
||||||
if (peer != null) dropTarget.removeNotify(peer);
|
dropTarget.removeNotify();
|
||||||
|
|
||||||
DropTarget t = dropTarget;
|
DropTarget t = dropTarget;
|
||||||
|
|
||||||
|
@ -1103,12 +1103,12 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||||
if ((dropTarget = dt) != null) {
|
if ((dropTarget = dt) != null) {
|
||||||
try {
|
try {
|
||||||
dropTarget.setComponent(this);
|
dropTarget.setComponent(this);
|
||||||
if (peer != null) dropTarget.addNotify(peer);
|
dropTarget.addNotify();
|
||||||
} catch (IllegalArgumentException iae) {
|
} catch (IllegalArgumentException iae) {
|
||||||
if (old != null) {
|
if (old != null) {
|
||||||
try {
|
try {
|
||||||
old.setComponent(this);
|
old.setComponent(this);
|
||||||
if (peer != null) dropTarget.addNotify(peer);
|
dropTarget.addNotify();
|
||||||
} catch (IllegalArgumentException iae1) {
|
} catch (IllegalArgumentException iae1) {
|
||||||
// ignore it!
|
// ignore it!
|
||||||
}
|
}
|
||||||
|
@ -7011,7 +7011,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||||
popup.addNotify();
|
popup.addNotify();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dropTarget != null) dropTarget.addNotify(peer);
|
if (dropTarget != null) dropTarget.addNotify();
|
||||||
|
|
||||||
peerFont = getFont();
|
peerFont = getFont();
|
||||||
|
|
||||||
|
@ -7098,7 +7098,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||||
((FlipBufferStrategy)bufferStrategy).destroyBuffers();
|
((FlipBufferStrategy)bufferStrategy).destroyBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dropTarget != null) dropTarget.removeNotify(peer);
|
if (dropTarget != null) dropTarget.removeNotify();
|
||||||
|
|
||||||
// Hide peer first to stop system events such as cursor moves.
|
// Hide peer first to stop system events such as cursor moves.
|
||||||
if (visible) {
|
if (visible) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2013, 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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -35,13 +35,15 @@ import java.awt.Toolkit;
|
||||||
import java.awt.datatransfer.FlavorMap;
|
import java.awt.datatransfer.FlavorMap;
|
||||||
import java.awt.datatransfer.SystemFlavorMap;
|
import java.awt.datatransfer.SystemFlavorMap;
|
||||||
import java.awt.datatransfer.Transferable;
|
import java.awt.datatransfer.Transferable;
|
||||||
import java.awt.dnd.peer.DragSourceContextPeer;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.security.AccessController;
|
import java.security.AccessController;
|
||||||
import java.util.EventListener;
|
import java.util.EventListener;
|
||||||
|
|
||||||
|
import sun.awt.AWTAccessor;
|
||||||
|
import sun.awt.AWTAccessor.DragSourceContextAccessor;
|
||||||
import sun.awt.dnd.SunDragSourceContextPeer;
|
import sun.awt.dnd.SunDragSourceContextPeer;
|
||||||
import sun.security.action.GetIntegerAction;
|
import sun.security.action.GetIntegerAction;
|
||||||
|
|
||||||
|
@ -303,22 +305,16 @@ public class DragSource implements Serializable {
|
||||||
try {
|
try {
|
||||||
if (flavorMap != null) this.flavorMap = flavorMap;
|
if (flavorMap != null) this.flavorMap = flavorMap;
|
||||||
|
|
||||||
DragSourceContextPeer dscp = Toolkit.getDefaultToolkit().createDragSourceContextPeer(trigger);
|
DragSourceContext dsc = createDragSourceContext(trigger, dragCursor,
|
||||||
|
dragImage,
|
||||||
DragSourceContext dsc = createDragSourceContext(dscp,
|
imageOffset,
|
||||||
trigger,
|
transferable, dsl);
|
||||||
dragCursor,
|
|
||||||
dragImage,
|
|
||||||
imageOffset,
|
|
||||||
transferable,
|
|
||||||
dsl
|
|
||||||
);
|
|
||||||
|
|
||||||
if (dsc == null) {
|
if (dsc == null) {
|
||||||
throw new InvalidDnDOperationException();
|
throw new InvalidDnDOperationException();
|
||||||
}
|
}
|
||||||
|
DragSourceContextAccessor acc = AWTAccessor.getDragSourceContextAccessor();
|
||||||
dscp.startDrag(dsc, dsc.getCursor(), dragImage, imageOffset); // may throw
|
acc.getPeer(dsc).startDrag(dsc, dsc.getCursor(), dragImage, imageOffset); // may throw
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
SunDragSourceContextPeer.setDragDropInProgress(false);
|
SunDragSourceContextPeer.setDragDropInProgress(false);
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -442,7 +438,6 @@ public class DragSource implements Serializable {
|
||||||
* is registered with the created <code>DragSourceContext</code>,
|
* is registered with the created <code>DragSourceContext</code>,
|
||||||
* but <code>NullPointerException</code> is not thrown.
|
* but <code>NullPointerException</code> is not thrown.
|
||||||
*
|
*
|
||||||
* @param dscp The <code>DragSourceContextPeer</code> for this drag
|
|
||||||
* @param dgl The <code>DragGestureEvent</code> that triggered the
|
* @param dgl The <code>DragGestureEvent</code> that triggered the
|
||||||
* drag
|
* drag
|
||||||
* @param dragCursor The initial {@code Cursor} for this drag operation
|
* @param dragCursor The initial {@code Cursor} for this drag operation
|
||||||
|
@ -473,8 +468,13 @@ public class DragSource implements Serializable {
|
||||||
* event are equal to <code>DnDConstants.ACTION_NONE</code>.
|
* event are equal to <code>DnDConstants.ACTION_NONE</code>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
protected DragSourceContext createDragSourceContext(DragSourceContextPeer dscp, DragGestureEvent dgl, Cursor dragCursor, Image dragImage, Point imageOffset, Transferable t, DragSourceListener dsl) {
|
protected DragSourceContext createDragSourceContext(DragGestureEvent dgl,
|
||||||
return new DragSourceContext(dscp, dgl, dragCursor, dragImage, imageOffset, t, dsl);
|
Cursor dragCursor,
|
||||||
|
Image dragImage,
|
||||||
|
Point imageOffset,
|
||||||
|
Transferable t,
|
||||||
|
DragSourceListener dsl) {
|
||||||
|
return new DragSourceContext(dgl, dragCursor, dragImage, imageOffset, t, dsl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -29,21 +29,20 @@ import java.awt.Component;
|
||||||
import java.awt.Cursor;
|
import java.awt.Cursor;
|
||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
|
import java.awt.Toolkit;
|
||||||
import java.awt.datatransfer.DataFlavor;
|
import java.awt.datatransfer.DataFlavor;
|
||||||
import java.awt.datatransfer.Transferable;
|
import java.awt.datatransfer.Transferable;
|
||||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||||
|
|
||||||
import java.awt.dnd.peer.DragSourceContextPeer;
|
import java.awt.dnd.peer.DragSourceContextPeer;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InvalidObjectException;
|
import java.io.InvalidObjectException;
|
||||||
import java.io.ObjectOutputStream;
|
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import java.util.TooManyListenersException;
|
import java.util.TooManyListenersException;
|
||||||
|
|
||||||
|
import sun.awt.AWTAccessor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The <code>DragSourceContext</code> class is responsible for managing the
|
* The <code>DragSourceContext</code> class is responsible for managing the
|
||||||
* initiator side of the Drag and Drop protocol. In particular, it is responsible
|
* initiator side of the Drag and Drop protocol. In particular, it is responsible
|
||||||
|
@ -123,6 +122,10 @@ public class DragSourceContext
|
||||||
|
|
||||||
protected static final int CHANGED = 3;
|
protected static final int CHANGED = 3;
|
||||||
|
|
||||||
|
static {
|
||||||
|
AWTAccessor.setDragSourceContextAccessor(dsc -> dsc.peer);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called from <code>DragSource</code>, this constructor creates a new
|
* Called from <code>DragSource</code>, this constructor creates a new
|
||||||
* <code>DragSourceContext</code> given the
|
* <code>DragSourceContext</code> given the
|
||||||
|
@ -155,7 +158,6 @@ public class DragSourceContext
|
||||||
* If <code>DragSourceListener</code> is <code>null</code> no exception
|
* If <code>DragSourceListener</code> is <code>null</code> no exception
|
||||||
* is thrown.
|
* is thrown.
|
||||||
*
|
*
|
||||||
* @param dscp the <code>DragSourceContextPeer</code> for this drag
|
|
||||||
* @param trigger the triggering event
|
* @param trigger the triggering event
|
||||||
* @param dragCursor the initial {@code Cursor} for this drag operation
|
* @param dragCursor the initial {@code Cursor} for this drag operation
|
||||||
* or {@code null} for the default cursor handling;
|
* or {@code null} for the default cursor handling;
|
||||||
|
@ -179,10 +181,12 @@ public class DragSourceContext
|
||||||
* @throws NullPointerException if dscp, trigger, or t are null, or
|
* @throws NullPointerException if dscp, trigger, or t are null, or
|
||||||
* if dragImage is non-null and offset is null
|
* if dragImage is non-null and offset is null
|
||||||
*/
|
*/
|
||||||
public DragSourceContext(DragSourceContextPeer dscp,
|
public DragSourceContext(DragGestureEvent trigger, Cursor dragCursor,
|
||||||
DragGestureEvent trigger, Cursor dragCursor,
|
|
||||||
Image dragImage, Point offset, Transferable t,
|
Image dragImage, Point offset, Transferable t,
|
||||||
DragSourceListener dsl) {
|
DragSourceListener dsl) {
|
||||||
|
DragSourceContextPeer dscp = Toolkit.getDefaultToolkit()
|
||||||
|
.createDragSourceContextPeer(trigger);
|
||||||
|
|
||||||
if (dscp == null) {
|
if (dscp == null) {
|
||||||
throw new NullPointerException("DragSourceContextPeer");
|
throw new NullPointerException("DragSourceContextPeer");
|
||||||
}
|
}
|
||||||
|
@ -623,8 +627,7 @@ public class DragSourceContext
|
||||||
/*
|
/*
|
||||||
* fields
|
* fields
|
||||||
*/
|
*/
|
||||||
|
private final transient DragSourceContextPeer peer;
|
||||||
private transient DragSourceContextPeer peer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The event which triggered the start of the drag.
|
* The event which triggered the start of the drag.
|
||||||
|
|
|
@ -207,19 +207,13 @@ public class DropTarget implements DropTargetListener, Serializable {
|
||||||
if (component == c || component != null && component.equals(c))
|
if (component == c || component != null && component.equals(c))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Component old;
|
final Component old = component;
|
||||||
ComponentPeer oldPeer = null;
|
|
||||||
|
|
||||||
if ((old = component) != null) {
|
if (old != null) {
|
||||||
clearAutoscroll();
|
clearAutoscroll();
|
||||||
|
|
||||||
component = null;
|
component = null;
|
||||||
|
removeNotify();
|
||||||
if (componentPeer != null) {
|
|
||||||
oldPeer = componentPeer;
|
|
||||||
removeNotify(componentPeer);
|
|
||||||
}
|
|
||||||
|
|
||||||
old.setDropTarget(null);
|
old.setDropTarget(null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -229,7 +223,7 @@ public class DropTarget implements DropTargetListener, Serializable {
|
||||||
} catch (Exception e) { // undo the change
|
} catch (Exception e) { // undo the change
|
||||||
if (old != null) {
|
if (old != null) {
|
||||||
old.setDropTarget(this);
|
old.setDropTarget(this);
|
||||||
addNotify(oldPeer);
|
addNotify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -497,16 +491,16 @@ public class DropTarget implements DropTargetListener, Serializable {
|
||||||
* association of the ComponentPeer with the Component may result in
|
* association of the ComponentPeer with the Component may result in
|
||||||
* a malfunction of the DnD system.
|
* a malfunction of the DnD system.
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
*
|
|
||||||
* @param peer The Peer of the Component we are associated with!
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
public void addNotify() {
|
||||||
public void addNotify(ComponentPeer peer) {
|
final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
|
||||||
if (peer == componentPeer) return;
|
ComponentPeer peer = acc.getPeer(component);
|
||||||
|
if (peer == null || peer == componentPeer) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
componentPeer = peer;
|
componentPeer = peer;
|
||||||
final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
|
|
||||||
|
|
||||||
for (Component c = component;
|
for (Component c = component;
|
||||||
c != null && peer instanceof LightweightPeer; c = c.getParent()) {
|
c != null && peer instanceof LightweightPeer; c = c.getParent()) {
|
||||||
|
@ -514,7 +508,7 @@ public class DropTarget implements DropTargetListener, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (peer instanceof DropTargetPeer) {
|
if (peer instanceof DropTargetPeer) {
|
||||||
nativePeer = peer;
|
nativePeer = (DropTargetPeer) peer;
|
||||||
((DropTargetPeer)peer).addDropTarget(this);
|
((DropTargetPeer)peer).addDropTarget(this);
|
||||||
} else {
|
} else {
|
||||||
nativePeer = null;
|
nativePeer = null;
|
||||||
|
@ -533,15 +527,14 @@ public class DropTarget implements DropTargetListener, Serializable {
|
||||||
* disassociation of the ComponentPeer from the Component may result in
|
* disassociation of the ComponentPeer from the Component may result in
|
||||||
* a malfunction of the DnD system.
|
* a malfunction of the DnD system.
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
*
|
|
||||||
* @param peer The Peer of the Component we are being disassociated from!
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void removeNotify(ComponentPeer peer) {
|
public void removeNotify() {
|
||||||
if (nativePeer != null)
|
if (nativePeer != null) {
|
||||||
((DropTargetPeer)nativePeer).removeDropTarget(this);
|
nativePeer.removeDropTarget(this);
|
||||||
|
}
|
||||||
componentPeer = nativePeer = null;
|
componentPeer = null;
|
||||||
|
nativePeer = null;
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (isDraggingInside) {
|
if (isDraggingInside) {
|
||||||
|
@ -837,7 +830,7 @@ public class DropTarget implements DropTargetListener, Serializable {
|
||||||
/*
|
/*
|
||||||
* That Component's "native" Peer
|
* That Component's "native" Peer
|
||||||
*/
|
*/
|
||||||
private transient ComponentPeer nativePeer;
|
private transient DropTargetPeer nativePeer;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2004, 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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -39,6 +39,8 @@ import java.io.Serializable;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import sun.awt.AWTAccessor;
|
||||||
|
import sun.awt.AWTAccessor.DropTargetContextAccessor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A <code>DropTargetContext</code> is created
|
* A <code>DropTargetContext</code> is created
|
||||||
|
@ -58,6 +60,19 @@ public class DropTargetContext implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = -634158968993743371L;
|
private static final long serialVersionUID = -634158968993743371L;
|
||||||
|
|
||||||
|
static {
|
||||||
|
AWTAccessor.setDropTargetContextAccessor(new DropTargetContextAccessor() {
|
||||||
|
@Override
|
||||||
|
public void reset(DropTargetContext dtc) {
|
||||||
|
dtc.reset();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void setDropTargetContextPeer(DropTargetContext dtc,
|
||||||
|
DropTargetContextPeer dtcp) {
|
||||||
|
dtc.setDropTargetContextPeer(dtcp);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Construct a <code>DropTargetContext</code>
|
* Construct a <code>DropTargetContext</code>
|
||||||
* given a specified <code>DropTarget</code>.
|
* given a specified <code>DropTarget</code>.
|
||||||
|
@ -89,21 +104,10 @@ public class DropTargetContext implements Serializable {
|
||||||
|
|
||||||
public Component getComponent() { return dropTarget.getComponent(); }
|
public Component getComponent() { return dropTarget.getComponent(); }
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when associated with the <code>DropTargetContextPeer</code>.
|
|
||||||
*
|
|
||||||
* @param dtcp the <code>DropTargetContextPeer</code>
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void addNotify(DropTargetContextPeer dtcp) {
|
|
||||||
dropTargetContextPeer = dtcp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when disassociated with the <code>DropTargetContextPeer</code>.
|
* Called when disassociated with the <code>DropTargetContextPeer</code>.
|
||||||
*/
|
*/
|
||||||
|
void reset() {
|
||||||
public void removeNotify() {
|
|
||||||
dropTargetContextPeer = null;
|
dropTargetContextPeer = null;
|
||||||
transferable = null;
|
transferable = null;
|
||||||
}
|
}
|
||||||
|
@ -282,11 +286,17 @@ public class DropTargetContext implements Serializable {
|
||||||
*
|
*
|
||||||
* @return the platform peer
|
* @return the platform peer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DropTargetContextPeer getDropTargetContextPeer() {
|
DropTargetContextPeer getDropTargetContextPeer() {
|
||||||
return dropTargetContextPeer;
|
return dropTargetContextPeer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the {@code DropTargetContextPeer}
|
||||||
|
*/
|
||||||
|
void setDropTargetContextPeer(final DropTargetContextPeer dtcp) {
|
||||||
|
dropTargetContextPeer = dtcp;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a TransferableProxy to proxy for the specified
|
* Creates a TransferableProxy to proxy for the specified
|
||||||
* Transferable.
|
* Transferable.
|
||||||
|
@ -412,7 +422,7 @@ public class DropTargetContext implements Serializable {
|
||||||
*
|
*
|
||||||
* @serial
|
* @serial
|
||||||
*/
|
*/
|
||||||
private DropTarget dropTarget;
|
private final DropTarget dropTarget;
|
||||||
|
|
||||||
private transient DropTargetContextPeer dropTargetContextPeer;
|
private transient DropTargetContextPeer dropTargetContextPeer;
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,10 @@ import sun.misc.Unsafe;
|
||||||
|
|
||||||
import javax.accessibility.AccessibleContext;
|
import javax.accessibility.AccessibleContext;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.awt.dnd.DragSourceContext;
|
||||||
|
import java.awt.dnd.DropTargetContext;
|
||||||
|
import java.awt.dnd.peer.DragSourceContextPeer;
|
||||||
|
import java.awt.dnd.peer.DropTargetContextPeer;
|
||||||
import java.awt.event.InputEvent;
|
import java.awt.event.InputEvent;
|
||||||
import java.awt.event.InvocationEvent;
|
import java.awt.event.InvocationEvent;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
|
@ -784,6 +788,31 @@ public final class AWTAccessor {
|
||||||
AppContext getAppContext(AccessibleContext accessibleContext);
|
AppContext getAppContext(AccessibleContext accessibleContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* An accessor object for the DragSourceContext class
|
||||||
|
*/
|
||||||
|
public interface DragSourceContextAccessor {
|
||||||
|
/**
|
||||||
|
* Returns the peer of the DragSourceContext.
|
||||||
|
*/
|
||||||
|
DragSourceContextPeer getPeer(DragSourceContext dsc);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* An accessor object for the DropTargetContext class
|
||||||
|
*/
|
||||||
|
public interface DropTargetContextAccessor {
|
||||||
|
/**
|
||||||
|
* Resets the DropTargetContext.
|
||||||
|
*/
|
||||||
|
void reset(DropTargetContext dtc);
|
||||||
|
/**
|
||||||
|
* Sets the {@code DropTargetContextPeer}
|
||||||
|
*/
|
||||||
|
void setDropTargetContextPeer(DropTargetContext dtc,
|
||||||
|
DropTargetContextPeer dtcp);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Accessor instances are initialized in the static initializers of
|
* Accessor instances are initialized in the static initializers of
|
||||||
* corresponding AWT classes by using setters defined below.
|
* corresponding AWT classes by using setters defined below.
|
||||||
|
@ -815,6 +844,8 @@ public final class AWTAccessor {
|
||||||
private static InvocationEventAccessor invocationEventAccessor;
|
private static InvocationEventAccessor invocationEventAccessor;
|
||||||
private static SystemColorAccessor systemColorAccessor;
|
private static SystemColorAccessor systemColorAccessor;
|
||||||
private static AccessibleContextAccessor accessibleContextAccessor;
|
private static AccessibleContextAccessor accessibleContextAccessor;
|
||||||
|
private static DragSourceContextAccessor dragSourceContextAccessor;
|
||||||
|
private static DropTargetContextAccessor dropTargetContextAccessor;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set an accessor object for the java.awt.Component class.
|
* Set an accessor object for the java.awt.Component class.
|
||||||
|
@ -1275,4 +1306,39 @@ public final class AWTAccessor {
|
||||||
public static void setAccessibleContextAccessor(AccessibleContextAccessor accessor) {
|
public static void setAccessibleContextAccessor(AccessibleContextAccessor accessor) {
|
||||||
AWTAccessor.accessibleContextAccessor = accessor;
|
AWTAccessor.accessibleContextAccessor = accessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the accessor object for the java.awt.dnd.DragSourceContext class.
|
||||||
|
*/
|
||||||
|
public static DragSourceContextAccessor getDragSourceContextAccessor() {
|
||||||
|
if (dragSourceContextAccessor == null) {
|
||||||
|
unsafe.ensureClassInitialized(DragSourceContext.class);
|
||||||
|
}
|
||||||
|
return dragSourceContextAccessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the accessor object for the java.awt.dnd.DragSourceContext class.
|
||||||
|
*/
|
||||||
|
public static void setDragSourceContextAccessor(DragSourceContextAccessor accessor) {
|
||||||
|
AWTAccessor.dragSourceContextAccessor = accessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the accessor object for the java.awt.dnd.DropTargetContext class.
|
||||||
|
*/
|
||||||
|
public static DropTargetContextAccessor getDropTargetContextAccessor() {
|
||||||
|
if (dropTargetContextAccessor == null) {
|
||||||
|
unsafe.ensureClassInitialized(DropTargetContext.class);
|
||||||
|
}
|
||||||
|
return dropTargetContextAccessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the accessor object for the java.awt.dnd.DropTargetContext class.
|
||||||
|
*/
|
||||||
|
public static void setDropTargetContextAccessor(DropTargetContextAccessor accessor) {
|
||||||
|
AWTAccessor.dropTargetContextAccessor = accessor;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -48,6 +48,8 @@ import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import sun.awt.AWTAccessor;
|
||||||
|
import sun.awt.AWTAccessor.DropTargetContextAccessor;
|
||||||
import sun.util.logging.PlatformLogger;
|
import sun.util.logging.PlatformLogger;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -313,9 +315,10 @@ public abstract class SunDropTargetContextPeer implements DropTargetContextPeer,
|
||||||
Point hots = event.getPoint();
|
Point hots = event.getPoint();
|
||||||
|
|
||||||
local = getJVMLocalSourceTransferable();
|
local = getJVMLocalSourceTransferable();
|
||||||
|
DropTargetContextAccessor acc =
|
||||||
|
AWTAccessor.getDropTargetContextAccessor();
|
||||||
if (currentDTC != null) { // some wreckage from last time
|
if (currentDTC != null) { // some wreckage from last time
|
||||||
currentDTC.removeNotify();
|
acc.reset(currentDTC);
|
||||||
currentDTC = null;
|
currentDTC = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,7 +326,7 @@ public abstract class SunDropTargetContextPeer implements DropTargetContextPeer,
|
||||||
currentDT = dt;
|
currentDT = dt;
|
||||||
currentDTC = currentDT.getDropTargetContext();
|
currentDTC = currentDT.getDropTargetContext();
|
||||||
|
|
||||||
currentDTC.addNotify(this);
|
acc.setDropTargetContextPeer(currentDTC, this);
|
||||||
|
|
||||||
currentA = dt.getDefaultActions();
|
currentA = dt.getDefaultActions();
|
||||||
|
|
||||||
|
@ -370,13 +373,15 @@ public abstract class SunDropTargetContextPeer implements DropTargetContextPeer,
|
||||||
Component c = (Component)event.getSource();
|
Component c = (Component)event.getSource();
|
||||||
DropTarget dt = c.getDropTarget();
|
DropTarget dt = c.getDropTarget();
|
||||||
DropTargetContext dtc = null;
|
DropTargetContext dtc = null;
|
||||||
|
DropTargetContextAccessor acc =
|
||||||
|
AWTAccessor.getDropTargetContextAccessor();
|
||||||
|
|
||||||
if (dt == null) {
|
if (dt == null) {
|
||||||
currentDT = null;
|
currentDT = null;
|
||||||
currentT = null;
|
currentT = null;
|
||||||
|
|
||||||
if (currentDTC != null) {
|
if (currentDTC != null) {
|
||||||
currentDTC.removeNotify();
|
acc.reset(currentDTC);
|
||||||
}
|
}
|
||||||
|
|
||||||
currentDTC = null;
|
currentDTC = null;
|
||||||
|
@ -387,13 +392,13 @@ public abstract class SunDropTargetContextPeer implements DropTargetContextPeer,
|
||||||
if (dt != currentDT) {
|
if (dt != currentDT) {
|
||||||
|
|
||||||
if (currentDTC != null) {
|
if (currentDTC != null) {
|
||||||
currentDTC.removeNotify();
|
acc.reset(currentDTC);
|
||||||
}
|
}
|
||||||
|
|
||||||
currentDT = dt;
|
currentDT = dt;
|
||||||
currentDTC = dt.getDropTargetContext();
|
currentDTC = dt.getDropTargetContext();
|
||||||
|
|
||||||
currentDTC.addNotify(this);
|
acc.setDropTargetContextPeer(currentDTC, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
dtc = currentDTC;
|
dtc = currentDTC;
|
||||||
|
@ -409,7 +414,7 @@ public abstract class SunDropTargetContextPeer implements DropTargetContextPeer,
|
||||||
currentDT = null;
|
currentDT = null;
|
||||||
currentT = null;
|
currentT = null;
|
||||||
|
|
||||||
currentDTC.removeNotify();
|
acc.reset(currentDTC);
|
||||||
currentDTC = null;
|
currentDTC = null;
|
||||||
|
|
||||||
local = null;
|
local = null;
|
||||||
|
@ -440,11 +445,13 @@ public abstract class SunDropTargetContextPeer implements DropTargetContextPeer,
|
||||||
int id = event.getID();
|
int id = event.getID();
|
||||||
DropTarget dt = c.getDropTarget();
|
DropTarget dt = c.getDropTarget();
|
||||||
DropTargetContext dtc = null;
|
DropTargetContext dtc = null;
|
||||||
|
DropTargetContextAccessor acc =
|
||||||
|
AWTAccessor.getDropTargetContextAccessor();
|
||||||
|
|
||||||
if (c.isShowing() && (dt != null) && dt.isActive()) {
|
if (c.isShowing() && (dt != null) && dt.isActive()) {
|
||||||
if (currentDT != dt) {
|
if (currentDT != dt) {
|
||||||
if (currentDTC != null) {
|
if (currentDTC != null) {
|
||||||
currentDTC.removeNotify();
|
acc.reset(currentDTC);
|
||||||
}
|
}
|
||||||
|
|
||||||
currentDT = dt;
|
currentDT = dt;
|
||||||
|
@ -454,11 +461,11 @@ public abstract class SunDropTargetContextPeer implements DropTargetContextPeer,
|
||||||
dtc = currentDT.getDropTargetContext();
|
dtc = currentDT.getDropTargetContext();
|
||||||
if (dtc != currentDTC) {
|
if (dtc != currentDTC) {
|
||||||
if (currentDTC != null) {
|
if (currentDTC != null) {
|
||||||
currentDTC.removeNotify();
|
acc.reset(currentDTC);
|
||||||
}
|
}
|
||||||
|
|
||||||
currentDTC = dtc;
|
currentDTC = dtc;
|
||||||
currentDTC.addNotify(this);
|
acc.setDropTargetContextPeer(currentDTC, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
currentA = currentDT.getDefaultActions();
|
currentA = currentDT.getDefaultActions();
|
||||||
|
@ -518,13 +525,15 @@ public abstract class SunDropTargetContextPeer implements DropTargetContextPeer,
|
||||||
DropTargetContext dtc = dt.getDropTargetContext();
|
DropTargetContext dtc = dt.getDropTargetContext();
|
||||||
|
|
||||||
currentDT = dt;
|
currentDT = dt;
|
||||||
|
DropTargetContextAccessor acc =
|
||||||
|
AWTAccessor.getDropTargetContextAccessor();
|
||||||
|
|
||||||
if (currentDTC != null) {
|
if (currentDTC != null) {
|
||||||
currentDTC.removeNotify();
|
acc.reset(currentDTC);
|
||||||
}
|
}
|
||||||
|
|
||||||
currentDTC = dtc;
|
currentDTC = dtc;
|
||||||
currentDTC.addNotify(this);
|
acc.setDropTargetContextPeer(currentDTC, this);
|
||||||
currentA = dt.getDefaultActions();
|
currentA = dt.getDefaultActions();
|
||||||
|
|
||||||
synchronized(_globalLock) {
|
synchronized(_globalLock) {
|
||||||
|
@ -687,7 +696,9 @@ public abstract class SunDropTargetContextPeer implements DropTargetContextPeer,
|
||||||
throw new InvalidDnDOperationException("No Drop pending");
|
throw new InvalidDnDOperationException("No Drop pending");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentDTC != null) currentDTC.removeNotify();
|
if (currentDTC != null) {
|
||||||
|
AWTAccessor.getDropTargetContextAccessor().reset(currentDTC);
|
||||||
|
}
|
||||||
|
|
||||||
currentDT = null;
|
currentDT = null;
|
||||||
currentDTC = null;
|
currentDTC = null;
|
||||||
|
|
|
@ -74,7 +74,6 @@ public class DragSourceListenerSerializationTest {
|
||||||
new Point(100, 100),
|
new Point(100, 100),
|
||||||
Arrays.asList(me));
|
Arrays.asList(me));
|
||||||
DragSourceContext dsc = new DragSourceContext(
|
DragSourceContext dsc = new DragSourceContext(
|
||||||
Toolkit.getDefaultToolkit().createDragSourceContextPeer(dge),
|
|
||||||
dge,
|
dge,
|
||||||
new Cursor(Cursor.HAND_CURSOR),
|
new Cursor(Cursor.HAND_CURSOR),
|
||||||
null, null, new StringSelection("TEXT"), null);
|
null, null, new StringSelection("TEXT"), null);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue