programmatic
11 Feb 2010, 7:57 AM
I am creating a tree with Drag and drop capabilities however I do not want to allow certain nodes to be dropped. My tree consists of 2 types of nodes:
1)Leaf node
2)Folder node containing 2 nodes, Yes and No. The Yes/No nodes are allowed children
I want to allow dropping for my Yes/No nodes ONLY. I also disabled dragging the Yes/No nodes. Not the Folder node. I do not want siblings for the Yes/No nodes, only children.
Also, why can't I drag and drop to the bottom of the tree if the last node is expanded? I also noticed this to be true in the Explorer Demo. If I expand the last node, I am unable to drop another folder to the bottom unless I collapse that last node then move down.
TreePanelDropTarget target = new TreePanelDropTarget(treePanel)
{
@Override
protected void showFeedback(DNDEvent event)
{
super.showFeedback(event);
TreeNode overItem = tree.findNode(event.getTarget());
if(overItem.getModel().get("type").equals(FOLDERNODE))
{
event.setCancelled(true);
event.getStatus().setStatus(false);
//event.getDropTarget().setFeedback(Feedback.APPEND);
}
}
};
target.setAllowSelfAsSource(true);
target.setFeedback(Feedback.BOTH);
Using this code, I am able to disallow dropping to the folder node, however if this folder node is the last node on the tree, it doesn't allow dropping after the node (whether it's expanded or collapsed)
1)Leaf node
2)Folder node containing 2 nodes, Yes and No. The Yes/No nodes are allowed children
I want to allow dropping for my Yes/No nodes ONLY. I also disabled dragging the Yes/No nodes. Not the Folder node. I do not want siblings for the Yes/No nodes, only children.
Also, why can't I drag and drop to the bottom of the tree if the last node is expanded? I also noticed this to be true in the Explorer Demo. If I expand the last node, I am unable to drop another folder to the bottom unless I collapse that last node then move down.
TreePanelDropTarget target = new TreePanelDropTarget(treePanel)
{
@Override
protected void showFeedback(DNDEvent event)
{
super.showFeedback(event);
TreeNode overItem = tree.findNode(event.getTarget());
if(overItem.getModel().get("type").equals(FOLDERNODE))
{
event.setCancelled(true);
event.getStatus().setStatus(false);
//event.getDropTarget().setFeedback(Feedback.APPEND);
}
}
};
target.setAllowSelfAsSource(true);
target.setFeedback(Feedback.BOTH);
Using this code, I am able to disallow dropping to the folder node, however if this folder node is the last node on the tree, it doesn't allow dropping after the node (whether it's expanded or collapsed)