1 28 29 package org.objectweb.util.explorer.core.dnd.lib; 30 31 import java.awt.datatransfer.Clipboard ; 32 import java.awt.datatransfer.ClipboardOwner ; 33 import java.awt.datatransfer.DataFlavor ; 34 import java.awt.datatransfer.Transferable ; 35 import java.awt.datatransfer.UnsupportedFlavorException ; 36 import java.io.IOException ; 37 import java.util.Arrays ; 38 import java.util.List ; 39 40 import org.objectweb.util.explorer.api.Entry; 41 import org.objectweb.util.trace.TraceSystem; 42 43 50 public class EntryTransferable 51 implements Transferable , ClipboardOwner { 52 53 59 60 public static final DataFlavor [] flavors_ = getDataFlavor(); 63 64 65 protected final List flavorList_ = Arrays.asList(flavors_); 66 67 68 protected Entry entryView_; 69 70 76 public EntryTransferable(Entry entryView){ 77 entryView_ = entryView; 78 } 79 80 86 protected static DataFlavor [] getDataFlavor(){ 87 try{ 88 return new DataFlavor []{new DataFlavor (DataFlavor.javaJVMLocalObjectMimeType + ";class=org.objectweb.util.explorer.api.Entry")}; 89 } catch(ClassNotFoundException e){ 90 TraceSystem.get("explorer").warn("[EntryTransferable] org.objectweb.util.explorer.api.Entry: Class Not Found!"); 91 return null; 92 } 93 } 94 95 101 104 public DataFlavor [] getTransferDataFlavors() { 105 return flavors_; 106 } 107 108 111 public boolean isDataFlavorSupported(DataFlavor flavor) { 112 return flavorList_.contains(flavor); 113 } 114 115 118 public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException , IOException { 119 return entryView_; 120 } 121 122 128 131 public void lostOwnership(Clipboard clipboard, Transferable contents) { 132 System.out.println ("EntryTransferable losts ownership of " + clipboard.getName()); 133 System.out.println ("data: " + contents); 134 } 135 136 } | Popular Tags |