01: //The contents of this file are subject to the Mozilla Public License Version 1.1
02: //(the "License"); you may not use this file except in compliance with the
03: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
04: //
05: //Software distributed under the License is distributed on an "AS IS" basis,
06: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
07: //for the specific language governing rights and
08: //limitations under the License.
09: //
10: //The Original Code is "The Columba Project"
11: //
12: //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14: //
15: //All Rights Reserved.
16: package org.columba.mail.gui.tree;
17:
18: import java.awt.datatransfer.DataFlavor;
19: import java.awt.datatransfer.Transferable;
20: import java.awt.datatransfer.UnsupportedFlavorException;
21: import java.io.IOException;
22:
23: import org.columba.mail.folder.IMailbox;
24:
25: /**
26: * A Transferable for moving one folder.
27: *
28: * @author redsolo
29: */
30: public class FolderTransfer implements Transferable {
31: /** The only <code>DataFlavor</code> that this transfer allows. */
32: public static DataFlavor FLAVOR;
33:
34: static {
35: try {
36: FLAVOR = new DataFlavor(
37: DataFlavor.javaJVMLocalObjectMimeType + "-"
38: + FolderTransfer.class.getName());
39: } catch (Exception ex) {
40: ex.printStackTrace();
41: }
42: }
43:
44: private IMailbox folderReference;
45:
46: /**
47: * Creates a transferable for transfering folders.
48: *
49: * @param folder
50: * the folder that is being transfered.
51: */
52: public FolderTransfer(IMailbox folder) {
53: folderReference = folder;
54: }
55:
56: /**
57: * Returns the folder reference for this transfer.
58: *
59: * @return a Folder
60: */
61: public IMailbox getFolderReference() {
62: return folderReference;
63: }
64:
65: /** {@inheritDoc} */
66: public DataFlavor[] getTransferDataFlavors() {
67: return new DataFlavor[] { FLAVOR };
68: }
69:
70: /** {@inheritDoc} */
71: public boolean isDataFlavorSupported(DataFlavor flavor) {
72: return FLAVOR.equals(flavor);
73: }
74:
75: /** {@inheritDoc} */
76: public Object getTransferData(DataFlavor flavor)
77: throws UnsupportedFlavorException, IOException {
78: if (!isDataFlavorSupported(flavor)) {
79: throw new UnsupportedFlavorException(flavor);
80: }
81:
82: return this;
83: }
84: }
|