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

DroppableList.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 public abstract class DroppableList extends JList implements DropTargetListener {
00011     DropTarget dropTarget;
00012     CriterionViewer criterionViewer;
00013   public DroppableList() {
00014     dropTarget = new DropTarget (this, this);
00015     setModel(new DefaultListModel());
00016   }  
00017 public abstract void dragEnter(DropTargetDragEvent dropTargetDragEvent);
00018 /*
00019 {
00020     System.out.println("drag enter drop");
00021     dropTargetDragEvent.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
00022 }
00023 */
00024   public void dragExit (DropTargetEvent dropTargetEvent) {
00025      // System.out.println("drag exit drop");
00026   }  
00027   public void dragOver (DropTargetDragEvent dropTargetDragEvent) {
00028      // System.out.println("drap over drop");
00029   }  
00030 public abstract void drop(DropTargetDropEvent dropTargetDropEvent);
00031 /*
00032 7{
00033     try {
00034         //Transferable tr = dropTargetDropEvent.getTransferable();
00035 
00036         Transferable tr = DraggableTree.currentDraggingTreeNode;
00037         if (tr.isDataFlavorSupported(TransferableTreeNode.DEFAULT_MUTABLE_TREENODE_FLAVOR)) {
00038             dropTargetDropEvent.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
00039             Object userObject = tr.getTransferData(TransferableTreeNode.DEFAULT_MUTABLE_TREENODE_FLAVOR);
00040             ((DefaultListModel) getModel()).addElement(userObject);
00041             dropTargetDropEvent.getDropTargetContext().dropComplete(true);
00042         } else
00043             if (tr.isDataFlavorSupported(DataFlavor.stringFlavor)) {
00044                 dropTargetDropEvent.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
00045                 String string = (String) tr.getTransferData(DataFlavor.stringFlavor);
00046                 ((DefaultListModel) getModel()).addElement(string);
00047                 dropTargetDropEvent.getDropTargetContext().dropComplete(true);
00048             } else
00049                 if (tr.isDataFlavorSupported(DataFlavor.plainTextFlavor)) {
00050                     dropTargetDropEvent.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
00051                     Object stream = tr.getTransferData(DataFlavor.plainTextFlavor);
00052                     if (stream instanceof InputStream) {
00053                         InputStreamReader isr = new InputStreamReader((InputStream) stream);
00054                         BufferedReader reader = new BufferedReader(isr);
00055                         String line;
00056                         while ((line = reader.readLine()) != null) {
00057                             ((DefaultListModel) getModel()).addElement(line);
00058                         }
00059                         dropTargetDropEvent.getDropTargetContext().dropComplete(true);
00060                     } else
00061                         if (stream instanceof Reader) {
00062                             BufferedReader reader = new BufferedReader((Reader) stream);
00063                             String line;
00064                             while ((line = reader.readLine()) != null) {
00065                                 ((DefaultListModel) getModel()).addElement(line);
00066                             }
00067                             dropTargetDropEvent.getDropTargetContext().dropComplete(true);
00068                         } else {
00069                             System.err.println("Unknown type: " + stream.getClass());
00070                             dropTargetDropEvent.rejectDrop();
00071                         }
00072                 } else
00073                     if (tr.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
00074                         dropTargetDropEvent.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
00075                         List fileList = (List) tr.getTransferData(DataFlavor.javaFileListFlavor);
00076                         Iterator iterator = fileList.iterator();
00077                         while (iterator.hasNext()) {
00078                             File file = (File) iterator.next();
00079                             Hashtable hashtable = new Hashtable();
00080                             hashtable.put("name", file.getName());
00081                             hashtable.put("url", file.toURL().toString());
00082                             ((DefaultListModel) getModel()).addElement(hashtable);
00083                         }
00084                         dropTargetDropEvent.getDropTargetContext().dropComplete(true);
00085                     } else {
00086                         System.err.println("Rejected");
00087                         dropTargetDropEvent.rejectDrop();
00088                     }
00089     } catch (IOException io) {
00090         io.printStackTrace();
00091         dropTargetDropEvent.rejectDrop();
00092     } catch (UnsupportedFlavorException ufe) {
00093         ufe.printStackTrace();
00094         dropTargetDropEvent.rejectDrop();
00095     }
00096 }
00097 */
00098   public void dropActionChanged (DropTargetDragEvent dropTargetDragEvent) {
00099       System.out.println("dropActionChanged");
00100   }  
00101 /**
00102  * Insert the method's description here.
00103  * Creation date: (00-11-21 11:45:59)
00104  * @param cv edu.ksu.cis.bandera.pdgslicer.dependency.CriterionViewer
00105  */
00106 void setCriterionViewer(CriterionViewer cv) {
00107     criterionViewer = cv;
00108 }
00109 }

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