Hello,
I have created a few childNodes for a parentNode and I want to visit some of them using this (TreeNode.traverse(new ProgramVisitor() { } )).
I have copied the code of Mr Jacob. Here is below:
TreeNode root = apiProvider.getProgramAPI().getProgramModel().getRootTreeNode(this);
// Traverse the program tree, using the ProgramNodeVisitor
root.traverse(new ProgramNodeVisitor() {
// Override "visit" looking for "URCapProgramNode" nodes
// Visit will be called for every URCapProgramNode in sub-tree
@Override
public void visit(URCapProgramNode programNode, int index, int depth) {
// Check if the found program node implements the "MyCustomAPI" interface
if(programNode.canGetAs(MyCustomAPI.class)) {
// If it did, we found the right node
// Now we can use "getAs" since we already tested with "canGetAs"
// After "getAs" we can now call the interface methods
programNode.getAs(MyCustomAPI.class).addPoss(poss, firstPoss);
}
}
});
This gets in every childNode which implements MyCustomAPI. I want to get only in 3rd and 5th childNodes of the same parentNode.
Thanks in Advance,
Mehmet Bilgin