1 package org.telscenter.pas.authortool.common.DND;
2
3 import java.awt.datatransfer.DataFlavor;
4 import java.awt.datatransfer.Transferable;
5 import java.awt.datatransfer.UnsupportedFlavorException;
6 import java.beans.beancontext.BeanContextChildSupport;
7
8 public class BeanTransferable implements Transferable {
9
10 Object data;
11
12 String localBeanType = DataFlavor.javaJVMLocalObjectMimeType + ";class=java.beans.beancontext.BeanContextChildSupport";
13
14 public DataFlavor localBeanFlavor;
15
16 public BeanTransferable(final Object object) {
17 data = object;
18 try {
19 localBeanFlavor = new DataFlavor(localBeanType);
20 } catch (final ClassNotFoundException e) {
21
22 e.printStackTrace();
23 }
24 }
25
26 public Object getTransferData(final DataFlavor flavor)
27 throws UnsupportedFlavorException {
28 if (!isDataFlavorSupported(flavor))
29 throw new UnsupportedFlavorException(flavor);
30 return data;
31 }
32
33 public DataFlavor[] getTransferDataFlavors() {
34 return new DataFlavor[] { localBeanFlavor };
35 }
36
37 public boolean isDataFlavorSupported(final DataFlavor flavor) {
38 if (BeanContextChildSupport.class.equals(flavor.getRepresentationClass()))
39 return true;
40
41 return false;
42 }
43 }
44
45