added support for dragover effects,

fixed NPE


git-svn-id: https://samskivert.googlecode.com/svn/trunk@817 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
ray
2002-08-20 22:38:42 +00:00
parent 756d6d9702
commit d8571fb1dd
2 changed files with 18 additions and 4 deletions
@@ -1,5 +1,5 @@
//
// $Id: DnDManager.java,v 1.2 2002/08/20 21:05:10 ray Exp $
// $Id: DnDManager.java,v 1.3 2002/08/20 22:38:42 ray Exp $
package com.samskivert.swing.dnd;
@@ -104,7 +104,7 @@ public class DnDManager
_source = (DragSource) _draggers.get(_sourceComp);
// make sure the source wants to start a drag.
if (!_source.startDrag(_cursors, _data)) {
if ((_source == null) || (!_source.startDrag(_cursors, _data))) {
// if not, reset our start conditions and bail
reset();
return;
@@ -166,10 +166,13 @@ public class DnDManager
*/
protected void mouseExited (MouseEvent event)
{
_lastTarget = null;
if (_lastComp != null) {
_lastComp.setCursor(_oldCursor);
}
if (_lastTarget != null) {
_lastTarget.noDrop();
_lastTarget = null;
}
}
/**
@@ -1,5 +1,5 @@
//
// $Id: DropTarget.java,v 1.1 2002/08/20 02:49:19 ray Exp $
// $Id: DropTarget.java,v 1.2 2002/08/20 22:38:42 ray Exp $
package com.samskivert.swing.dnd;
@@ -11,9 +11,20 @@ public interface DropTarget
{
/**
* Return true if the specified drop should be allowed on this target.
* Also indicates that a hover has started in case the drop target would
* like to create dragover feedback aside from the cursor feedback.
*
* If this method returns true then either dropCompleted or hoverEnd
* will be called next.
*/
public boolean checkDrop (DragSource source, Object peekdata);
/**
* Called to let the DropTarget know that we've stopped hovering over
* but did not actually drop.
*/
public void noDrop ();
/**
* Called when the drop is actually executed.
*/