01: /*
02: * TransferableProfileNode.java
03: *
04: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
05: *
06: * Copyright 2002-2008, Thomas Kellerer
07: * No part of this code maybe reused without the permission of the author
08: *
09: * To contact the author please send an email to: support@sql-workbench.net
10: *
11: */
12: package workbench.gui.profiles;
13:
14: import java.awt.datatransfer.DataFlavor;
15: import java.awt.datatransfer.Transferable;
16: import java.awt.datatransfer.UnsupportedFlavorException;
17: import java.io.IOException;
18: import javax.swing.tree.TreePath;
19:
20: /**
21: * Handle drag and drop in the profile Tree
22: * @author support@sql-workbench.net
23: */
24: class TransferableProfileNode implements Transferable {
25: public static final DataFlavor PROFILE_FLAVOR = new DataFlavor(
26: TreePath.class, "ProfileTreeElement");
27: private TreePath[] path;
28:
29: public TransferableProfileNode(TreePath[] tp) {
30: path = tp;
31: }
32:
33: public DataFlavor[] getTransferDataFlavors() {
34: return new DataFlavor[] { PROFILE_FLAVOR };
35: }
36:
37: public boolean isDataFlavorSupported(DataFlavor flavor) {
38: return (flavor.getRepresentationClass() == PROFILE_FLAVOR
39: .getRepresentationClass());
40: }
41:
42: public synchronized Object getTransferData(DataFlavor flavor)
43: throws UnsupportedFlavorException, IOException {
44: if (isDataFlavorSupported(flavor)) {
45: return path;
46: } else {
47: throw new UnsupportedFlavorException(flavor);
48: }
49: }
50: }
|