493 actions = JNFCallIntMethod(env, fDropTargetContextPeer, handleEnterMessageMethod, fComponent, (jint) javaLocation.x, (jint) javaLocation.y, dropAction, actions, formats, ptr_to_jlong(self)); // AWT_THREADING Safe (CToolkitThreadBlockedHandler) 494 } 495 496 if (sDraggingError == FALSE) { 497 // Initialize drag operation: 498 sDragOperation = NSDragOperationNone; 499 500 // Map Java actions back to NSDragOperation. 501 // 1-6-03 Note: if the entry point of this CDropTarget isn't covered by a droppable component 502 // (as can be the case with lightweight children) we must not return NSDragOperationNone 503 // since that would prevent dropping into any of the contained drop targets. 504 // Unfortunately there is no easy way to test this so we just test actions and override them 505 // with GENERIC if necessary. Proper drag operations will be returned by draggingUpdated: which is 506 // called right away, taking care of setting the right cursor and snap-back action. 507 dragOp = ((actions != java_awt_dnd_DnDConstants_ACTION_NONE) ? 508 [DnDUtilities mapJavaDragOperationToNS:dropAction] : NSDragOperationGeneric); 509 510 // Remember the dragOp for no-op'd update messages: 511 sUpdateOperation = dragOp; 512 } 513 514 // If we are in the same process as the sender, make the sender post the appropriate message 515 if (sender) { 516 [[CDragSource currentDragSource] postDragEnter]; 517 } 518 } 519 520 // 9-11-02 Note: the native event thread would not handle an exception gracefully: 521 //if (sDraggingError == TRUE) 522 // [NSException raise:NSGenericException format:@"[CDropTarget draggingEntered] failed."]; 523 524 DLog2(@"[CDropTarget draggingEntered]: returning %lu\n", (unsigned long) dragOp); 525 526 return dragOp; 527 } 528 529 - (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender 530 { 531 //DLog2(@"[CDropTarget draggingUpdated]: %@\n", self); 532 533 sCurrentDropTarget = self; 534 535 // Set the initial drag operation return value: 536 NSDragOperation dragOp = (sDraggingError == FALSE ? sUpdateOperation : NSDragOperationNone); 537 592 } 593 594 DLog2(@"[CDropTarget draggingUpdated]: returning %lu\n", (unsigned long) dragOp); 595 596 return dragOp; 597 } 598 599 - (void)draggingExited:(id<NSDraggingInfo>)sender 600 { 601 DLog2(@"[CDropTarget draggingExited]: %@\n", self); 602 603 sCurrentDropTarget = nil; 604 605 JNIEnv* env = [ThreadUtilities getJNIEnv]; 606 607 if (sDraggingExited == FALSE && sDraggingError == FALSE) { 608 JNF_MEMBER_CACHE(handleExitMessageMethod, jc_CDropTargetContextPeer, "handleExitMessage", "(Ljava/awt/Component;J)V"); 609 if (sDraggingError == FALSE) { 610 DLog3(@" - dragExit: loc native %f, %f\n", sDraggingLocation.x, sDraggingLocation.y); 611 JNFCallVoidMethod(env, fDropTargetContextPeer, handleExitMessageMethod, fComponent, ptr_to_jlong(self)); // AWT_THREADING Safe (CToolkitThreadBlockedHandler) 612 // If we are in the same process as the sender, make the sender post the appropriate message 613 if (sender) { 614 [[CDragSource currentDragSource] postDragExit]; 615 } 616 } 617 618 // 5-27-03 Note: [Radar 3270455] 619 // -draggingExited: can be called both by the AppKit and by -performDragOperation: but shouldn't execute 620 // twice per drop since cleanup code like that in swing/plaf/basic/BasicDropTargetListener would throw NPEs. 621 sDraggingExited = TRUE; 622 } 623 624 DLog(@"[CDropTarget draggingExited]: returning.\n"); 625 } 626 627 - (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender 628 { 629 DLog2(@"[CDropTarget prepareForDragOperation]: %@\n", self); 630 DLog2(@"[CDropTarget prepareForDragOperation]: returning %@\n", (sDraggingError ? @"NO" : @"YES")); 631 632 return sDraggingError ? NO : YES; 633 } 634 635 - (BOOL)performDragOperation:(id<NSDraggingInfo>)sender | 493 actions = JNFCallIntMethod(env, fDropTargetContextPeer, handleEnterMessageMethod, fComponent, (jint) javaLocation.x, (jint) javaLocation.y, dropAction, actions, formats, ptr_to_jlong(self)); // AWT_THREADING Safe (CToolkitThreadBlockedHandler) 494 } 495 496 if (sDraggingError == FALSE) { 497 // Initialize drag operation: 498 sDragOperation = NSDragOperationNone; 499 500 // Map Java actions back to NSDragOperation. 501 // 1-6-03 Note: if the entry point of this CDropTarget isn't covered by a droppable component 502 // (as can be the case with lightweight children) we must not return NSDragOperationNone 503 // since that would prevent dropping into any of the contained drop targets. 504 // Unfortunately there is no easy way to test this so we just test actions and override them 505 // with GENERIC if necessary. Proper drag operations will be returned by draggingUpdated: which is 506 // called right away, taking care of setting the right cursor and snap-back action. 507 dragOp = ((actions != java_awt_dnd_DnDConstants_ACTION_NONE) ? 508 [DnDUtilities mapJavaDragOperationToNS:dropAction] : NSDragOperationGeneric); 509 510 // Remember the dragOp for no-op'd update messages: 511 sUpdateOperation = dragOp; 512 } 513 } 514 515 // 9-11-02 Note: the native event thread would not handle an exception gracefully: 516 //if (sDraggingError == TRUE) 517 // [NSException raise:NSGenericException format:@"[CDropTarget draggingEntered] failed."]; 518 519 DLog2(@"[CDropTarget draggingEntered]: returning %lu\n", (unsigned long) dragOp); 520 521 return dragOp; 522 } 523 524 - (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender 525 { 526 //DLog2(@"[CDropTarget draggingUpdated]: %@\n", self); 527 528 sCurrentDropTarget = self; 529 530 // Set the initial drag operation return value: 531 NSDragOperation dragOp = (sDraggingError == FALSE ? sUpdateOperation : NSDragOperationNone); 532 587 } 588 589 DLog2(@"[CDropTarget draggingUpdated]: returning %lu\n", (unsigned long) dragOp); 590 591 return dragOp; 592 } 593 594 - (void)draggingExited:(id<NSDraggingInfo>)sender 595 { 596 DLog2(@"[CDropTarget draggingExited]: %@\n", self); 597 598 sCurrentDropTarget = nil; 599 600 JNIEnv* env = [ThreadUtilities getJNIEnv]; 601 602 if (sDraggingExited == FALSE && sDraggingError == FALSE) { 603 JNF_MEMBER_CACHE(handleExitMessageMethod, jc_CDropTargetContextPeer, "handleExitMessage", "(Ljava/awt/Component;J)V"); 604 if (sDraggingError == FALSE) { 605 DLog3(@" - dragExit: loc native %f, %f\n", sDraggingLocation.x, sDraggingLocation.y); 606 JNFCallVoidMethod(env, fDropTargetContextPeer, handleExitMessageMethod, fComponent, ptr_to_jlong(self)); // AWT_THREADING Safe (CToolkitThreadBlockedHandler) 607 } 608 609 // 5-27-03 Note: [Radar 3270455] 610 // -draggingExited: can be called both by the AppKit and by -performDragOperation: but shouldn't execute 611 // twice per drop since cleanup code like that in swing/plaf/basic/BasicDropTargetListener would throw NPEs. 612 sDraggingExited = TRUE; 613 } 614 615 DLog(@"[CDropTarget draggingExited]: returning.\n"); 616 } 617 618 - (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender 619 { 620 DLog2(@"[CDropTarget prepareForDragOperation]: %@\n", self); 621 DLog2(@"[CDropTarget prepareForDragOperation]: returning %@\n", (sDraggingError ? @"NO" : @"YES")); 622 623 return sDraggingError ? NO : YES; 624 } 625 626 - (BOOL)performDragOperation:(id<NSDraggingInfo>)sender |