00001 package edu.ksu.cis.bandera.pdgslicer.dependency;
00002
00003 import javax.swing.*;
00004 import javax.swing.tree.*;
00005 import java.awt.dnd.*;
00006 import java.awt.datatransfer.*;
00007
00008 import edu.ksu.cis.bandera.annotation.*;
00009 import edu.ksu.cis.bandera.pdgslicer.datastructure.*;
00010
00011
00012
00013
00014
00015 public class DraggableHierTree extends DraggableTree {
00016
00017
00018
00019 public DraggableHierTree() {
00020 super();
00021 }
00022
00023
00024
00025
00026 public DraggableHierTree(javax.swing.tree.TreeModel model) {
00027
00028 }
00029
00030
00031 public void dragGestureRecognized(DragGestureEvent dragGestureEvent) {
00032 TreePath path = getSelectionPath();
00033 if (path == null) {
00034
00035 currentDraggingTreeNode = null;
00036 draggingTreeNode = false;
00037 System.out.println("Nothing selected - beep");
00038 getToolkit().beep();
00039 } else {
00040 DefaultMutableTreeNode selection = (DefaultMutableTreeNode) path.getLastPathComponent();
00041 Object userObject = selection.getUserObject();
00042 if (userObject instanceof FieldDeclarationAnnotation) {
00043 FieldDeclarationAnnotation fda = (FieldDeclarationAnnotation) userObject;
00044 SliceVariable sf = new SliceField(fda.getSootField().getDeclaringClass(), fda.getSootField());
00045 currentDraggingTreeNode = new TransferableSliceVariable(sf);
00046 draggingTreeNode = true;
00047 dragSource.startDrag(dragGestureEvent, DragSource.DefaultCopyDrop, currentDraggingTreeNode, DraggableHierTree.this.dragSourceListener);
00048 } else {
00049 System.out.println("Select wrong node - beep");
00050 currentDraggingTreeNode = null;
00051 draggingTreeNode = false;
00052 getToolkit().beep();
00053 }
00054 }
00055 }
00056 }