KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.awt.Component JavaDoc;
19 import java.awt.datatransfer.Transferable JavaDoc;
20 import java.awt.Image JavaDoc;
21 import org.apache.ojb.tools.mapping.reversedb2.dbmetatreemodel.*;
22 import org.apache.ojb.tools.mapping.reversedb2.datatransfer.*;
23
24 /**
25  * @author <a HREF="mailto:bfl@florianbruckner.com">Florian Bruckner</a>
26  * @version $Id: ReverseDbNodesDragWorker.java,v 1.1.2.1 2005/12/21 22:32:42 tomdz Exp $
27  */

28 public class ReverseDbNodesDragWorker implements DragCopyCutWorkerInterface
29 {
30     
31     /** Creates a new instance of ReverseDbNodesDragWorker */
32     public ReverseDbNodesDragWorker ()
33     {
34     }
35     
36     public void exportDone (Component JavaDoc c, int action)
37     {
38         System.err.println("exportDone");
39     }
40     
41     public void exportStarted (Component JavaDoc c, int action)
42     {
43         System.err.println("exportStarted");
44     }
45     
46     public int getAcceptableActions (Component JavaDoc c)
47     {
48         return DnDWorkerConstants.DRAG_COPY | DnDWorkerConstants.DRAG_LINK;
49     }
50     
51     public Image JavaDoc getDragImage (Component JavaDoc c, Transferable JavaDoc t, int action)
52     {
53         return null;
54     }
55     
56     public Transferable JavaDoc getTransferable (Component JavaDoc c)
57     {
58         System.err.println("getTransferable()");
59         try
60         {
61             if (c instanceof javax.swing.JTree JavaDoc)
62             {
63                 System.err.println(" e is a JTree");
64                 javax.swing.JTree JavaDoc jtree = (javax.swing.JTree JavaDoc)c;
65                 if (jtree.getModel() instanceof DatabaseMetaDataTreeModel)
66                 {
67                     System.err.println(" and has a DatabaseMetaDataTreeModel");
68                     ReverseDbTreeNode[] selectedNodes =
69                         new ReverseDbTreeNode[jtree.getSelectionCount()];
70                     for (int i = 0; jtree.getSelectionPaths() != null && i < jtree.getSelectionPaths().length; i++)
71                     {
72                         System.err.println(" adding Node" + jtree.getSelectionPaths()[i].getLastPathComponent());
73                         selectedNodes[i] = (ReverseDbTreeNode) jtree.getSelectionPaths()[i].getLastPathComponent();
74                     }
75                     return new TransferableDBMetaTreeNodes(selectedNodes);
76                 }
77             }
78         }
79         catch (Throwable JavaDoc t)
80         {
81             t.printStackTrace();
82         }
83         System.err.println(" returning null");
84         return null;
85     }
86     
87 }
88
Popular Tags