KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > browser > core > dnd > EntryViewTransferable


1 /*====================================================================
2
3 Objectweb Browser framework
4 Copyright (C) 2000-2003 INRIA & USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Jerome Moroy.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.util.browser.core.dnd;
28
29 import java.awt.datatransfer.Clipboard JavaDoc;
30 import java.awt.datatransfer.ClipboardOwner JavaDoc;
31 import java.awt.datatransfer.DataFlavor JavaDoc;
32 import java.awt.datatransfer.Transferable JavaDoc;
33 import java.awt.datatransfer.UnsupportedFlavorException JavaDoc;
34 import java.io.IOException JavaDoc;
35 import java.util.Arrays JavaDoc;
36 import java.util.List JavaDoc;
37
38 import org.objectweb.util.browser.core.common.EntryView;
39
40 /**
41  *
42  *
43  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jerome Moroy</a>
44  *
45  * @version 0.1
46  */

47 public class EntryViewTransferable
48     implements Transferable JavaDoc, ClipboardOwner JavaDoc {
49
50     //==================================================================
51
//
52
// Internal states.
53
//
54
//==================================================================
55

56     /** The flavors representing the TreeView class */
57     //
58
// new DataFlavor(TreeView.class,"treeView")
59
public static final DataFlavor JavaDoc[] flavors_ = getDataFlavor();
60     
61     /** A list representing the flavors of the TreeView class */
62     protected final List JavaDoc flavorList_ = Arrays.asList(flavors_);
63     
64     /** The EntryView to transfer */
65     protected EntryView entryView_;
66
67     //==================================================================
68
//
69
// No constructor.
70
//
71
//==================================================================
72

73     public EntryViewTransferable(EntryView entryView){
74         entryView_ = entryView;
75     }
76
77     //==================================================================
78
//
79
// Internal methods.
80
//
81
//==================================================================
82

83     protected static DataFlavor JavaDoc[] getDataFlavor(){
84         try{
85             return new DataFlavor JavaDoc[]{new DataFlavor JavaDoc(DataFlavor.javaJVMLocalObjectMimeType + ";class=org.objectweb.util.browser.core.common.EntryView")};
86         } catch(ClassNotFoundException JavaDoc e){
87             System.out.println("ClassNotFoundException");
88             return null;
89         }
90     }
91
92     //==================================================================
93
//
94
// Public methods for Transferable.
95
//
96
//==================================================================
97

98     /*
99      * @see java.awt.datatransfer.Transferable#getTransferDataFlavors()
100      */

101     public DataFlavor JavaDoc[] getTransferDataFlavors() {
102         return flavors_;
103     }
104
105     /*
106      * @see java.awt.datatransfer.Transferable#isDataFlavorSupported(java.awt.datatransfer.DataFlavor)
107      */

108     public boolean isDataFlavorSupported(DataFlavor JavaDoc flavor) {
109         return flavorList_.contains(flavor);
110     }
111
112     /*
113      * @see java.awt.datatransfer.Transferable#getTransferData(java.awt.datatransfer.DataFlavor)
114      */

115     public Object JavaDoc getTransferData(DataFlavor JavaDoc flavor) throws UnsupportedFlavorException JavaDoc, IOException JavaDoc {
116         return entryView_;
117     }
118
119     //==================================================================
120
//
121
// Public methods for ClipboardOwner.
122
//
123
//==================================================================
124

125     /*
126      * @see java.awt.datatransfer.ClipboardOwner#lostOwnership(java.awt.datatransfer.Clipboard, java.awt.datatransfer.Transferable)
127      */

128     public void lostOwnership(Clipboard JavaDoc clipboard, Transferable JavaDoc contents) {
129         System.out.println ("EntryViewTransferable losts ownership of " + clipboard.getName());
130         System.out.println ("data: " + contents);
131     }
132
133 }
Popular Tags