Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » How to update a tree in a tree field?
How to update a tree in a tree field? [message #1553047] Thu, 08 January 2015 13:19 Go to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
I have a tree field populated with a LookupCall:
index.php/fa/20397/0/

Here the corresponding code:
@Override
protected void execInitField() throws ProcessingException {
  //Fetch the LookupRows:
  SomeLookupCall call = new SomeLookupCall();
  List<? extends ILookupRow<Long>> lookupRows = call.getDataByAll();

  //Build the Tree:
  ITree tree = getTree();
  tree.removeAllChildNodes(tree.getRootNode());

  P_TreeNodeBuilder builder = new P_TreeNodeBuilder();
  List<ITreeNode> children = builder.createTreeNodes(lookupRows, ITreeNode.STATUS_NON_CHANGED, true);
  tree.addChildNodes(tree.getRootNode(), children);
  tree.selectFirstNode();
  tree.expandAll(tree.getRootNode());
}



My problem is: I am not able to reload the tree in the TreeField. My LookupCall provides different texts and icons each time it is called. When I reload the tree, it should look like this:
index.php/fa/20398/0/

=> In order to understand and debug the tree, I have introduced a first node "counter".

How can I update or reset a tree in a tree field?
  • Attachment: Tree1.png
    (Size: 4.28KB, Downloaded 215 times)
  • Attachment: Tree2.png
    (Size: 5.18KB, Downloaded 246 times)
Re: How to update a tree in a tree field? [message #1553506 is a reply to message #1553047] Thu, 08 January 2015 18:50 Go to previous message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
After some discussion with a colleague, a possibility is to set build a new Tree and to set it:
public void refreshTree() throws ProcessingException {
  //Selection Key:
  Object key = null;
  if (getTree().getSelectedNode() != null) {
    key = getTree().getSelectedNode().getPrimaryKey();
  }

  //Fetch the LookupRows:
  SomeLookupCall call = new SomeLookupCall();
  List<? extends ILookupRow<Long>> lookupRows = call.getDataByAll();

  //Build the Tree:
  ITree tree = new Tree();
  setTree(tree, false);
  tree.removeAllChildNodes(tree.getRootNode());

  P_TreeNodeBuilder builder = new P_TreeNodeBuilder();
  List<ITreeNode> children = builder.createTreeNodes(lookupRows, ITreeNode.STATUS_NON_CHANGED, true);
  tree.addChildNodes(tree.getRootNode(), children);
  tree.selectNode(tree.findNode(key));
  tree.expandAll(tree.getRootNode());
}

Previous Topic:Click OutlineViewButton via Jubula
Next Topic:Multi Column SmartField
Goto Forum:
  


Current Time: Fri Apr 19 21:20:52 GMT 2024

Powered by FUDForum. Page generated in 0.03260 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top