get-item doesn't find tree node given tree node name [message #1737758] |
Tue, 12 July 2016 14:24 |
Endi Wu Messages: 3 Registered: July 2016 |
Junior Member |
|
|
I have treeviewer, hooking own contentprovider and labelprovider, in contentprovider, I implement getChildren, getElement, returns my model object, model object has toString method, the labelprovider implements getText, getImage. When I record select last tree node for my test case, RCPTT gives me:
get-view Home | get-tree | select [get-item "" | get-item "" -index 2]
It uses index to find tree. But I want to use tree node name to find tree node, like the follows:
get-view Home | get-tree | select [get-item "Home" | get-item "Book1" ]
But it failed, it said [Home, Book1] can not be found.
I checked detail message and found there is no name for each tree item in swt.info block
swt.info
{
Tree()
{
Item()
{
Item()
Item()
Item()
}
}
}
I also checked sample rcpmail code, it gave me treenode name during recording the selection;
get-view Mailboxes | get-tree | select "me@this.com"
I would like to know how rcptt get treenode name in swt.info, which API RCPTT check it? Where is the implementation for it. Maybe I need to tweak my code to get it work.
|
|
|
|
|
|
Re: get-item doesn't find tree node given tree node name [message #1737993 is a reply to message #1737891] |
Thu, 14 July 2016 19:03 |
Endi Wu Messages: 3 Registered: July 2016 |
Junior Member |
|
|
My solution works!!!
Here is the script, maybe not expert level script, any comments or simplification of my script are welcome and appreciated:
Requirement: Given tree node name, find tree node one level under root node in the View, name "Home", then select ( applies to treeitem text is empty, like me using OwnerDrawLabelProvider)
**
* the procedure to find first matching node one level under root given node name
*/
proc "find-node-under-root" [val nodeName]
{
let [val root [get-view Home | get-tree | get-item ""] ]
{
let [val count [ $root | get-property childCount -raw]]
{
loop [val index [int 0]]
{
let [val nodename [ $root | get-item "" -index $index | get-object |invoke getData | invoke toString ] ]
{
if [ $nodename |eq $nodeName]
{
$root | get-item "" -index $index
}
-else
{
if [ $index | lt $count ]
{
recur [ $index | plus 1]
}
}
}
}
}
}
}
select-item [ find-node-under-root "Book1" ]
Result: Book1 node under root, "Home", is selected
[Updated on: Thu, 14 July 2016 19:59] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03711 seconds