KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > gui > table > MessageReferencesTransfer


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.table;
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.command.IMailFolderCommandReference;
24
25 /**
26  * A Transferable for moving message references.
27  *
28  * @author redsolo
29  */

30 public class MessageReferencesTransfer 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                     + MessageReferencesTransfer.class.getName());
38         } catch (Exception JavaDoc ex) {
39             ex.printStackTrace();
40         }
41     }
42
43     private IMailFolderCommandReference reference;
44     
45     private int action;
46     
47     /**
48      * true, if operation is a drag'n'drop operation
49      */

50     private boolean isDragOperation;
51     
52     /**
53      * true, if operation is a cut/copy/paste accelerator key operation
54      * using the clipboard
55      */

56     private boolean isClipboardOperation;
57
58     /**
59      * Creates a message transferable
60      *
61      * @param ref
62      * message references.
63      */

64     public MessageReferencesTransfer(IMailFolderCommandReference ref) {
65         super();
66         reference = ref;
67         
68         isDragOperation = false;
69         isClipboardOperation = false;
70     }
71
72     
73     /**
74      * @return Returns the action.
75      */

76     public int getAction() {
77         return action;
78     }
79     
80     /**
81      * @param action The action to set.
82      */

83     public void setAction(int action) {
84         this.action = action;
85     }
86     /**
87      * Returns the message references for this transfer.
88      *
89      * @return the message references for this transfer.
90      */

91     public IMailFolderCommandReference getFolderReferences() {
92         return reference;
93     }
94
95     /** {@inheritDoc} */
96     public DataFlavor JavaDoc[] getTransferDataFlavors() {
97         return new DataFlavor JavaDoc[] { FLAVOR };
98     }
99
100     /** {@inheritDoc} */
101     public boolean isDataFlavorSupported(DataFlavor JavaDoc flavor) {
102         return FLAVOR.equals(flavor);
103     }
104
105     /** {@inheritDoc} */
106     public Object JavaDoc getTransferData(DataFlavor JavaDoc flavor)
107             throws UnsupportedFlavorException JavaDoc, IOException JavaDoc {
108         if (!isDataFlavorSupported(flavor)) {
109             throw new UnsupportedFlavorException JavaDoc(flavor);
110         }
111
112         return this;
113     }
114     /**
115      * @return Returns the isClipboardOperation.
116      */

117     public boolean isClipboardOperation() {
118         return isClipboardOperation;
119     }
120     /**
121      * @param isClipboardOperation The isClipboardOperation to set.
122      */

123     public void setClipboardOperation(boolean isClipboardOperation) {
124         this.isClipboardOperation = isClipboardOperation;
125     }
126     /**
127      * @return Returns the isDragOperation.
128      */

129     public boolean isDragOperation() {
130         return isDragOperation;
131     }
132     /**
133      * @param isDragOperation The isDragOperation to set.
134      */

135     public void setDragOperation(boolean isDragOperation) {
136         this.isDragOperation = isDragOperation;
137     }
138 }
Popular Tags