01: /*
02: * Created on 2003-nov-11
03: */
04: package org.columba.mail.gui.config.filter;
05:
06: import java.awt.datatransfer.DataFlavor;
07: import java.awt.datatransfer.Transferable;
08: import java.awt.datatransfer.UnsupportedFlavorException;
09: import java.io.IOException;
10:
11: import javax.swing.JComponent;
12:
13: /**
14: * An Object array transfer.
15: *
16: *
17: * @author redsolo
18: */
19: public class ObjectArrayTransfer implements Transferable {
20: /** The only <code>DataFlavor</code> that this transfer allows. */
21: public static DataFlavor FLAVOR;
22:
23: static {
24: try {
25: FLAVOR = new DataFlavor(
26: DataFlavor.javaJVMLocalObjectMimeType);
27: } catch (Exception ex) {
28: ex.printStackTrace();
29: }
30: }
31:
32: /** The JComponent that created this Transferable */
33: private JComponent source;
34:
35: /** The data that is being transfered */
36: private Object[] objectArray;
37:
38: /**
39: * Creates an object array transfer from the specified source.
40: * @param comp source component.
41: * @param arr the object array.
42: */
43: public ObjectArrayTransfer(JComponent comp, Object[] arr) {
44: source = comp;
45: objectArray = arr;
46: }
47:
48: /** {@inheritDoc}
49: * @return this object (ObjectArrayTransfer) */
50: public Object getTransferData(DataFlavor flavor)
51: throws UnsupportedFlavorException, IOException {
52: if (!isDataFlavorSupported(flavor)) {
53: throw new UnsupportedFlavorException(flavor);
54: }
55:
56: return this ;
57: }
58:
59: /** {@inheritDoc} */
60: public boolean isDataFlavorSupported(DataFlavor flavor) {
61: return FLAVOR.equals(flavor);
62: }
63:
64: /** {@inheritDoc} */
65: public DataFlavor[] getTransferDataFlavors() {
66: return new DataFlavor[] { FLAVOR };
67: }
68:
69: /**
70: * Returns the source of this transfer.
71: * @return the source of this transfer.
72: */
73: public JComponent getSource() {
74: return source;
75: }
76:
77: /**
78: * Returns the object array.
79: * @return the object array.
80: */
81: public Object[] getData() {
82: return objectArray;
83: }
84: }
|