FileDocCategorySizeDatePackage
DropTargetContext.javaAPI DocJava SE 5 API12411Fri Aug 26 14:56:48 BST 2005java.awt.dnd

DropTargetContext

public class DropTargetContext extends Object implements Serializable
A DropTargetContext is created whenever the logical cursor associated with a Drag and Drop operation coincides with the visible geometry of a Component associated with a DropTarget. The DropTargetContext provides the mechanism for a potential receiver of a drop operation to both provide the end user with the appropriate drag under feedback, but also to effect the subsequent data transfer if appropriate.
version
1.37, 05/05/04
since
1.2

Fields Summary
private static final long
serialVersionUID
private DropTarget
dropTarget
The DropTarget associated with this DropTargetContext.
private transient DropTargetContextPeer
dropTargetContextPeer
private transient Transferable
transferable
Constructors Summary
DropTargetContext(DropTarget dt)
Construct a DropTargetContext given a specified DropTarget.

param
dt the DropTarget to associate with


                         

      
	super();

	dropTarget = dt;
    
Methods Summary
protected voidacceptDrag(int dragOperation)
accept the Drag.

param
dragOperation the supported action(s)

        DropTargetContextPeer peer = getDropTargetContextPeer();
        if (peer != null) {
            peer.acceptDrag(dragOperation);
        }
    
protected voidacceptDrop(int dropOperation)
called to signal that the drop is acceptable using the specified operation. must be called during DropTargetListener.drop method invocation.

param
dropOperation the supported action(s)

        DropTargetContextPeer peer = getDropTargetContextPeer();
        if (peer != null) {
            peer.acceptDrop(dropOperation);
        }
    
public voidaddNotify(java.awt.dnd.peer.DropTargetContextPeer dtcp)
Called when associated with the DropTargetContextPeer.

param
dtcp the DropTargetContextPeer

	dropTargetContextPeer = dtcp;
    
protected java.awt.datatransfer.TransferablecreateTransferableProxy(java.awt.datatransfer.Transferable t, boolean local)
Creates a TransferableProxy to proxy for the specified Transferable.

param
t the Transferable to be proxied
param
local true if t represents the result of a local drag-n-drop operation.
return
the new TransferableProxy instance.

	return new TransferableProxy(t, local);
    
public voiddropComplete(boolean success)
This method signals that the drop is completed and if it was successful or not.

param
success true for success, false if not

throws
InvalidDnDOperationException if a drop is not outstanding/extant

        DropTargetContextPeer peer = getDropTargetContextPeer();
        if (peer != null) {
	    peer.dropComplete(success);
        }
    
public java.awt.ComponentgetComponent()
This method returns the Component associated with this DropTargetContext.

return
the Component associated with this Context

 return dropTarget.getComponent(); 
protected java.awt.datatransfer.DataFlavor[]getCurrentDataFlavors()
get the available DataFlavors of the Transferable operand of this operation.

return
a DataFlavor[] containing the supported DataFlavors of the Transferable operand.

        DropTargetContextPeer peer = getDropTargetContextPeer();
        return peer != null ? peer.getTransferDataFlavors() : new DataFlavor[0];
    
protected java.util.ListgetCurrentDataFlavorsAsList()
This method returns a the currently available DataFlavors of the Transferable operand as a java.util.List.

return
the currently available DataFlavors as a java.util.List

	return Arrays.asList(getCurrentDataFlavors());
    
public java.awt.dnd.DropTargetgetDropTarget()
This method returns the DropTarget associated with this DropTargetContext.

return
the DropTarget associated with this DropTargetContext

 return dropTarget; 
java.awt.dnd.peer.DropTargetContextPeergetDropTargetContextPeer()
Get the DropTargetContextPeer

return
the platform peer

 
	return dropTargetContextPeer;
    
protected intgetTargetActions()
This method returns an int representing the current actions this DropTarget will accept.

return
the current actions acceptable to this DropTarget

        DropTargetContextPeer peer = getDropTargetContextPeer();
        return ((peer != null)
			? peer.getTargetActions() 
			: dropTarget.getDefaultActions()
	);
    
protected java.awt.datatransfer.TransferablegetTransferable()
get the Transferable (proxy) operand of this operation

throws
InvalidDnDOperationException if a drag is not outstanding/extant

return
the Transferable

        DropTargetContextPeer peer = getDropTargetContextPeer();
        if (peer == null) {
	    throw new InvalidDnDOperationException();
	} else {
            if (transferable == null) {
                Transferable t = peer.getTransferable();
                boolean isLocal = peer.isTransferableJVMLocal();
                synchronized (this) {
                    if (transferable == null) {
                        transferable = createTransferableProxy(t, isLocal);
                    }
                }
	    }

	    return transferable;
	}
    
protected booleanisDataFlavorSupported(java.awt.datatransfer.DataFlavor df)
This method returns a boolean indicating if the given DataFlavor is supported by this DropTargetContext.

param
df the DataFlavor

return
if the DataFlavor specified is supported

	return getCurrentDataFlavorsAsList().contains(df);
    
protected voidrejectDrag()
reject the Drag.

        DropTargetContextPeer peer = getDropTargetContextPeer();
        if (peer != null) {
            peer.rejectDrag();
        }
    
protected voidrejectDrop()
called to signal that the drop is unacceptable. must be called during DropTargetListener.drop method invocation.

        DropTargetContextPeer peer = getDropTargetContextPeer();
        if (peer != null) {
            peer.rejectDrop();
        }
    
public voidremoveNotify()
Called when disassociated with the DropTargetContextPeer.

	dropTargetContextPeer = null;
	transferable          = null;
    
protected voidsetTargetActions(int actions)
This method sets the current actions acceptable to this DropTarget.

param
actions an int representing the supported action(s)

        DropTargetContextPeer peer = getDropTargetContextPeer();
        if (peer != null) {
            synchronized (peer) {
                peer.setTargetActions(actions);
                getDropTarget().doSetDefaultActions(actions);
            }
        } else {
            getDropTarget().doSetDefaultActions(actions);
        }