gwtproject / gwt

GWT Open Source Project
http://www.gwtproject.org
1.52k stars 374 forks source link

CellTreeNodeView.setOpen(false, ...) destroys child nodes, or walking CellTree problematic #5291

Closed dankurka closed 9 years ago

dankurka commented 9 years ago

Originally reported on Google Code with ID 5292

Found in GWT Release (e.g. 1.5.3, 1.6 RC):
GWT 2.1.0-8798 (appears to be the same in current trunk, 8824)

Encountered on OS / Browser (e.g. WinXP, IE6-7, FF3):
Fedora 12, Firefox 3.5.12

Detailed description (please be as specific as possible):

Walking a CellTree appears to only be possible by calling
TreeNode#setChildOpen(inx, open, fireEvents). At the end you then have a completely
expanded tree. However, if you want to close some of those nodes by calling TreeNode#setChildOpen(inx,
false, fireEvents), it will "destroy" all child nodes of those closed.

A function that walks a tree:

private TreeNode findParentOfLink(TreeNode parent, String token) {
        TreeNode node = null;
        int childCount = parent.getChildCount();

        for (int i = 0; i < childCount; i++) {
            NavigationLink link = (NavigationLink) parent.getChildValue(i);
            if (token.equals(link.getHistoryToken())) {
                return parent;
            }

            if (!parent.isChildLeaf(i)) {
                // get child node
                TreeNode child = parent.setChildOpen(i, true);

                node = findParentOfLink(child, token);

                if (node != null) {
                    return node;
                }
            }
        }

        return null;
    }

After using this, calling methods like TreeNode#getParent() throw an IllegalState exception
if the node in question is a destroyed child.

Workaround if you have one:

none, yet

Links to relevant GWT Developer Forum posts:

Reported by jesse.hutton on 2010-09-20 21:27:18

dankurka commented 9 years ago

Reported by dankurka@google.com on 2013-05-27 23:33:46