Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
MatrixTreeTransferable.java
1 
16 package net.squiz.matrix.matrixtree;
17 
18 import java.awt.datatransfer.*;
19 import java.util.*;
20 import java.io.*;
21 import javax.swing.tree.*;
22 
23 public class MatrixTreeTransferable implements Transferable, Serializable {
24 
25  public static final DataFlavor TREE_NODE_FLAVOUR
26  = new DataFlavor(MatrixTreeNode.class, "Matrix Tree Node");
27 
28  static DataFlavor flavors[] = { TREE_NODE_FLAVOUR };
29 
30  private final List paths;
31 
32  public MatrixTreeTransferable(TreePath[] paths) {
33  this.paths = Arrays.asList(paths);
34  }
35 
36  public Object getTransferData(DataFlavor flavor)
37  throws UnsupportedFlavorException, IOException {
38  if (flavor.equals(TREE_NODE_FLAVOUR))
39  return paths;
40  else
41  throw new UnsupportedFlavorException(flavor);
42  }
43 
44  public DataFlavor[] getTransferDataFlavors() {
45  return flavors;
46  }
47 
48  public boolean isDataFlavorSupported(DataFlavor flavor) {
49  return flavor.equals(TREE_NODE_FLAVOUR);
50  }
51 }