View Javadoc
1 package com.bonevich.erj.ui; 2 3 import com.bonevich.erj.model.ModelElement; 4 5 import java.awt.datatransfer.*; 6 import java.io.IOException; 7 8 public final class TransferableModelElement 9 implements Transferable, ClipboardOwner 10 { 11 ////////////////////////////////////////////////////////// 12 // Attributes 13 private ModelElement _elt; 14 15 public static final DataFlavor MODEL_ELEMENT_FLAVOR 16 = new DataFlavor(ModelElement.class, "ModelElement"); 17 private static final DataFlavor[] _flavors = { MODEL_ELEMENT_FLAVOR }; 18 19 ////////////////////////////////////////////////////////// 20 // Constructors 21 public TransferableModelElement(ModelElement elt) 22 { 23 _elt = elt; 24 } 25 26 ////////////////////////////////////////////////////////// 27 // Transferable implementation 28 public DataFlavor[] getTransferDataFlavors() 29 { 30 return _flavors; 31 } 32 33 public Object getTransferData(DataFlavor flavor) 34 throws UnsupportedFlavorException, IOException 35 { 36 if (!isDataFlavorSupported(flavor)) 37 { 38 throw new UnsupportedFlavorException(flavor); 39 } 40 return _elt; 41 } 42 43 public boolean isDataFlavorSupported(DataFlavor flavor) 44 { 45 return flavor.equals(MODEL_ELEMENT_FLAVOR); 46 } 47 48 ////////////////////////////////////////////////////////// 49 // ClipboardOwner implementation 50 public void lostOwnership(Clipboard clipboard, Transferable contents) 51 { 52 } 53 54 } /*** end class TransferableModelElement */

This page was automatically generated by Maven