CellTree - which nodes are open or closed on it?

117 views
Skip to first unread message

Vasi, Sándor

unread,
Feb 14, 2012, 5:46:12 AM2/14/12
to google-we...@googlegroups.com
I have a cellTree with few nodes.
I need to send to the server side which nodes are open on the tree, and which are closed.

I was thinking on two solutions, but i have problem with both.

1. Walk the cellTree and double-check all the nodes if they are open or closed.
My problem with this is that i dont know, how to walk the tree.
I can get it's root element from the CellTree by calling it's tree.getRootTreeNode() method,
but i cant find any way how to get the rootNode's children.
http://google-web-toolkit.googlecode.com/svn/javadoc/2.1/com/google/gwt/user/cellview/client/TreeNode.html
The TreeNode interface does not have a TreeNode getChild(int i) method.

2. Assume, that all children are closed / opened, and catch the close / open node event, and save it's state in a variable.
I do not know if there is any kind of event that can deal with this user activity.

What's your opinion and how to fix this issues?

Regards,
Sandor

Patrice De Saint Steban

unread,
Feb 14, 2012, 9:42:54 AM2/14/12
to google-we...@googlegroups.com
It's not a good solution, but when you open a tree node with setChildOpen(), the method return the Child TreeNode :
public TreeNode setChildOpen(int index, boolean open, boolean fireEvents) {
      assertNotDestroyed();
      checkChildBounds(index);
      CellTreeNodeView<?> child = nodeView.getChildNode(index);
      return child.setOpen(open, fireEvents) ? child.treeNode : null;
}

The setOpen() return True only when the TreeNode is not a leaf and is closed, ans you ask to open the node.

Thomas Broyer

unread,
Feb 14, 2012, 10:56:10 AM2/14/12
to google-we...@googlegroups.com
...which leads to the alternate solution: add an OpenHandler and a CloseHandler to the CellTree.

jabal

unread,
Feb 14, 2012, 8:59:59 AM2/14/12
to Google Web Toolkit
Today I had almost the same issue.. :-)

It seems that browsing the model of the CellTree is almost impossible
from the side of a SelectionModel or a DefaultSelectionEventManager. I
inherited from DefaultSelectionEventManager and tried to override
doMultiSelection(..) but from that method I could not access the tree
data as it is hidden by the HasData<T> interface. When debugging the
instance of this interface is a CellTreeNodeView$NodeCellList but is a
private inner class that cannot be accessed.. :-(

Regards,
JB

On Feb 14, 11:46 am, Vasi, Sándor <sa...@inlineskate.hu> wrote:
> I have a cellTree with few nodes.
> I need to send to the server side which nodes are open on the tree, and
> which are closed.
>
> I was thinking on two solutions, but i have problem with both.
>
> 1. Walk the cellTree and double-check all the nodes if they are open or
> closed.
> My problem with this is that i dont know, how to walk the tree.
> I can get it's root element from the CellTree by calling it's
> tree.getRootTreeNode() method,
> but i cant find any way how to get the rootNode's children.http://google-web-toolkit.googlecode.com/svn/javadoc/2.1/com/google/g...
Reply all
Reply to author
Forward
0 new messages