title: Open GWT cell tree to specific node
body: <p>I have a file browser type application consisting of a CellTree displaying the hierarchy and a browser pane showing the contents of the current node.</p>
  
  <p>The application has to handle hierarchies which may be too large for the CellTree to handle effectively, so the location shown in the browser pane is not strongly coupled to the open nodes in the tree.</p>
  
  <p>I wish to implement a button which will open the current browse location in the CellTree. My server side data model has parent/child references on all objects so obtaining the hierarchy is a simple matter, but I am struggling with how to apply this to the tree.</p>
  
  <p>This is my current attempt, it is a method on the widget which contains my tree, and is called from the reciever. The RecordTreeLevel objects each represent a level in the tree.</p>
  
  <pre><code>public void navigateTo(List&lt;RecordTreeLevelProxy&gt; hierarchy) {
      TreeNode currentNode = tree.getRootTreeNode();
  
      ListIterator iter = hierarchy.listIterator(hierarchy.size());
  
      while (iter.hasPrevious()){
          RecordTreeLevelProxy level = (RecordTreeLevelProxy) iter.previous();
          Integer nodeIndex = locateNode(level.getUniqueRef(), currentNode);
          if (nodeIndex != null){
              currentNode = currentNode.setChildOpen(nodeIndex, true, true);
          }
      }
  }
  </code></pre>
  
  <p>This doesn't work, because the loop completes in its entirity before the children are added to any of the nodes. Therefore the first level node opens as it should, but doesn't have any children when the loop comes around the second time.</p>
  
  <p>I can't help but feel that I'm missing something obvious, or doing this in the wrong way, but I can't see it. Any help much apprieciated (even if it's to say "don't be silly, you can't do it that way)</p>