Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
CueTreeTransferHandler.java
1 
16 package net.squiz.cuetree;
17 
18 import javax.swing.*;
19 import java.awt.event.*;
20 import java.awt.datatransfer.*;
21 import java.util.*;
22 
23 public class CueTreeTransferHandler extends TransferHandler {
24 
25  public CueTreeTransferHandler() {
26  System.out.println("DragAndDropTransferHandler created");
27  }
28 
29  public boolean canImport(JComponent comp, DataFlavor[] transferFlavors) {
30 
31  for (int i = 0; i < transferFlavors.length; i++) {
32  if (transferFlavors[i].equals(DataFlavor.javaFileListFlavor)) {
33  System.out.println("was a file");
34  return true;
35  }
36  }
37  System.out.println("There were no files in the clipboard");
38  return false;
39  }
40 
41  public boolean importData(JComponent c, Transferable t) {
42 
43  System.out.println("Start of importData");
44 
45  if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
46  List files = null;
47  try {
48  files = (List) t.getTransferData(DataFlavor.javaFileListFlavor);
49  } catch (Exception e) {
50  e.printStackTrace();
51  }
52  System.out.println(files);
53  } else {
54  System.out.println("Was not a file");
55  }
56 
57  System.out.println("importing data");
58  return true;
59  }
60 }