-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix dragging playlist from playlists-directory panel into playlist ed…
…itor
- Loading branch information
Showing
2 changed files
with
62 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package listfix.view; | ||
|
||
import java.awt.datatransfer.DataFlavor; | ||
import java.awt.datatransfer.Transferable; | ||
import java.awt.datatransfer.UnsupportedFlavorException; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
/** | ||
* Converts a List of Files into a <code>java.awt.datatransfer.Transferable</code> of flavour <code>application/x-java-file-list;class=java.util.List</code> | ||
* @author Borewit | ||
* @see DataFlavor#javaFileListFlavor | ||
*/ | ||
public class FileListTransferable implements Transferable | ||
{ | ||
private List<File> fileList; | ||
private DataFlavor[] dataFlavors; | ||
|
||
public FileListTransferable(List<File> fileList) | ||
{ | ||
this.fileList = Collections.unmodifiableList(fileList); | ||
this.dataFlavors = new DataFlavor[] {DataFlavor.javaFileListFlavor}; | ||
} | ||
|
||
@Override | ||
public DataFlavor[] getTransferDataFlavors() | ||
{ | ||
return dataFlavors; | ||
} | ||
|
||
@Override | ||
public boolean isDataFlavorSupported(DataFlavor flavor) | ||
{ | ||
return Arrays.stream(this.dataFlavors).anyMatch(f -> f.equals(flavor)); | ||
} | ||
|
||
@Override | ||
public List<File> getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException | ||
{ | ||
return this.fileList; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters