1 15 16 package org.apache.ojb.tools.mapping.reversedb2.datatransfer; 17 import java.awt.datatransfer.*; 18 import org.apache.ojb.tools.mapping.reversedb2.dbmetatreemodel.*; 19 20 24 public class TransferableDBMetaTreeNodes implements java.awt.datatransfer.Transferable , java.io.Serializable 25 { 26 public static DataFlavor DBMETATABLENODE_FLAVOR_REMOTE; 27 public static DataFlavor DBMETATABLENODE_FLAVOR_LOCAL; 28 33 private static DataFlavor[] _flavors; 35 36 static 37 { 38 try 39 { 40 DBMETATABLENODE_FLAVOR_REMOTE = new DataFlavor(DataFlavor.javaRemoteObjectMimeType + ";class=org.apache.ojb.tools.mapping.reversedb2.datatransfer.TransferableDBMetaTreeNodes$ReverseDbTreeNodesContainer", "OJB Reversedb Database objects"); 43 DBMETATABLENODE_FLAVOR_LOCAL = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType + ";class=org.apache.ojb.tools.mapping.reversedb2.datatransfer.TransferableDBMetaTreeNodes$ReverseDbTreeNodesContainer"); 44 _flavors = new DataFlavor[] {DBMETATABLENODE_FLAVOR_LOCAL, DBMETATABLENODE_FLAVOR_REMOTE}; } 48 catch (ClassNotFoundException cce) 49 { 50 DBMETATABLENODE_FLAVOR_REMOTE = null; 51 DBMETATABLENODE_FLAVOR_LOCAL = null; 52 _flavors = null; 54 cce.printStackTrace(); 55 } 56 } 57 58 60 61 62 63 private ReverseDbTreeNodesContainer nodesContainer = new ReverseDbTreeNodesContainer(); 65 66 public TransferableDBMetaTreeNodes (ReverseDbTreeNode[] pselectedNodes) 67 { 68 nodesContainer.selectedNodes = pselectedNodes; 69 } 70 71 public Object getTransferData(java.awt.datatransfer.DataFlavor dataFlavor) 72 throws java.awt.datatransfer.UnsupportedFlavorException , java.io.IOException 73 { 74 if ( dataFlavor.equals(DBMETATABLENODE_FLAVOR_REMOTE) 75 || dataFlavor.equals(DBMETATABLENODE_FLAVOR_LOCAL) 76 ) 77 return nodesContainer.selectedNodes; 79 else 80 throw new UnsupportedFlavorException(dataFlavor); 81 } 82 83 public java.awt.datatransfer.DataFlavor [] getTransferDataFlavors() 84 { 85 return _flavors; 86 } 87 88 public boolean isDataFlavorSupported(DataFlavor flavor) 89 { 90 boolean b = java.util.Arrays.asList(_flavors).contains(flavor); 91 System.err.println("TransferableDBMetaTreeNodes.isDataFlavorSupported " + flavor + " returns " + b); 92 return java.util.Arrays.asList(_flavors).contains(flavor); 93 } 94 95 public static class ReverseDbTreeNodesContainer 96 implements java.io.Serializable 97 { 98 private ReverseDbTreeNode[] selectedNodes; 99 } 100 } 101 | Popular Tags |