|
Quick Lists
|
|
Bug ID:
|
4378091
|
|
Votes
|
11
|
|
Synopsis
|
Please add DropTargetDragEvent.getTransferable() method
|
|
Category
|
java:drag&drop
|
|
Reported Against
|
1.3
, 1.4.1
, 1.4.2
|
|
Release Fixed
|
1.5(tiger)
|
|
State
|
10-Fix Delivered,
request for enhancement
|
|
Priority:
|
4-Low
|
|
Related Bugs
|
4248542
,
4357494
,
4908752
,
4938575
,
4942851
,
5018712
|
|
Submit Date
|
10-OCT-2000
|
|
Description
|
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)
======================================================================
|
|
Work Around
|
Save the transferable node/object in a global field so that it is accessible in
all xxxxx drag&drop interface methods. :-(
======================================================================
|
|
Evaluation
|
Will consider for tiger.
xxxxx@xxxxx 2001-03-19
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();
xxxxx@xxxxx 2003-12-03
======================================================================
|
|
Comments
|
Submitted On 22-AUG-2001
mfarrelly
Try this work around: the transferable object is contained
in the DropTargetContext. There is a method to access
DropTargetContext but unfortunately its getTransferable()
method is protected however the good news it that
DropTargetDopEvent happens to also use a DropTargetContext
and it does have a getTransferable() so just create a
temporary DropTargetDopEvent using the DropTargetContext to
access the transferable. eg:
DropTargetDragEvent dragEvent = ...; // from where ever
DropTargetDropEvent tempDTDropEvent = new
DropTargetDropEvent(dragEvent.getDropTargetContext(),
dragEvent.getLocation(), 0, 0);
Transferable dragData = tempDTDropEvent.getTransferable();
Not pretty but at least this way you don't have to create
any messy globals.
Submitted On 08-AUG-2002
jrduncans
HEY! This is a replicate of Bug Id 4248542
http://developer.java.sun.com/developer/bugParade/bugs/424
8542.html
Please transfer the votes and evaluation to Bug 4248542
Submitted On 26-OCT-2002
Mig-O
The workaround does not work in jdk1.4.
It fail with a
java.awt.dnd.InvalidDnDOperationException: No drop
current
Time for me to vote on this bug. It seems I am by far not the
only one having this problem.
Submitted On 25-MAR-2003
jlweb58
This workaround seems to work for me with the Sun VM
1.4.1_01 on Suse Linux 8.0. I haven't tested it very
extensively, though.
The requests seem reasonable-- why isn't anything being done?
Submitted On 01-DEC-2003
mflis
How was this "closed,fixed"?
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |