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