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

DroppableVariablesList.java

00001 package edu.ksu.cis.bandera.pdgslicer.dependency;
00002 
00003 import java.awt.*;
00004 import java.awt.dnd.*;
00005 import java.awt.datatransfer.*;
00006 import javax.swing.*;
00007 import java.io.*;
00008 import java.util.*;
00009 import java.util.List;
00010 //import edu.ksu.cis.bandera.annotation.*;
00011 import edu.ksu.cis.bandera.pdgslicer.datastructure.*;
00012 /**
00013  * Insert the type's description here.
00014  * Creation date: (00-11-20 10:03:05)
00015  * @author: 
00016  */
00017 public class DroppableVariablesList extends DroppableList {
00018 /**
00019  * DroppableVariablesList constructor comment.
00020  */
00021 public DroppableVariablesList() {
00022     super();
00023 }
00024 public void dragEnter(DropTargetDragEvent dropTargetDragEvent) {
00025     Transferable tr = DraggableTree.currentDraggingTreeNode;
00026     if (tr == null) {
00027         dropTargetDragEvent.rejectDrag();
00028     } else if (DraggableTree.draggingTreeNode) {
00029         Object userObject = null;
00030         try {
00031             userObject = tr.getTransferData(TransferableSliceVariable.SLICE_VARIABLE_FLAVOR);
00032         } catch (IOException io) {
00033             io.printStackTrace();
00034             dropTargetDragEvent.rejectDrag();
00035         } catch (UnsupportedFlavorException ufe) {
00036             ufe.printStackTrace();
00037             dropTargetDragEvent.rejectDrag();
00038         }
00039         if (userObject instanceof SliceVariable) {
00040             dropTargetDragEvent.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
00041             return;
00042         } else
00043             dropTargetDragEvent.rejectDrag();
00044 }
00045 Object listNode = DraggableList.currentDraggingListNode;
00046 if (listNode == null)
00047     dropTargetDragEvent.rejectDrag();
00048 else
00049     dropTargetDragEvent.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
00050 }
00051 public void drop(DropTargetDropEvent dropTargetDropEvent) {
00052     try {
00053         Transferable tr = DraggableTree.currentDraggingTreeNode;
00054         if (tr == null || !DraggableTree.draggingTreeNode)
00055             tr = DraggableList.currentDraggingListNode;
00056         if (tr.isDataFlavorSupported(TransferableSliceVariable.SLICE_VARIABLE_FLAVOR)) {
00057             dropTargetDropEvent.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
00058             Object userObject = tr.getTransferData(TransferableSliceVariable.SLICE_VARIABLE_FLAVOR);
00059             criterionViewer.addVarToCriterion(userObject);
00060             dropTargetDropEvent.getDropTargetContext().dropComplete(true);
00061         } else {
00062             System.err.println("Rejected");
00063             dropTargetDropEvent.rejectDrop();
00064         }
00065     } catch (IOException io) {
00066         io.printStackTrace();
00067         dropTargetDropEvent.rejectDrop();
00068     } catch (UnsupportedFlavorException ufe) {
00069         ufe.printStackTrace();
00070         dropTargetDropEvent.rejectDrop();
00071     }
00072 }
00073 }

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