KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > tools > mapping > reversedb2 > datatransfer > TransferableDBMetaTreeNodes


1 /* Copyright 2002-2005 The Apache Software Foundation
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */

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 /**
21  *
22  * @author Administrator
23  */

24 public class TransferableDBMetaTreeNodes implements java.awt.datatransfer.Transferable JavaDoc, java.io.Serializable JavaDoc
25 {
26     public static DataFlavor DBMETATABLENODE_FLAVOR_REMOTE;
27     public static DataFlavor DBMETATABLENODE_FLAVOR_LOCAL;
28 // public static DataFlavor DBMETATABLENODE_FLAVOR_SERIALIZED;
29
// = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType + "; class=org.apache.ojb.tools.mapping.reversedb2.dbmetatreemodel.ReverseDbTreeNode[]", "Reverse Engineered Database Objects");
30
// = new DataFlavor(org.apache.ojb.tools.mapping.reversedb2.dbmetatreemodel.ReverseDbTreeNode[].class, "DB");
31
// = new DataFlavor(DataFlavor.javaRemoteObjectMimeType + ";class=org.apache.ojb.tools.mapping.reversedb2.dbmetatreemodel.ReverseDbTreeNode[]");
32

33     // private static final DataFlavor[] _flavors = {DBMETABLENODE_FLAVOR};
34
private static DataFlavor[] _flavors;
35     
36     static
37     {
38         try
39         {
40             // System.err.println(org.apache.ojb.tools.mapping.reversedb2.dbmetatreemodel.ReverseDbTreeNode[].class.getName());
41
// DBMETATABLENODE_FLAVOR_REMOTE = new DataFlavor(org.apache.ojb.tools.mapping.reversedb2.datatransfer.TransferableDBMetaTreeNodes.ReverseDbTreeNodesContainer.class, "OJB Reversedb Database objects");
42
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             // DBMETATABLENODE_FLAVOR_SERIALIZED = new DataFlavor(DataFlavor.javaSerializedObjectMimeType + ";class=org.apache.ojb.tools.mapping.reversedb2.datatransfer.TransferableDBMetaTreeNodes$ReverseDbTreeNodesContainer");
45
// DBMETATABLENODE_FLAVOR_SERIALIZED = DBMETATABLENODE_FLAVOR_REMOTE;
46
_flavors = new DataFlavor[] {DBMETATABLENODE_FLAVOR_LOCAL, DBMETATABLENODE_FLAVOR_REMOTE}; //, DBMETATABLENODE_FLAVOR_SERIALIZED};
47
}
48         catch (ClassNotFoundException JavaDoc cce)
49         {
50             DBMETATABLENODE_FLAVOR_REMOTE = null;
51             DBMETATABLENODE_FLAVOR_LOCAL = null;
52 // DBMETATABLENODE_FLAVOR_SERIALIZED = null;
53
_flavors = null;
54             cce.printStackTrace();
55         }
56     }
57     
58 // org.apache.ojb.tools.mapping.reversedb2.dbmetatreemodel.ReverseDbTreeNode[]
59

60
61     /** Creates a new instance of TransferableDBMetaTable */
62     
63     // private ReverseDbTreeNode[] selectedNodes;
64
private ReverseDbTreeNodesContainer nodesContainer = new ReverseDbTreeNodesContainer();
65     
66     public TransferableDBMetaTreeNodes (ReverseDbTreeNode[] pselectedNodes)
67     {
68         nodesContainer.selectedNodes = pselectedNodes;
69     }
70     
71     public Object JavaDoc getTransferData(java.awt.datatransfer.DataFlavor JavaDoc dataFlavor)
72         throws java.awt.datatransfer.UnsupportedFlavorException JavaDoc, java.io.IOException JavaDoc
73     {
74         if ( dataFlavor.equals(DBMETATABLENODE_FLAVOR_REMOTE)
75             || dataFlavor.equals(DBMETATABLENODE_FLAVOR_LOCAL)
76            )
77 // || dataFlaCvor.isMimeTypeEqual(DBMETATABLENODE_FLAVOR_SERIALIZED))
78
return nodesContainer.selectedNodes;
79         else
80             throw new UnsupportedFlavorException(dataFlavor);
81     }
82     
83     public java.awt.datatransfer.DataFlavor JavaDoc[] 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 JavaDoc
97     {
98         private ReverseDbTreeNode[] selectedNodes;
99     }
100 }
101
Popular Tags