src/macosx/native/sun/awt/CDragSource.m

Print this page




 296     // And assume there are no NS-type data: [Radar 3065621]
 297     // This is to be able to drop transferables containing only a serialized object flavor, e.g.:
 298     //   "JAVA_DATAFLAVOR:application/x-java-serialized-object; class=java.awt.Label".
 299     BOOL hasNSTypeData = false;
 300 
 301     // Collect all supported types in a pasteboard format into the storage arrays:
 302     jsize i;
 303     for (i = 0; i < formatsLength; i++) {
 304         jlong jformat = jformats[i];
 305 
 306         if (jformat >= 0) {
 307             NSString* type = formatForIndex(jformat);
 308 
 309             // Add element type to the storage array.
 310             if (type != nil) {
 311                 if ([type hasPrefix:@"JAVA_DATAFLAVOR:application/x-java-jvm-local-objectref;"] == false) {
 312                     [pbTypes addObject:type];
 313 
 314                     // This is a good approximation if not perfect. A conclusive search would
 315                     // have to be done matching all defined strings in AppKit's commonStrings.h.
 316                     if ([type hasPrefix:@"NS"] || [type hasPrefix:@"NeXT"])
 317                         hasNSTypeData = true;
 318                 }
 319             }
 320         }
 321     }
 322 
 323     // 1-16-03 Note: [Radar 3065621]
 324     // When TransferHandler is used with Swing components it puts only a type like this on the pasteboard:
 325     //   "JAVA_DATAFLAVOR:application/x-java-jvm-local-objectref; class=java.lang.String"
 326     // And there's similar type for serialized object only transferables.
 327     // Since our drop targets aren't trained for arbitrary data types yet we need to fake an empty string
 328     // which will cause drop target handlers to fire.
 329     // KCH  - 3550405 If the drag is between Swing components, formatsLength == 0, so expand the check.
 330     // Also, use a custom format rather than NSString, since that will prevent random views from accepting the drag
 331     if (hasNSTypeData == false && formatsLength >= 0) {
 332         [pbTypes addObject:[DnDUtilities javaPboardType]];
 333     }
 334 
 335     (*env)->ReleaseLongArrayElements(env, fFormats, jformats, JNI_ABORT);
 336 
 337     // Declare pasteboard types. If the types array is empty we still want to declare them




 296     // And assume there are no NS-type data: [Radar 3065621]
 297     // This is to be able to drop transferables containing only a serialized object flavor, e.g.:
 298     //   "JAVA_DATAFLAVOR:application/x-java-serialized-object; class=java.awt.Label".
 299     BOOL hasNSTypeData = false;
 300 
 301     // Collect all supported types in a pasteboard format into the storage arrays:
 302     jsize i;
 303     for (i = 0; i < formatsLength; i++) {
 304         jlong jformat = jformats[i];
 305 
 306         if (jformat >= 0) {
 307             NSString* type = formatForIndex(jformat);
 308 
 309             // Add element type to the storage array.
 310             if (type != nil) {
 311                 if ([type hasPrefix:@"JAVA_DATAFLAVOR:application/x-java-jvm-local-objectref;"] == false) {
 312                     [pbTypes addObject:type];
 313 
 314                     // This is a good approximation if not perfect. A conclusive search would
 315                     // have to be done matching all defined strings in AppKit's commonStrings.h.
 316                     hasNSTypeData = [type hasPrefix:@"NS"] || [type hasPrefix:@"NeXT"] || [type hasPrefix:@"public."];

 317                 }
 318             }
 319         }
 320     }
 321 
 322     // 1-16-03 Note: [Radar 3065621]
 323     // When TransferHandler is used with Swing components it puts only a type like this on the pasteboard:
 324     //   "JAVA_DATAFLAVOR:application/x-java-jvm-local-objectref; class=java.lang.String"
 325     // And there's similar type for serialized object only transferables.
 326     // Since our drop targets aren't trained for arbitrary data types yet we need to fake an empty string
 327     // which will cause drop target handlers to fire.
 328     // KCH  - 3550405 If the drag is between Swing components, formatsLength == 0, so expand the check.
 329     // Also, use a custom format rather than NSString, since that will prevent random views from accepting the drag
 330     if (hasNSTypeData == false && formatsLength >= 0) {
 331         [pbTypes addObject:[DnDUtilities javaPboardType]];
 332     }
 333 
 334     (*env)->ReleaseLongArrayElements(env, fFormats, jformats, JNI_ABORT);
 335 
 336     // Declare pasteboard types. If the types array is empty we still want to declare them