PDA

View Full Version : [CLOSED] Tree: cannot add leaf as a child of leaf node via drag drop: node disappers



pete_by
29 Nov 2011, 12:13 PM
Though it is possible to drag-and-drop leaf node of a tree to another non-leaf node, drag-and-dropping leaf node to another leaf node makes the dragged one disappear after dropping it. The problem is that initially all the leaf nodes have TreeNode#isChildrenRendered property turned off (false). When the leaf is dropped to another leaf node this property does not changes. Thus the implementation of Tree.onAdd works incorrectly:


protected void onAdd(StoreAddEvent<M> event) {
...
if (isOrWasAttached()) {
// event.getItems().get(0) is a dropped leaf-node
// parent is a target leaf-node
M parent = store.getParent(event.getItems().get(0));
TreeNode<M> pn = findNode(parent);
if (parent == null || (pn != null && pn.isChildrenRendered())) {
// we'll never get here because pn.isChildrenRendered() == false
...
// rendering the children nodes
}
...
}
...

Colin Alworth
30 Nov 2011, 7:24 PM
Thanks for the report - we're looking into it.

pete_by
1 Dec 2011, 10:44 AM
Thanks for the report - we're looking into it.

I'm not quite sure that the isChildrenRendered property is the only reason for this issue, as far as I tried to change it in debugger to true, but that did not produce any effect so far. The internal logic of the widget is a bit sophisticated to me from the first view, but I expect to have time to get into soon.

pete_by
2 Dec 2011, 7:10 AM
Looks like the problem in store and my data model syncronisation during nodes moving. In Tree.onAdd method:

int parentChildCount = parent == null ? store.getRootCount() : store.getChildCount(parent);

parentChildCount= 1 after dropping one leaf node on another but parent.getChildren() is still empty but should be instead contain node that passed in event.getItems(). Looks I have to look close to the TreeStore and how it use properly.

pete_by
2 Dec 2011, 8:48 AM
Looks like the bug submission is irrelevant, my error was not keeping my own tree model in sync with TreeStore model.

Colin Alworth
5 Dec 2011, 8:53 AM
Thanks for the update, and for all of the other testing you've done. Let us know if another bug shows itself - we'll hopefully get those other tree bugs closed out this week.