View Full Version : Get moved over node for TreePanel DND

11 Oct 2011, 3:54 AM

Is it possible to get in dragEnter or dragMove events the node, over which the drugged one has been moved?
I have several different models in my tree and I need to avoid dropping between some model types.
The only thing I found is that I can get DOM element of event. Or I can try to cancel drop if the position is wrong, but this is not the best solution I suppose.

Thanks in advace

11 Oct 2011, 12:11 PM
Yeah I have this.... basically I have a tree of collections which have albums and those have countries. So I can only drag a country to another album etc.

This is a simplification on my DNDListener but....

public class BrowseTreeDNDListener extends DNDListener {

public void dragMove(DNDEvent e) {
Element el = e.getTarget();
// I keep track of the last element to skip the calculation if it hasn't moved (for performance)
if (prevEl == null || !prevEl.equals(el)) {
prevEl = el;
prevValid = false;
TreeNode node = treePanel.findNode(el);
if (node != null && node.getModel() instanceof BeanModel) {
// this is just an unwrapper method to get my POJO
AbstractNamedBean target = getNamedBean((BeanModel) node.getModel() );
ArrayList<TreeStoreModel> tsm = e.getData();
if( tsm != null && !tsm.isEmpty()) {
AbstractNamedBean source = getNamedBean( (BeanModel)tsm.get(0).getModel());
if (ModelHelper.isValidMoveTarget(source, target)) {
// set it as a valid drop target
prevValid = true;


11 Oct 2011, 10:33 PM
Thank you, managed to get the "moved over" nodes. Now it's the case of logic only.