Clover coverage report - clover
Coverage timestamp: Sat Oct 8 2005 22:54:17 EDT
file stats: LOC: 91   Methods: 11
NCLOC: 81   Classes: 2
 
 Source file Conditionals Statements Methods TOTAL
DragLabel.java 75% 83.3% 72.7% 80%
coverage coverage
 1   
 package abbot.tester;
 2   
 
 3   
 import java.awt.*;
 4   
 import java.awt.datatransfer.*;
 5   
 import java.awt.dnd.*;
 6   
 import javax.swing.*;
 7   
 
 8   
 import abbot.Log;
 9   
 
 10   
 public class DragLabel extends DropLabel {
 11   
     private class DragData implements Transferable {
 12  7
         public DataFlavor[] getTransferDataFlavors() {
 13  7
             return new DataFlavor[] {
 14   
                 DataFlavor.stringFlavor
 15   
             };
 16   
         }
 17  0
         public boolean isDataFlavorSupported(DataFlavor flavor) {
 18  0
             return true;
 19   
         }
 20  0
         public Object getTransferData(DataFlavor flavor) {
 21  0
             return getName();
 22   
         }
 23   
     }
 24   
 
 25   
     /** Drag gesture was recognized. */
 26   
     public volatile boolean dragStarted = false;
 27   
     /** Drag has left the building, er, Component. */
 28   
     public volatile boolean dragExited = false;
 29   
     /** Source registered a successful drop. */
 30   
     public volatile boolean dropSuccessful = false;
 31   
     /** Source got an indication the drag ended. */
 32   
     public volatile boolean dragEnded = false;
 33   
     public Exception exception = null;
 34   
     private DragGestureListener dgl = null;
 35   
     private DragSourceListener dsl = null;
 36   
     private DragSource dragSource = null;
 37   
     private int acceptedActions = DnDConstants.ACTION_COPY_OR_MOVE;
 38  4
     public DragLabel(String name) { this(name, true); }
 39  7
     public DragLabel(String name, final boolean acceptDrops) { 
 40  7
         super(name, acceptDrops);
 41  7
         setName("DragLabel (" + name + ")");
 42  7
         dragSource = DragSource.getDefaultDragSource();
 43  7
         dgl = new DragGestureListener() {
 44  7
                 public void dragGestureRecognized(DragGestureEvent e) {
 45  7
                     Log.debug("Recognizing gesture");
 46  7
                     if ((e.getDragAction() & acceptedActions) == 0)
 47  0
                         return;
 48  7
                     Log.debug("Drag started (listener)");
 49  7
                     dragStarted = true;
 50  7
                     try {
 51  7
                         e.startDrag(acceptDrops
 52   
                                     ? DragSource.DefaultCopyDrop
 53   
                                     : DragSource.DefaultCopyNoDrop,
 54   
                                     new DragData(), dsl);
 55  7
                         setForeground(Color.red);
 56  7
                         paintImmediately(getBounds());
 57   
                     }
 58   
                     catch(InvalidDnDOperationException idoe) {
 59  0
                         exception = idoe;
 60   
                     }
 61   
                 }
 62   
             };
 63  7
         dsl = new DragSourceListener() {
 64  7
                 public void dragDropEnd(DragSourceDropEvent e) {
 65  7
                     Log.debug("Drag ended (success="
 66   
                               + e.getDropSuccess() + ")");
 67  7
                     dropSuccessful = e.getDropSuccess();
 68  7
                     dragEnded = true;
 69  7
                     setForeground(Color.black);
 70  7
                     paintImmediately(getBounds());
 71   
                 }
 72  11
                 public void dragEnter(DragSourceDragEvent e) {
 73  11
                     Log.debug("Drag enter (source)");
 74   
                 }
 75  52
                 public void dragOver(DragSourceDragEvent e) {
 76  52
                     Log.debug("Drag over (source)");
 77   
                 }
 78  14
                 public void dragExit(DragSourceEvent e) {
 79  14
                     Log.debug("Drag exit (source)");
 80  14
                     dragExited = true;
 81   
                 }
 82  0
                 public void dropActionChanged(DragSourceDragEvent e) {
 83  0
                     Log.debug("Drop action changed (source)");
 84   
                 }
 85   
             };
 86  7
         dragSource.
 87   
             createDefaultDragGestureRecognizer(this, acceptedActions, dgl);
 88   
     }
 89   
 }
 90   
 
 91