Hi Victor,
assuming that you have a node "Mother" with a recursion node "Children" with the repeated node set to Mother, you can do for example:
if (! wdContext.nodeMother().isEmpty()) { int size = wdContext.nodeMother().size(); /* Level 0 */ for (int i = 0; i < size; i++) { IMotherElement el0 = wdContext.nodeMother().getMotherElementAt(i); if (! el0.nodeChildren().isEmpty()) { /* Level 1 */ IMotherNode node1 = el0.nodeChildren(); for (int j = 0; j < node1.size(); j++) { IMotherElement el1 = node1.getMotherElementAt(j); if (! el1.nodeChildren().isEmpty()) { /* Level 2 */ IMotherNode node2 = el1.nodeChildren(); /* More levels... */ } } } } }
Hope that helps.
Regards
Stefan
Hello Victor,
to get the selected note I did the following:
ITreeElement currentElement, dummy;
currentElement = dummy = wdContext.currentTreeElement();
do{
currentElement = dummy;
dummy = currentElement.currentTeeChildrenElement();
} while(dummy != null);
String text = currentElement.getText();
Regards,
Oliver
Message was edited by: Oliver Grande
Message was edited by: Oliver Grande
Hi all, and first of all thank you for your answers.
The depth of the tree I am working with is undefined so I needed a generic way to do a things.
My question is actually not how to implement recursive (or not) search on the tree but Is this true that there is no any search method for the tree structure? Does SAP plan to implement this in the future like Java Swing Tree control?
Best regards,
Victor.
Hi, In general you are right but there is one thing I want to point out.
I hope WD environment would be developed in Java spirit, and the way I used to work with collection in Java (or any other modern languages like C#) would be preserved. This is true not only about trees but other collections, like tables, as well.
In general, I fill uncomfortable each time I need to work with collection in WD, I really need the power I had in pure Java framework before.
It <b>is possible</b> to implement generic search functionality for tree, the order is not actually the problem, you can provide custom comparator class which would define the order or conversely define search algorithm like BFS or DFS which defines their own order.
I hope it would be some feedback from Karin and Co on this issue.
Best regards.
Victor.
Add a comment