36 final class CDropTargetContextPeer extends SunDropTargetContextPeer {
37
38 private long fNativeDropTransfer = 0;
39 private long fNativeDataAvailable = 0;
40 private Object fNativeData = null;
41 private boolean insideTarget = false;
42
43 Object awtLockAccess = new Object();
44
45 static CDropTargetContextPeer getDropTargetContextPeer() {
46 return new CDropTargetContextPeer();
47 }
48
49 private CDropTargetContextPeer() {
50 super();
51 }
52
53 // We block, waiting for an empty event to get posted (CToolkit.invokeAndWait)
54 // This is so we finish dispatching DropTarget events before we dispatch the dragDropFinished event (which is a higher priority).
55 private void flushEvents(Component c) {
56 try {
57 LWCToolkit.invokeAndWait(new Runnable() {
58 public synchronized void run() {
59 }
60 }, c);
61 }
62 catch(Exception e) {
63 e.printStackTrace();
64 }
65 }
66
67 protected Object getNativeData(long format) {
68 long nativeDropTarget = this.getNativeDragContext();
69
70 synchronized (awtLockAccess) {
71 fNativeDataAvailable = 0;
72
73 if (fNativeDropTransfer == 0) {
74 fNativeDropTransfer = startTransfer(nativeDropTarget, format);
75 } else {
76 addTransfer(nativeDropTarget, fNativeDropTransfer, format);
77 }
78
79 while (format != fNativeDataAvailable) {
80 try {
81 awtLockAccess.wait();
82 } catch (Throwable e) {
83 e.printStackTrace();
84 }
|
36 final class CDropTargetContextPeer extends SunDropTargetContextPeer {
37
38 private long fNativeDropTransfer = 0;
39 private long fNativeDataAvailable = 0;
40 private Object fNativeData = null;
41 private boolean insideTarget = false;
42
43 Object awtLockAccess = new Object();
44
45 static CDropTargetContextPeer getDropTargetContextPeer() {
46 return new CDropTargetContextPeer();
47 }
48
49 private CDropTargetContextPeer() {
50 super();
51 }
52
53 // We block, waiting for an empty event to get posted (CToolkit.invokeAndWait)
54 // This is so we finish dispatching DropTarget events before we dispatch the dragDropFinished event (which is a higher priority).
55 private void flushEvents(Component c) {
56 LWCToolkit.flushPendingEventsOnAppkit(c);
57 }
58
59 protected Object getNativeData(long format) {
60 long nativeDropTarget = this.getNativeDragContext();
61
62 synchronized (awtLockAccess) {
63 fNativeDataAvailable = 0;
64
65 if (fNativeDropTransfer == 0) {
66 fNativeDropTransfer = startTransfer(nativeDropTarget, format);
67 } else {
68 addTransfer(nativeDropTarget, fNativeDropTransfer, format);
69 }
70
71 while (format != fNativeDataAvailable) {
72 try {
73 awtLockAccess.wait();
74 } catch (Throwable e) {
75 e.printStackTrace();
76 }
|