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