KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > tools > mapping > reversedb2 > dnd2 > ReverseDbNodesDropWorker


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

17
18 import org.apache.ojb.tools.mapping.reversedb2.dbmetatreemodel.*;
19 import org.apache.ojb.tools.mapping.reversedb2.datatransfer.*;
20
21 /**
22  * @author <a HREF="mailto:bfl@florianbruckner.com">Florian Bruckner</a>
23  * @version $Id: ReverseDbNodesDropWorker.java,v 1.1.2.1 2005/12/21 22:32:42 tomdz Exp $
24  */

25 public class ReverseDbNodesDropWorker implements DropPasteWorkerInterface
26 {
27     /** Creates a new instance of ReverseDbNodesDropWorker */
28     public ReverseDbNodesDropWorker ()
29     {
30     }
31    
32     public int getAcceptableActions (java.awt.Component JavaDoc c)
33     {
34         return DnDWorkerConstants.DRAG_MOVE | DnDWorkerConstants.DRAG_COPY ;
35     }
36     
37     public int getAcceptableActions (java.awt.Component JavaDoc c, java.awt.datatransfer.DataFlavor JavaDoc[] flavor)
38     {
39         for (int j = 0; j < flavor.length; j++)
40             if (flavor[j].isMimeTypeEqual (TransferableDBMetaTreeNodes.DBMETATABLENODE_FLAVOR_REMOTE))
41                 return DnDWorkerConstants.DRAG_MOVE | DnDWorkerConstants.DRAG_COPY;
42         return DnDWorkerConstants.NONE;
43     }
44     
45     public java.awt.datatransfer.DataFlavor JavaDoc getSupportedDataFlavor ()
46     {
47         return TransferableDBMetaTreeNodes.DBMETATABLENODE_FLAVOR_REMOTE;
48     }
49     
50     public boolean importData (java.awt.Component JavaDoc c, java.awt.datatransfer.Transferable JavaDoc t, int action)
51     {
52         if (t.isDataFlavorSupported(TransferableDBMetaTreeNodes.DBMETATABLENODE_FLAVOR_REMOTE))
53         {
54             try
55             {
56                 ReverseDbTreeNode[] nodes =
57                     (ReverseDbTreeNode[])t.getTransferData(TransferableDBMetaTreeNodes.DBMETATABLENODE_FLAVOR_REMOTE);
58                 for (int i = 0; i < nodes.length; i++)
59                     System.err.println("Transfered: " + nodes[i]);
60                 return true;
61             }
62             catch (Throwable JavaDoc throwable)
63             {
64                 throwable.printStackTrace();
65                 return false;
66             }
67         }
68         else
69         {
70             return false;
71         }
72     }
73 }
74
Popular Tags