8020371: [macosx] applets with Drag and Drop fail with IllegalArgumentException
authorpchelko
Mon, 15 Jul 2013 12:06:06 +0400
changeset 18763 5d31d298e4d4
parent 18762 eb4a26b2cd7f
child 18764 12a1993f109b
8020371: [macosx] applets with Drag and Drop fail with IllegalArgumentException Reviewed-by: anthony, art
jdk/src/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java
jdk/src/macosx/classes/sun/lwawt/macosx/CDropTarget.java
jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java	Fri Jul 12 21:33:33 2013 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java	Mon Jul 15 12:06:06 2013 +0400
@@ -107,10 +107,6 @@
             loc = rootComponent.getLocation();
         }
 
-        //It sure will be LWComponentPeer instance as rootComponent is a Window
-        PlatformWindow platformWindow = ((LWComponentPeer)rootComponent.getPeer()).getPlatformWindow();
-        long nativeViewPtr = CPlatformWindow.getNativeViewPtr(platformWindow);
-
         // If there isn't any drag image make one of default appearance:
         if (fDragImage == null)
             this.setDefaultDragImage(component);
@@ -137,6 +133,11 @@
         }
 
         try {
+            //It sure will be LWComponentPeer instance as rootComponent is a Window
+            PlatformWindow platformWindow = ((LWComponentPeer)rootComponent.getPeer()).getPlatformWindow();
+            long nativeViewPtr = CPlatformWindow.getNativeViewPtr(platformWindow);
+            if (nativeViewPtr == 0L) throw new InvalidDnDOperationException("Unsupported platform window implementation");
+
             // Create native dragging source:
             final long nativeDragSource = createNativeDragSource(component, nativeViewPtr, transferable, triggerEvent,
                 (int) (dragOrigin.getX()), (int) (dragOrigin.getY()), extModifiers,
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CDropTarget.java	Fri Jul 12 21:33:33 2013 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CDropTarget.java	Mon Jul 15 12:06:06 2013 +0400
@@ -52,6 +52,8 @@
         fPeer = peer;
 
         long nativePeer = CPlatformWindow.getNativeViewPtr(((LWComponentPeer) peer).getPlatformWindow());
+        if (nativePeer == 0L) return; // Unsupported for a window without a native view (plugin)
+
         // Create native dragging destination:
         fNativeDropTarget = this.createNativeDropTarget(dropTarget, component, peer, nativePeer);
         if (fNativeDropTarget == 0) {
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Fri Jul 12 21:33:33 2013 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Mon Jul 15 12:06:06 2013 +0400
@@ -896,8 +896,6 @@
             nativePeer = ((CPlatformWindow) platformWindow).getContentView().getAWTView();
         } else if (platformWindow instanceof CViewPlatformEmbeddedFrame){
             nativePeer = ((CViewPlatformEmbeddedFrame) platformWindow).getNSViewPtr();
-        } else {
-            throw new IllegalArgumentException("Unsupported platformWindow implementation");
         }
         return nativePeer;
     }