CDropTarget.m revision 6057
4632N/A return sCurrentDropTarget;
4632N/A- (id)init:(jobject)jdropTarget component:(jobject)jcomponent peer:(jobject)jpeer control:(id)control
4632N/A// When [CDropTarget init] is called the ControlModel's fView may not have been set up yet. ControlModel
4632N/A// (soon after) calls [CDropTarget controlModelControlValid] on the native event thread, once per CDropTarget,
4632N/A- (void)controlModelControlValid
4632N/A- (void)releaseDraggingData
4632N/A return sDraggingSequenceNumber;
4632N/A // For each flavor on the pasteboard show the type, its data, and its property if there is one:
4632N/A // Copy all data formats and properties. In case of properties, if they are nil, we need to use
4632N/A DLog2(@"[CDropTarget copyDraggingTypes]: typesCount = %lu\n", (unsigned long) sPasteboardItemsCount);
4632N/A // They're often copies of their flavor's data and copying them for all available pasteboard flavors
4632N/A // If this is a remote object type (not a pre-defined format) register it with the pasteboard:
4632N/A if (jformats[i] == -1 && [pbType hasPrefix:@"JAVA_DATAFLAVOR:application/x-java-remote-object;"])
4632N/A // Copy all data items to a safe place since the pasteboard may go away before we'll need them:
4632N/A // 01-10-03 Note: copying only NS-type data (until Java-specified types can make it through the AppKit)
4632N/A // would be a good idea since we can't do anything with those CoreFoundation unknown types anyway.
4632N/A // But I'm worried that it would break something in Fuller so I'm leaving this here as a reminder,
4632N/A //id pbData = [pbType hasPrefix:@"NS"] ? [pb dataForType:pbType] : nil; // Copy only NS-type data!
4632N/A id propertyList = [NSPropertyListSerialization propertyListFromData:data mutabilityOption:NSPropertyListImmutable
4632N/A if (propertyList != nil && errorString == nil && [propertyList isKindOfClass:[NSArray class]]) {
4639N/A JNIEnv* env = [ThreadUtilities getJNIEnvUncached]; // Join the main thread by requesting uncached environment
4632N/A return gbyteArray;
4632N/A- (void)javaDraggingEnded:(jlong)draggingSequenceNumber success:(BOOL)jsuccess action:(jint)jdropaction
6057N/A [ThreadUtilities performOnMainThread:@selector(safeReleaseDraggingData:) on:self withObject:draggingSequenceNumberID waitUntilDone:NO];
4632N/A/******************************** BEGIN NSDraggingDestination Interface ********************************/
4632N/A NSDragOperation rawDragActions = (NSDragOperation) [jrsDrag performSelector:@selector(currentAllowableActions)];
4632N/A NSUInteger dragModifiers = (NSUInteger) [jrsDrag performSelector:@selector(currentModifiers)];
4632N/A // Either the drop action is narrowed as per Java rules (MOVE, COPY, LINK, NONE) or by the drag modifiers
4632N/A if (dragModifiers) {
4632N/A // Get the user selected operation based on the drag modifiers, then return the intersection
4632N/A JNF_STATIC_MEMBER_CACHE(getDropTargetContextPeerMethod, jc_CDropTargetContextPeer, "getDropTargetContextPeer", "()Lsun/lwawt/macosx/CDropTargetContextPeer;");
4632N/A jobject dropTargetContextPeer = JNFCallStaticObjectMethod(env, getDropTargetContextPeerMethod);
4632N/A DLog5(@"+ dragEnter: loc native %f, %f, java %f, %f\n", sDraggingLocation.x, sDraggingLocation.y, javaLocation.x, javaLocation.y);
4632N/A JNF_MEMBER_CACHE(handleEnterMessageMethod, jc_CDropTargetContextPeer, "handleEnterMessage", "(Ljava/awt/Component;IIII[JJ)I");
4632N/A actions = JNFCallIntMethod(env, fDropTargetContextPeer, handleEnterMessageMethod, fComponent, (jint) javaLocation.x, (jint) javaLocation.y, dropAction, actions, formats, ptr_to_jlong(self)); // AWT_THREADING Safe (CToolkitThreadBlockedHandler)
4632N/A // 1-6-03 Note: if the entry point of this CDropTarget isn't covered by a droppable component
4632N/A // Unfortunately there is no easy way to test this so we just test actions and override them
4632N/A // with GENERIC if necessary. Proper drag operations will be returned by draggingUpdated: which is
4632N/A // If we are in the same process as the sender, make the sender post the appropriate message
4632N/A NSDragOperation dragOp = (sDraggingError == FALSE ? sUpdateOperation : NSDragOperationNone);
4632N/A // b) drag actions (key modifiers) have changed (handleMotionMessage() will do proper notifications):
4730N/A // For some reason even after the convertPoint drag events come with the y coordinate reverted
4632N/A //DLog5(@" : dragMoved: loc native %f, %f, java %f, %f\n", sDraggingLocation.x, sDraggingLocation.y, javaLocation.x, javaLocation.y);
4632N/A JNF_MEMBER_CACHE(handleMotionMessageMethod, jc_CDropTargetContextPeer, "handleMotionMessage", "(Ljava/awt/Component;IIII[JJ)I");
4632N/A userAction = JNFCallIntMethod(env, fDropTargetContextPeer, handleMotionMessageMethod, fComponent, (jint) javaLocation.x, (jint) javaLocation.y, dropAction, actions, formats, ptr_to_jlong(self)); // AWT_THREADING Safe (CToolkitThreadBlockedHandler)
4632N/A JNF_MEMBER_CACHE(handleExitMessageMethod, jc_CDropTargetContextPeer, "handleExitMessage", "(Ljava/awt/Component;J)V");
4632N/A JNFCallVoidMethod(env, fDropTargetContextPeer, handleExitMessageMethod, fComponent, ptr_to_jlong(self)); // AWT_THREADING Safe (CToolkitThreadBlockedHandler)
4632N/A // If we are in the same process as the sender, make the sender post the appropriate message
4632N/A // -draggingExited: can be called both by the AppKit and by -performDragOperation: but shouldn't execute
4632N/A // twice per drop since cleanup code like that in swing/plaf/basic/BasicDropTargetListener would throw NPEs.
4632N/A DLog2(@"[CDropTarget prepareForDragOperation]: returning %@\n", (sDraggingError ? @"NO" : @"YES"));
4632N/A jint actions = [DnDUtilities mapNSDragOperationMaskToJava:[sender draggingSourceOperationMask]];
4632N/A JNF_MEMBER_CACHE(handleDropMessageMethod, jc_CDropTargetContextPeer, "handleDropMessage", "(Ljava/awt/Component;IIII[JJ)V");
4632N/A JNFCallVoidMethod(env, fDropTargetContextPeer, handleDropMessageMethod, fComponent, (jint) javaLocation.x, (jint) javaLocation.y, dropAction, actions, formats, ptr_to_jlong(self)); // AWT_THREADING Safe (event)
4632N/A JNF_MEMBER_CACHE(flushEventsMethod, jc_CDropTargetContextPeer, "flushEvents", "(Ljava/awt/Component;)V");
4632N/A JNFCallVoidMethod(env, fDropTargetContextPeer, flushEventsMethod, fComponent); // AWT_THREADING Safe (AWTRunLoopMode)
4632N/A DLog2(@"[CDropTarget performDragOperation]: returning %@\n", (sDraggingError ? @"NO" : @"YES"));
4632N/A return !sDraggingError;
4632N/A/******************************** END NSDraggingDestination Interface ********************************/
4632N/A (JNIEnv *env, jobject jthis, jobject jdroptarget, jobject jcomponent, jobject jpeer, jlong jnativepeer)
4632N/A dropTarget = [[CDropTarget alloc] init:jdroptarget component:jcomponent peer:jpeer control:controlObj];
4632N/A if (dropTarget) {