View Javadoc

1   package org.telscenter.pas.authortool.common.tree;
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(Object object) {
17          data = object;
18  		try {
19  			localBeanFlavor = new DataFlavor(localBeanType);
20  		} catch (ClassNotFoundException e) {
21  			// TODO Auto-generated catch block
22  			e.printStackTrace();
23  		}
24      }
25  
26      public Object getTransferData(DataFlavor flavor)
27                               throws UnsupportedFlavorException {
28          if (!isDataFlavorSupported(flavor)) {
29              throw new UnsupportedFlavorException(flavor);
30          }
31          return data;
32      }
33  
34      public DataFlavor[] getTransferDataFlavors() {
35          return new DataFlavor[] { localBeanFlavor };
36      }
37  
38      public boolean isDataFlavorSupported(DataFlavor flavor) {
39          if (BeanContextChildSupport.class.equals(flavor.getRepresentationClass())) {
40              return true;
41          }
42         
43          return false;
44      }
45  }
46  
47