1 26 27 package org.objectweb.util.browser.core.dnd; 28 29 import java.awt.datatransfer.Clipboard ; 30 import java.awt.datatransfer.ClipboardOwner ; 31 import java.awt.datatransfer.DataFlavor ; 32 import java.awt.datatransfer.Transferable ; 33 import java.awt.datatransfer.UnsupportedFlavorException ; 34 import java.io.IOException ; 35 import java.util.Arrays ; 36 import java.util.List ; 37 38 import org.objectweb.util.browser.core.common.EntryView; 39 40 47 public class EntryViewTransferable 48 implements Transferable , ClipboardOwner { 49 50 56 57 public static final DataFlavor [] flavors_ = getDataFlavor(); 60 61 62 protected final List flavorList_ = Arrays.asList(flavors_); 63 64 65 protected EntryView entryView_; 66 67 73 public EntryViewTransferable(EntryView entryView){ 74 entryView_ = entryView; 75 } 76 77 83 protected static DataFlavor [] getDataFlavor(){ 84 try{ 85 return new DataFlavor []{new DataFlavor (DataFlavor.javaJVMLocalObjectMimeType + ";class=org.objectweb.util.browser.core.common.EntryView")}; 86 } catch(ClassNotFoundException e){ 87 System.out.println("ClassNotFoundException"); 88 return null; 89 } 90 } 91 92 98 101 public DataFlavor [] getTransferDataFlavors() { 102 return flavors_; 103 } 104 105 108 public boolean isDataFlavorSupported(DataFlavor flavor) { 109 return flavorList_.contains(flavor); 110 } 111 112 115 public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException , IOException { 116 return entryView_; 117 } 118 119 125 128 public void lostOwnership(Clipboard clipboard, Transferable contents) { 129 System.out.println ("EntryViewTransferable losts ownership of " + clipboard.getName()); 130 System.out.println ("data: " + contents); 131 } 132 133 } | Popular Tags |