01: package org.apache.ojb.tools.mapping.reversedb2.dnd2;
02:
03: /* Copyright 2002-2005 The Apache Software Foundation
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * 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;
19: import java.awt.datatransfer.Transferable;
20: import java.awt.Image;
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
29: DragCopyCutWorkerInterface {
30:
31: /** Creates a new instance of ReverseDbNodesDragWorker */
32: public ReverseDbNodesDragWorker() {
33: }
34:
35: public void exportDone(Component c, int action) {
36: System.err.println("exportDone");
37: }
38:
39: public void exportStarted(Component c, int action) {
40: System.err.println("exportStarted");
41: }
42:
43: public int getAcceptableActions(Component c) {
44: return DnDWorkerConstants.DRAG_COPY
45: | DnDWorkerConstants.DRAG_LINK;
46: }
47:
48: public Image getDragImage(Component c, Transferable t, int action) {
49: return null;
50: }
51:
52: public Transferable getTransferable(Component c) {
53: System.err.println("getTransferable()");
54: try {
55: if (c instanceof javax.swing.JTree) {
56: System.err.println(" e is a JTree");
57: javax.swing.JTree jtree = (javax.swing.JTree) c;
58: if (jtree.getModel() instanceof DatabaseMetaDataTreeModel) {
59: System.err
60: .println(" and has a DatabaseMetaDataTreeModel");
61: ReverseDbTreeNode[] selectedNodes = new ReverseDbTreeNode[jtree
62: .getSelectionCount()];
63: for (int i = 0; jtree.getSelectionPaths() != null
64: && i < jtree.getSelectionPaths().length; i++) {
65: System.err.println(" adding Node"
66: + jtree.getSelectionPaths()[i]
67: .getLastPathComponent());
68: selectedNodes[i] = (ReverseDbTreeNode) jtree
69: .getSelectionPaths()[i]
70: .getLastPathComponent();
71: }
72: return new TransferableDBMetaTreeNodes(
73: selectedNodes);
74: }
75: }
76: } catch (Throwable t) {
77: t.printStackTrace();
78: }
79: System.err.println(" returning null");
80: return null;
81: }
82:
83: }
|