changeset 6712:19ffa204aae1

8020371: [macosx] applets with Drag and Drop fail with IllegalArgumentException Reviewed-by: anthony, art
author pchelko
date Thu, 25 Jul 2013 11:24:25 +0400
parents 86d282f57326
children c103e0918d60
files src/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java src/macosx/classes/sun/lwawt/macosx/CDropTarget.java src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
diffstat 3 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java	Wed Jul 24 15:05:04 2013 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java	Thu Jul 25 11:24:25 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/src/macosx/classes/sun/lwawt/macosx/CDropTarget.java	Wed Jul 24 15:05:04 2013 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CDropTarget.java	Thu Jul 25 11:24:25 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/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Wed Jul 24 15:05:04 2013 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Thu Jul 25 11:24:25 2013 +0400
@@ -933,8 +933,6 @@
             nativePeer = ((CPlatformWindow) platformWindow).getContentView().getAWTView();
         } else if (platformWindow instanceof CViewPlatformEmbeddedFrame){
             nativePeer = ((CViewPlatformEmbeddedFrame) platformWindow).getNSViewPtr();
-        } else {
-            throw new IllegalArgumentException("Unsupported platformWindow implementation");
         }
         return nativePeer;
     }