KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > gui > tree > FolderTransfer


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
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 JavaDoc;
19 import java.awt.datatransfer.Transferable JavaDoc;
20 import java.awt.datatransfer.UnsupportedFlavorException JavaDoc;
21 import java.io.IOException JavaDoc;
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 JavaDoc {
31     /** The only <code>DataFlavor</code> that this transfer allows. */
32     public static DataFlavor JavaDoc FLAVOR;
33
34     static {
35         try {
36             FLAVOR = new DataFlavor JavaDoc(DataFlavor.javaJVMLocalObjectMimeType + "-"
37                     + FolderTransfer.class.getName());
38         } catch (Exception JavaDoc ex) {
39             ex.printStackTrace();
40         }
41     }
42
43     private IMailbox folderReference;
44
45     /**
46      * Creates a transferable for transfering folders.
47      *
48      * @param folder
49      * the folder that is being transfered.
50      */

51     public FolderTransfer(IMailbox folder) {
52         folderReference = folder;
53     }
54
55     /**
56      * Returns the folder reference for this transfer.
57      *
58      * @return a Folder
59      */

60     public IMailbox getFolderReference() {
61         return folderReference;
62     }
63
64     /** {@inheritDoc} */
65     public DataFlavor JavaDoc[] getTransferDataFlavors() {
66         return new DataFlavor JavaDoc[] { FLAVOR };
67     }
68
69     /** {@inheritDoc} */
70     public boolean isDataFlavorSupported(DataFlavor JavaDoc flavor) {
71         return FLAVOR.equals(flavor);
72     }
73
74     /** {@inheritDoc} */
75     public Object JavaDoc getTransferData(DataFlavor JavaDoc flavor)
76             throws UnsupportedFlavorException JavaDoc, IOException JavaDoc {
77         if (!isDataFlavorSupported(flavor)) {
78             throw new UnsupportedFlavorException JavaDoc(flavor);
79         }
80
81         return this;
82     }
83 }
84
Popular Tags