KickJava   Java API By Example, From Geeks To Geeks.

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


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.swing.resourcetree.*;
38 import org.openharmonise.vfs.gui.*;
39
40
41 /**
42  * Drag source for the resource tree. Used in the workflow editor for
43  * dragging stages into the diagram.
44  *
45  * @author Matthew Large
46  * @version $Revision: 1.1 $
47  *
48  */

49 public class TreeDragSource
50     implements DragSourceListener JavaDoc, DragGestureListener JavaDoc {
51
52         DragSource JavaDoc m_source;
53         DragGestureRecognizer JavaDoc m_recognizer;
54         ResourceTree m_tree;
55
56     /**
57      * Constructs a new tree drag source.
58      *
59      * @param tree Resource tree
60      * @param comp Component
61      * @param actions Allowed actions
62      */

63     public TreeDragSource(ResourceTree tree, Component JavaDoc comp, int actions) {
64         super();
65         this.m_tree = tree;
66         this.m_source = new DragSource JavaDoc();
67         this.m_recognizer = this.m_source.createDefaultDragGestureRecognizer(comp, actions, this);
68     }
69
70     /* (non-Javadoc)
71      * @see java.awt.dnd.DragSourceListener#dragEnter(java.awt.dnd.DragSourceDragEvent)
72      */

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

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

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

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

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

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