001: /* Copyright 2002-2005 The Apache Software Foundation
002: *
003: * Licensed under the Apache License, Version 2.0 (the "License");
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at
006: *
007: * http://www.apache.org/licenses/LICENSE-2.0
008: *
009: * Unless required by applicable law or agreed to in writing, software
010: * distributed under the License is distributed on an "AS IS" BASIS,
011: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012: * See the License for the specific language governing permissions and
013: * limitations under the License.
014: */
015:
016: package org.apache.ojb.tools.mapping.reversedb2.datatransfer;
017:
018: import java.awt.datatransfer.*;
019: import org.apache.ojb.tools.mapping.reversedb2.dbmetatreemodel.*;
020:
021: /**
022: *
023: * @author Administrator
024: */
025: public class TransferableDBMetaTreeNodes implements
026: java.awt.datatransfer.Transferable, java.io.Serializable {
027: public static DataFlavor DBMETATABLENODE_FLAVOR_REMOTE;
028: public static DataFlavor DBMETATABLENODE_FLAVOR_LOCAL;
029: // public static DataFlavor DBMETATABLENODE_FLAVOR_SERIALIZED;
030: // = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType + "; class=org.apache.ojb.tools.mapping.reversedb2.dbmetatreemodel.ReverseDbTreeNode[]", "Reverse Engineered Database Objects");
031: // = new DataFlavor(org.apache.ojb.tools.mapping.reversedb2.dbmetatreemodel.ReverseDbTreeNode[].class, "DB");
032: // = new DataFlavor(DataFlavor.javaRemoteObjectMimeType + ";class=org.apache.ojb.tools.mapping.reversedb2.dbmetatreemodel.ReverseDbTreeNode[]");
033:
034: // private static final DataFlavor[] _flavors = {DBMETABLENODE_FLAVOR};
035: private static DataFlavor[] _flavors;
036:
037: static {
038: try {
039: // System.err.println(org.apache.ojb.tools.mapping.reversedb2.dbmetatreemodel.ReverseDbTreeNode[].class.getName());
040: // DBMETATABLENODE_FLAVOR_REMOTE = new DataFlavor(org.apache.ojb.tools.mapping.reversedb2.datatransfer.TransferableDBMetaTreeNodes.ReverseDbTreeNodesContainer.class, "OJB Reversedb Database objects");
041: DBMETATABLENODE_FLAVOR_REMOTE = new DataFlavor(
042: DataFlavor.javaRemoteObjectMimeType
043: + ";class=org.apache.ojb.tools.mapping.reversedb2.datatransfer.TransferableDBMetaTreeNodes$ReverseDbTreeNodesContainer",
044: "OJB Reversedb Database objects");
045: DBMETATABLENODE_FLAVOR_LOCAL = new DataFlavor(
046: DataFlavor.javaJVMLocalObjectMimeType
047: + ";class=org.apache.ojb.tools.mapping.reversedb2.datatransfer.TransferableDBMetaTreeNodes$ReverseDbTreeNodesContainer");
048: // DBMETATABLENODE_FLAVOR_SERIALIZED = new DataFlavor(DataFlavor.javaSerializedObjectMimeType + ";class=org.apache.ojb.tools.mapping.reversedb2.datatransfer.TransferableDBMetaTreeNodes$ReverseDbTreeNodesContainer");
049: // DBMETATABLENODE_FLAVOR_SERIALIZED = DBMETATABLENODE_FLAVOR_REMOTE;
050: _flavors = new DataFlavor[] { DBMETATABLENODE_FLAVOR_LOCAL,
051: DBMETATABLENODE_FLAVOR_REMOTE }; //, DBMETATABLENODE_FLAVOR_SERIALIZED};
052: } catch (ClassNotFoundException cce) {
053: DBMETATABLENODE_FLAVOR_REMOTE = null;
054: DBMETATABLENODE_FLAVOR_LOCAL = null;
055: // DBMETATABLENODE_FLAVOR_SERIALIZED = null;
056: _flavors = null;
057: cce.printStackTrace();
058: }
059: }
060:
061: // org.apache.ojb.tools.mapping.reversedb2.dbmetatreemodel.ReverseDbTreeNode[]
062:
063: /** Creates a new instance of TransferableDBMetaTable */
064:
065: // private ReverseDbTreeNode[] selectedNodes;
066: private ReverseDbTreeNodesContainer nodesContainer = new ReverseDbTreeNodesContainer();
067:
068: public TransferableDBMetaTreeNodes(
069: ReverseDbTreeNode[] pselectedNodes) {
070: nodesContainer.selectedNodes = pselectedNodes;
071: }
072:
073: public Object getTransferData(
074: java.awt.datatransfer.DataFlavor dataFlavor)
075: throws java.awt.datatransfer.UnsupportedFlavorException,
076: java.io.IOException {
077: if (dataFlavor.equals(DBMETATABLENODE_FLAVOR_REMOTE)
078: || dataFlavor.equals(DBMETATABLENODE_FLAVOR_LOCAL))
079: // || dataFlaCvor.isMimeTypeEqual(DBMETATABLENODE_FLAVOR_SERIALIZED))
080: return nodesContainer.selectedNodes;
081: else
082: throw new UnsupportedFlavorException(dataFlavor);
083: }
084:
085: public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors() {
086: return _flavors;
087: }
088:
089: public boolean isDataFlavorSupported(DataFlavor flavor) {
090: boolean b = java.util.Arrays.asList(_flavors).contains(flavor);
091: System.err
092: .println("TransferableDBMetaTreeNodes.isDataFlavorSupported "
093: + flavor + " returns " + b);
094: return java.util.Arrays.asList(_flavors).contains(flavor);
095: }
096:
097: public static class ReverseDbTreeNodesContainer implements
098: java.io.Serializable {
099: private ReverseDbTreeNode[] selectedNodes;
100: }
101: }
|