src/java.desktop/share/classes/sun/awt/dnd/SunDropTargetContextPeer.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * 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.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -46,10 +46,12 @@
 
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Arrays;
 
+import sun.awt.AWTAccessor;
+import sun.awt.AWTAccessor.DropTargetContextAccessor;
 import sun.util.logging.PlatformLogger;
 
 import java.io.IOException;
 import java.io.InputStream;
 

@@ -311,21 +313,22 @@
         Component  c    = (Component)event.getSource();
         DropTarget dt   = c.getDropTarget();
         Point      hots = event.getPoint();
 
         local = getJVMLocalSourceTransferable();
-
+        DropTargetContextAccessor acc =
+                AWTAccessor.getDropTargetContextAccessor();
         if (currentDTC != null) { // some wreckage from last time
-            currentDTC.removeNotify();
+            acc.reset(currentDTC);
             currentDTC = null;
         }
 
         if (c.isShowing() && dt != null && dt.isActive()) {
             currentDT  = dt;
             currentDTC = currentDT.getDropTargetContext();
 
-            currentDTC.addNotify(this);
+            acc.setDropTargetContextPeer(currentDTC, this);
 
             currentA   = dt.getDefaultActions();
 
             try {
                 ((DropTargetListener)dt).dragEnter(new DropTargetDragEvent(currentDTC,

@@ -368,34 +371,36 @@
 
     protected void processExitMessage(SunDropTargetEvent event) {
         Component         c   = (Component)event.getSource();
         DropTarget        dt  = c.getDropTarget();
         DropTargetContext dtc = null;
+        DropTargetContextAccessor acc =
+                AWTAccessor.getDropTargetContextAccessor();
 
         if (dt == null) {
             currentDT = null;
             currentT  = null;
 
             if (currentDTC != null) {
-                currentDTC.removeNotify();
+                acc.reset(currentDTC);
             }
 
             currentDTC = null;
 
             return;
         }
 
         if (dt != currentDT) {
 
             if (currentDTC != null) {
-                currentDTC.removeNotify();
+                acc.reset(currentDTC);
             }
 
             currentDT  = dt;
             currentDTC = dt.getDropTargetContext();
 
-            currentDTC.addNotify(this);
+            acc.setDropTargetContextPeer(currentDTC, this);
         }
 
         dtc = currentDTC;
 
         if (dt.isActive()) try {

@@ -407,11 +412,11 @@
             currentSA = DnDConstants.ACTION_NONE;
             currentDA = DnDConstants.ACTION_NONE;
             currentDT = null;
             currentT  = null;
 
-            currentDTC.removeNotify();
+            acc.reset(currentDTC);
             currentDTC = null;
 
             local = null;
 
             dragRejected = false;

@@ -438,29 +443,31 @@
         Component         c    = (Component)event.getSource();
         Point             hots = event.getPoint();
         int               id   = event.getID();
         DropTarget        dt   = c.getDropTarget();
         DropTargetContext dtc  = null;
+        DropTargetContextAccessor acc =
+                AWTAccessor.getDropTargetContextAccessor();
 
         if (c.isShowing() && (dt != null) && dt.isActive()) {
             if (currentDT != dt) {
                 if (currentDTC != null) {
-                    currentDTC.removeNotify();
+                    acc.reset(currentDTC);
                 }
 
                 currentDT  = dt;
                 currentDTC = null;
             }
 
             dtc = currentDT.getDropTargetContext();
             if (dtc != currentDTC) {
                 if (currentDTC != null) {
-                    currentDTC.removeNotify();
+                    acc.reset(currentDTC);
                 }
 
                 currentDTC = dtc;
-                currentDTC.addNotify(this);
+                acc.setDropTargetContextPeer(currentDTC, this);
             }
 
             currentA = currentDT.getDefaultActions();
 
             try {

@@ -516,17 +523,19 @@
 
         if (c.isShowing() && dt != null && dt.isActive()) {
             DropTargetContext dtc = dt.getDropTargetContext();
 
             currentDT = dt;
+            DropTargetContextAccessor acc =
+                    AWTAccessor.getDropTargetContextAccessor();
 
             if (currentDTC != null) {
-                currentDTC.removeNotify();
+                acc.reset(currentDTC);
             }
 
             currentDTC = dtc;
-            currentDTC.addNotify(this);
+            acc.setDropTargetContextPeer(currentDTC, this);
             currentA = dt.getDefaultActions();
 
             synchronized(_globalLock) {
                 if ((local = getJVMLocalSourceTransferable()) != null)
                     setCurrentJVMLocalSourceTransferable(null);

@@ -685,11 +694,13 @@
     public synchronized void dropComplete(boolean success) {
         if (dropStatus == STATUS_NONE) {
             throw new InvalidDnDOperationException("No Drop pending");
         }
 
-        if (currentDTC != null) currentDTC.removeNotify();
+        if (currentDTC != null) {
+            AWTAccessor.getDropTargetContextAccessor().reset(currentDTC);
+        }
 
         currentDT  = null;
         currentDTC = null;
         currentT   = null;
         currentA   = DnDConstants.ACTION_NONE;