KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > him > dnd > TableDragSource


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19
20 package org.openharmonise.him.dnd;
21
22 import java.awt.Component JavaDoc;
23 import java.awt.Cursor JavaDoc;
24 import java.awt.Point JavaDoc;
25 import java.awt.Toolkit JavaDoc;
26 import java.awt.dnd.DragGestureEvent JavaDoc;
27 import java.awt.dnd.DragGestureListener JavaDoc;
28 import java.awt.dnd.DragGestureRecognizer JavaDoc;
29 import java.awt.dnd.DragSource JavaDoc;
30 import java.awt.dnd.DragSourceDragEvent JavaDoc;
31 import java.awt.dnd.DragSourceDropEvent JavaDoc;
32 import java.awt.dnd.DragSourceEvent JavaDoc;
33 import java.awt.dnd.DragSourceListener JavaDoc;
34
35 import javax.swing.ImageIcon JavaDoc;
36
37 import org.openharmonise.him.displaycomponents.table.*;
38 import org.openharmonise.vfs.gui.*;
39
40
41 /**
42  * Drag source for the table view. Used for copying or moving resources
43  * to another collection.
44  *
45  * @author Matthew Large
46  * @version $Revision: 1.1 $
47  *
48  */

49 public class TableDragSource
50     implements DragSourceListener JavaDoc, DragGestureListener JavaDoc {
51
52         DragSource JavaDoc source;
53         DragGestureRecognizer JavaDoc recognizer;
54         TableEntry sourceTable;
55
56     /**
57      * Constructs a new table drag source.
58      *
59      * @param table Table view
60      * @param comp Component
61      * @param actions Allowed actions
62      */

63     public TableDragSource(TableEntry table, Component JavaDoc comp, int actions) {
64         sourceTable=table;
65         source = new DragSource JavaDoc();
66         recognizer = source.createDefaultDragGestureRecognizer(comp, actions, this);
67       }
68
69     /* (non-Javadoc)
70      * @see java.awt.dnd.DragSourceListener#dragEnter(java.awt.dnd.DragSourceDragEvent)
71      */

72     public void dragEnter(DragSourceDragEvent JavaDoc arg0) {
73     }
74
75     /* (non-Javadoc)
76      * @see java.awt.dnd.DragSourceListener#dragOver(java.awt.dnd.DragSourceDragEvent)
77      */

78     public void dragOver(DragSourceDragEvent JavaDoc arg0) {
79     }
80
81     /* (non-Javadoc)
82      * @see java.awt.dnd.DragSourceListener#dropActionChanged(java.awt.dnd.DragSourceDragEvent)
83      */

84     public void dropActionChanged(DragSourceDragEvent JavaDoc arg0) {
85     }
86
87     /* (non-Javadoc)
88      * @see java.awt.dnd.DragSourceListener#dragDropEnd(java.awt.dnd.DragSourceDropEvent)
89      */

90     public void dragDropEnd(DragSourceDropEvent JavaDoc arg0) {
91     }
92
93     /* (non-Javadoc)
94      * @see java.awt.dnd.DragSourceListener#dragExit(java.awt.dnd.DragSourceEvent)
95      */

96     public void dragExit(DragSourceEvent JavaDoc arg0) {
97     }
98
99     /* (non-Javadoc)
100      * @see java.awt.dnd.DragGestureListener#dragGestureRecognized(java.awt.dnd.DragGestureEvent)
101      */

102     public void dragGestureRecognized(DragGestureEvent JavaDoc dge) {
103         Cursor JavaDoc cursor = Toolkit.getDefaultToolkit().createCustomCursor( ((ImageIcon JavaDoc)IconManager.getInstance().getIcon("16-pointer-drag.gif")).getImage(), new Point JavaDoc(3,1),"COPY");
104
105         dge.startDrag(cursor, new VirtualFileTransferable( this.sourceTable.getVFS().getVirtualFile(this.sourceTable.getDragVirtualFilePath()).getResource() ), this);
106     }
107
108 }
Popular Tags