01: /*
02: * Copyright 2001-2006 C:1 Financial Services GmbH
03: *
04: * This software is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License Version 2.1, as published by the Free Software Foundation.
07: *
08: * This software is distributed in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11: * Lesser General Public License for more details.
12: *
13: * You should have received a copy of the GNU Lesser General Public
14: * License along with this library; if not, write to the Free Software
15: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
16: */
17:
18: package de.finix.contelligent.client.util.dnd;
19:
20: import java.awt.datatransfer.DataFlavor;
21: import java.awt.datatransfer.Transferable;
22: import java.awt.datatransfer.UnsupportedFlavorException;
23: import java.io.IOException;
24:
25: import de.finix.contelligent.client.base.ContelligentComponent;
26: import de.finix.contelligent.client.gui.View;
27:
28: public class MultipleComponentTransferable implements Transferable {
29: public static DataFlavor flavor = new DataFlavor(
30: ContelligentComponent[].class, "Multiple Components");
31:
32: private DataFlavor myFlavor = flavor;
33:
34: private ContelligentComponent[] components;
35: private String sourceEnvironment;
36:
37: public MultipleComponentTransferable(
38: ContelligentComponent[] components, String sourceEnvironment) {
39: this .components = components;
40: this .sourceEnvironment = sourceEnvironment;
41: }
42:
43: public DataFlavor[] getTransferDataFlavors() {
44: return new DataFlavor[] { myFlavor,
45: SingleComponentTransferable.sourceEnvironmentFlavor };
46: }
47:
48: public void setDataFlavor(DataFlavor newFlavor) {
49: myFlavor = newFlavor;
50: }
51:
52: public boolean isDataFlavorSupported(DataFlavor requestedFlavor) {
53: if (requestedFlavor == myFlavor) {
54: return true;
55: } else if (requestedFlavor
56: .equals(SingleComponentTransferable.sourceEnvironmentFlavor)) {
57: return true;
58: }
59: return false;
60: }
61:
62: public Object getTransferData(DataFlavor requestedFlavor)
63: throws UnsupportedFlavorException, IOException {
64: if (requestedFlavor
65: .equals(SingleComponentTransferable.sourceEnvironmentFlavor)) {
66: return sourceEnvironment;
67: }
68: return components;
69: }
70:
71: }
|