001: /*
002: * The contents of this file are subject to the
003: * Mozilla Public License Version 1.1 (the "License");
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
009: * See the License for the specific language governing rights and
010: * limitations under the License.
011: *
012: * The Initial Developer of the Original Code is Simulacra Media Ltd.
013: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014: *
015: * All Rights Reserved.
016: *
017: * Contributor(s):
018: */
019:
020: package org.openharmonise.him.dnd;
021:
022: import java.awt.Component;
023: import java.awt.Cursor;
024: import java.awt.Point;
025: import java.awt.Toolkit;
026: import java.awt.dnd.DragGestureEvent;
027: import java.awt.dnd.DragGestureListener;
028: import java.awt.dnd.DragGestureRecognizer;
029: import java.awt.dnd.DragSource;
030: import java.awt.dnd.DragSourceDragEvent;
031: import java.awt.dnd.DragSourceDropEvent;
032: import java.awt.dnd.DragSourceEvent;
033: import java.awt.dnd.DragSourceListener;
034:
035: import javax.swing.ImageIcon;
036:
037: import org.openharmonise.him.swing.resourcetree.*;
038: import org.openharmonise.vfs.gui.*;
039:
040: /**
041: * Drag source for the resource tree. Used in the workflow editor for
042: * dragging stages into the diagram.
043: *
044: * @author Matthew Large
045: * @version $Revision: 1.1 $
046: *
047: */
048: public class TreeDragSource implements DragSourceListener,
049: DragGestureListener {
050:
051: DragSource m_source;
052: DragGestureRecognizer m_recognizer;
053: ResourceTree m_tree;
054:
055: /**
056: * Constructs a new tree drag source.
057: *
058: * @param tree Resource tree
059: * @param comp Component
060: * @param actions Allowed actions
061: */
062: public TreeDragSource(ResourceTree tree, Component comp, int actions) {
063: super ();
064: this .m_tree = tree;
065: this .m_source = new DragSource();
066: this .m_recognizer = this .m_source
067: .createDefaultDragGestureRecognizer(comp, actions, this );
068: }
069:
070: /* (non-Javadoc)
071: * @see java.awt.dnd.DragSourceListener#dragEnter(java.awt.dnd.DragSourceDragEvent)
072: */
073: public void dragEnter(DragSourceDragEvent arg0) {
074: }
075:
076: /* (non-Javadoc)
077: * @see java.awt.dnd.DragSourceListener#dragOver(java.awt.dnd.DragSourceDragEvent)
078: */
079: public void dragOver(DragSourceDragEvent arg0) {
080: }
081:
082: /* (non-Javadoc)
083: * @see java.awt.dnd.DragSourceListener#dropActionChanged(java.awt.dnd.DragSourceDragEvent)
084: */
085: public void dropActionChanged(DragSourceDragEvent arg0) {
086: }
087:
088: /* (non-Javadoc)
089: * @see java.awt.dnd.DragSourceListener#dragDropEnd(java.awt.dnd.DragSourceDropEvent)
090: */
091: public void dragDropEnd(DragSourceDropEvent arg0) {
092: }
093:
094: /* (non-Javadoc)
095: * @see java.awt.dnd.DragSourceListener#dragExit(java.awt.dnd.DragSourceEvent)
096: */
097: public void dragExit(DragSourceEvent arg0) {
098: }
099:
100: /* (non-Javadoc)
101: * @see java.awt.dnd.DragGestureListener#dragGestureRecognized(java.awt.dnd.DragGestureEvent)
102: */
103: public void dragGestureRecognized(DragGestureEvent dge) {
104: Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(
105: ((ImageIcon) IconManager.getInstance().getIcon(
106: "16-pointer-drag.gif")).getImage(),
107: new Point(3, 1), "COPY");
108:
109: this .m_source.startDrag(dge, cursor,
110: new VirtualFileTransferable(this.m_tree
111: .getSelectedResource().getVFS().getVirtualFile(
112: this.m_tree.getSelectedResource()
113: .getFullPath()).getResource()),
114: this);
115: }
116:
117: }
|