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.displaycomponents.table.*;
038: import org.openharmonise.vfs.gui.*;
039:
040: /**
041: * Drag source for the table view. Used for copying or moving resources
042: * to another collection.
043: *
044: * @author Matthew Large
045: * @version $Revision: 1.1 $
046: *
047: */
048: public class TableDragSource implements DragSourceListener,
049: DragGestureListener {
050:
051: DragSource source;
052: DragGestureRecognizer recognizer;
053: TableEntry sourceTable;
054:
055: /**
056: * Constructs a new table drag source.
057: *
058: * @param table Table view
059: * @param comp Component
060: * @param actions Allowed actions
061: */
062: public TableDragSource(TableEntry table, Component comp, int actions) {
063: sourceTable = table;
064: source = new DragSource();
065: recognizer = source.createDefaultDragGestureRecognizer(comp,
066: actions, this );
067: }
068:
069: /* (non-Javadoc)
070: * @see java.awt.dnd.DragSourceListener#dragEnter(java.awt.dnd.DragSourceDragEvent)
071: */
072: public void dragEnter(DragSourceDragEvent arg0) {
073: }
074:
075: /* (non-Javadoc)
076: * @see java.awt.dnd.DragSourceListener#dragOver(java.awt.dnd.DragSourceDragEvent)
077: */
078: public void dragOver(DragSourceDragEvent arg0) {
079: }
080:
081: /* (non-Javadoc)
082: * @see java.awt.dnd.DragSourceListener#dropActionChanged(java.awt.dnd.DragSourceDragEvent)
083: */
084: public void dropActionChanged(DragSourceDragEvent arg0) {
085: }
086:
087: /* (non-Javadoc)
088: * @see java.awt.dnd.DragSourceListener#dragDropEnd(java.awt.dnd.DragSourceDropEvent)
089: */
090: public void dragDropEnd(DragSourceDropEvent arg0) {
091: }
092:
093: /* (non-Javadoc)
094: * @see java.awt.dnd.DragSourceListener#dragExit(java.awt.dnd.DragSourceEvent)
095: */
096: public void dragExit(DragSourceEvent arg0) {
097: }
098:
099: /* (non-Javadoc)
100: * @see java.awt.dnd.DragGestureListener#dragGestureRecognized(java.awt.dnd.DragGestureEvent)
101: */
102: public void dragGestureRecognized(DragGestureEvent dge) {
103: Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(
104: ((ImageIcon) IconManager.getInstance().getIcon(
105: "16-pointer-drag.gif")).getImage(),
106: new Point(3, 1), "COPY");
107:
108: dge.startDrag(cursor, new VirtualFileTransferable(
109: this.sourceTable.getVFS().getVirtualFile(
110: this.sourceTable.getDragVirtualFilePath())
111: .getResource()), this);
112: }
113:
114: }
|