001: //The contents of this file are subject to the Mozilla Public License Version 1.1
002: //(the "License"); you may not use this file except in compliance with the
003: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
004: //
005: //Software distributed under the License is distributed on an "AS IS" basis,
006: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
007: //for the specific language governing rights and
008: //limitations under the License.
009: //
010: //The Original Code is "The Columba Project"
011: //
012: //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
013: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
014: //
015: //All Rights Reserved.
016: package org.columba.mail.gui.table;
017:
018: import java.awt.datatransfer.DataFlavor;
019: import java.awt.datatransfer.Transferable;
020: import java.awt.datatransfer.UnsupportedFlavorException;
021: import java.io.IOException;
022:
023: import org.columba.mail.command.IMailFolderCommandReference;
024:
025: /**
026: * A Transferable for moving message references.
027: *
028: * @author redsolo
029: */
030: public class MessageReferencesTransfer implements Transferable {
031: /** The only <code>DataFlavor</code> that this transfer allows. */
032: public static DataFlavor FLAVOR;
033:
034: static {
035: try {
036: FLAVOR = new DataFlavor(
037: DataFlavor.javaJVMLocalObjectMimeType + "-"
038: + MessageReferencesTransfer.class.getName());
039: } catch (Exception ex) {
040: ex.printStackTrace();
041: }
042: }
043:
044: private IMailFolderCommandReference reference;
045:
046: private int action;
047:
048: /**
049: * true, if operation is a drag'n'drop operation
050: */
051: private boolean isDragOperation;
052:
053: /**
054: * true, if operation is a cut/copy/paste accelerator key operation
055: * using the clipboard
056: */
057: private boolean isClipboardOperation;
058:
059: /**
060: * Creates a message transferable
061: *
062: * @param ref
063: * message references.
064: */
065: public MessageReferencesTransfer(IMailFolderCommandReference ref) {
066: super ();
067: reference = ref;
068:
069: isDragOperation = false;
070: isClipboardOperation = false;
071: }
072:
073: /**
074: * @return Returns the action.
075: */
076: public int getAction() {
077: return action;
078: }
079:
080: /**
081: * @param action The action to set.
082: */
083: public void setAction(int action) {
084: this .action = action;
085: }
086:
087: /**
088: * Returns the message references for this transfer.
089: *
090: * @return the message references for this transfer.
091: */
092: public IMailFolderCommandReference getFolderReferences() {
093: return reference;
094: }
095:
096: /** {@inheritDoc} */
097: public DataFlavor[] getTransferDataFlavors() {
098: return new DataFlavor[] { FLAVOR };
099: }
100:
101: /** {@inheritDoc} */
102: public boolean isDataFlavorSupported(DataFlavor flavor) {
103: return FLAVOR.equals(flavor);
104: }
105:
106: /** {@inheritDoc} */
107: public Object getTransferData(DataFlavor flavor)
108: throws UnsupportedFlavorException, IOException {
109: if (!isDataFlavorSupported(flavor)) {
110: throw new UnsupportedFlavorException(flavor);
111: }
112:
113: return this ;
114: }
115:
116: /**
117: * @return Returns the isClipboardOperation.
118: */
119: public boolean isClipboardOperation() {
120: return isClipboardOperation;
121: }
122:
123: /**
124: * @param isClipboardOperation The isClipboardOperation to set.
125: */
126: public void setClipboardOperation(boolean isClipboardOperation) {
127: this .isClipboardOperation = isClipboardOperation;
128: }
129:
130: /**
131: * @return Returns the isDragOperation.
132: */
133: public boolean isDragOperation() {
134: return isDragOperation;
135: }
136:
137: /**
138: * @param isDragOperation The isDragOperation to set.
139: */
140: public void setDragOperation(boolean isDragOperation) {
141: this.isDragOperation = isDragOperation;
142: }
143: }
|