United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-4378091 Please add DropTargetDragEvent.getTransferable() method
JDK-4378091 : Please add DropTargetDragEvent.getTransferable() method

Details
Type:
Enhancement
Submit Date:
2000-10-10
Status:
Resolved
Updated Date:
2008-11-05
Project Name:
JDK
Resolved Date:
2003-08-08
Component:
client-libs
OS:
windows_nt,windows_xp
Sub-Component:
java.awt
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.3.0,1.4.1,1.4.2
Fixed Versions:
5.0 (tiger)

Related Reports
Duplicate:
Duplicate:
Duplicate:
Relates:
Relates:

Sub Tasks

Description

Name: rmT116609			Date: 10/10/2000


java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

I've written a JTree that supports drag&drop. I implemented the
DropTargetListener.dragOver(DropTargetDragEvent) that it selects the current
node that the dragging node moves over. Now, I want to check if this
current/selected node is a valid drop target (node). For this reason, I need to
get the current transferable to check wether source and target nodes
are "compatible". For this reason I did a DropTargetDragEvent.getTransferable()
(just like DropTargetDropEvent.getTransferable()) but this method is not
available in DropTargetDragEvent! Playing with different DataFlavors is not
enough, there are objects of the same flavour but with different properties.
And the dropping sequence is dependend on this properties, so I need to have
the transferable to check for additional values.

Can we expect to have DropTargetDragEvent.getTransferable() in the next SDK or
is there another solution for this problem?

when I implemented the DropTargetListener, I came to dragOver(). In this
method I want to check if the dragged node is allowed to be dropped on the
current "under" node. SO, just like I did in with a DropTargetDropEvent, I
called "getTransferable()" to inspect the nodes and do further checking. But
the compiler said that getTransferable() is not availabe in
DropTargetDragEvent!

But I need this to check whether the node is "compatible" with the to be
dropped on node. (Application logic: only specific nodes (with specific
properties) are allowed to be dropped - even of the same falvour!).

Here's the code with the not working (but needed) part in comments:

--------------------------------------
    /**
     * Implements DropTargetListener.
     * Called when a drag operation is ongoing on the DropTarget.
     */
    public void dragOver(DropTargetDragEvent event) {
//System.out.println("DropTargetListener.dragOver() ...");
        Point mouseLoc = event.getLocation();
        TreePath path = this.getPathForLocation(mouseLoc.x, mouseLoc.y);
        if (path != null) {
            VegasNode selectedTarget = (VegasNode)
path.getLastPathComponent();
            selectNode(selectedTarget);

//unfortunately, the following method does not exist: !!!
//            Transferable tr = event.getTransferable();
//            if (tr.isDataFlavorSupported(VegasNode.NODE_FLAVOR)) { //is
this a VegasNode?
//                VegasNode dragNode = (VegasNode)
tr.getTransferData(VegasNode.NODE_FLAVOR);
//                Utils.debug("check here for valid drop sequence:
dragNode="+dragNode+", dropNode="+selectedTarget);
//                //todo: check type of both VegasNodes if they are
compatibe ...
//            }
        }
    }//dragOver()
(Review ID: 107743) 
======================================================================

                                    

Comments
EVALUATION

Will consider for tiger.
david.mendenhall@east 2001-03-19


Name: dsR10078			Date: 12/03/2003


A new method java.awt.dnd.DropTargetDragEvent.getTransferable() added
in 1.5:

  /**
   * This method returns the Transferable object that represents
   * the data associated with the current drag operation.
   * 
   * @return the Transferable associated with the drag operation
   * @throws InvalidDnDOperationException if the data associated with the drag
   *         operation is not available
   *
   * @since 1.5
   */
  public Transferable getTransferable();

###@###.### 2003-12-03

======================================================================
                                     
2003-12-03
WORK AROUND



Name: rmT116609			Date: 10/10/2000


Save the transferable node/object in a global field so that it is accessible in
all other drag&drop interface methods. :-(
======================================================================
                                     
2004-06-11
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
tiger

FIXED IN:
tiger

INTEGRATED IN:
tiger
tiger-b15


                                     
2004-06-14



Hardware and Software, Engineered to Work Together