Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

DraggableTree.java

00001 package edu.ksu.cis.bandera.pdgslicer.dependency;
00002 
00003 import javax.swing.*;
00004 import javax.swing.tree.*;
00005 import javax.swing.plaf.TreeUI;
00006 import java.awt.*;
00007 import java.awt.dnd.*;
00008 import java.awt.datatransfer.*;
00009 import java.io.IOException;
00010 public abstract class DraggableTree extends JTree implements DragGestureListener {
00011     static Transferable currentDraggingTreeNode;
00012     static boolean draggingTreeNode;
00013     DragSource dragSource = DragSource.getDefaultDragSource();
00014     DragSourceListener dragSourceListener = new MyDragSourceListener();
00015     class MyDragSourceListener implements DragSourceListener {
00016         public void dragDropEnd(DragSourceDropEvent DragSourceDropEvent) {
00017             //System.out.println("Drag Drop End");
00018             //currentDraggingTreeNode = null;
00019             draggingTreeNode = false;
00020         }
00021         public void dragEnter(DragSourceDragEvent DragSourceDragEvent) {
00022             //      System.out.println ("Drag Enter");
00023         }
00024         public void dragExit(DragSourceEvent DragSourceEvent) {
00025             //System.out.println("Drag Exit");
00026             //currentDraggingTreeNode = null;
00027             draggingTreeNode=false;
00028         }
00029         public void dragOver(DragSourceDragEvent DragSourceDragEvent) {
00030             //      System.out.println ("Drag Over");
00031         }
00032         public void dropActionChanged(DragSourceDragEvent DragSourceDragEvent) {
00033             //      System.out.println ("Drag Action Changed");
00034         }
00035     }
00036 /*
00037 TreePath path = getSelectionPath();
00038 if (path == null) {
00039 // Nothing selected, nothing to drag
00040 System.out.println("Nothing selected - beep");
00041 getToolkit().beep();
00042 } else {
00043 DefaultMutableTreeNode selection = (DefaultMutableTreeNode) path.getLastPathComponent();
00044 synchronized (this) {
00045 currentDraggingTreeNode = new TransferableTreeNode(selection);
00046 System.out.println("currentDraggingTreeNode: " + currentDraggingTreeNode);
00047 }
00048 dragSource.startDrag(dragGestureEvent, DragSource.DefaultCopyDrop, currentDraggingTreeNode, dragSourceListener);
00049 }
00050 }
00051 */
00052   public DraggableTree () {
00053     dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE, this);
00054   }  
00055   public DraggableTree (TreeModel model) {
00056     super (model);
00057     dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE, this);
00058   }  
00059 // DragGestureListener
00060 
00061 public abstract void dragGestureRecognized(DragGestureEvent dragGestureEvent) 
00062 ;
00063 }

Generated at Thu Feb 7 06:44:39 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001