views:

20

answers:

0

I'm currently working on Java code that can copy files into the system clipboard.

For Windows and Linux I already got it working. For OSX I tried several flavors but the "Paste" action in Finder never cames active.

Any idea which DataFlavor settings are required for Finder?

Used flavors:

DataFlavor.javaFileListFlavor
URILIST_FLAVOR = new DataFlavor( "text/uri-list" );
XFILELIST_FLAVOR = new DataFlavor( "application/x-java-file-list" );
GNOMEFILELIST_FLAVOR = new DataFlavor( "x-special/gnome-copied-files" );

The method to return the data for the flavor:

public Object getTransferData( DataFlavor flavor ) throws UnsupportedFlavorException, IOException {
    if( FILELIST_FLAVOR.equals( flavor ) ) {
        if( List.class == flavor.getRepresentationClass() ) {
            return Arrays.asList( files );
        } else if( InputStream.class == flavor.getRepresentationClass() ) {
            return getStreamData( files, null );
        }
    } else if( DataFlavor.javaFileListFlavor.equals( flavor ) ) {
        if( List.class == flavor.getRepresentationClass() ) {
            return locallist;
        } else if( InputStream.class == flavor.getRepresentationClass() ) {
            return getStreamData( files, null );
        }
    } else if( URILIST_FLAVOR.equals( flavor ) ) {
        if( List.class == flavor.getRepresentationClass() ) {
            return Arrays.asList( files );
        } else if( InputStream.class == flavor.getRepresentationClass() ) {
            return getStreamData( files, null );
        }
    } else if( GNOMEFILELIST_FLAVOR.equals( flavor ) ) {
        if( List.class == flavor.getRepresentationClass() ) {
            return Arrays.asList( files );
        } else if( InputStream.class == flavor.getRepresentationClass() ) {
            // FIXME support cut and copy
            return getStreamData( files, "copy" );
        }
    } else if( XFILELIST_FLAVOR.equals( flavor ) ) {
        if( List.class == flavor.getRepresentationClass() ) {
            return locallist;
        } else if( InputStream.class == flavor.getRepresentationClass() ) {
            return getStreamData( files, null );
        }
    }
    throw new UnsupportedFlavorException( flavor );
}

Thanks, André