Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » RCP Testing Tool » get-item doesn't find tree node given tree node name
get-item doesn't find tree node given tree node name [message #1737758] Tue, 12 July 2016 14:24 Go to next message
Endi Wu is currently offline Endi WuFriend
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 #1737791 is a reply to message #1737758] Wed, 13 July 2016 04:00 Go to previous messageGo to next message
Rajesh Singh is currently offline Rajesh SinghFriend
Messages: 18
Registered: March 2016
Junior Member
we can use
get-view Home | get-tree | select [get-item "Home" -column "Column Name"| get-item "Book1" -column "Column Name" ]
than it will identify with the name
Re: get-item doesn't find tree node given tree node name [message #1737793 is a reply to message #1737791] Wed, 13 July 2016 05:02 Go to previous messageGo to next message
Aditya Mahakulkar is currently offline Aditya MahakulkarFriend
Messages: 3
Registered: June 2016
Junior Member
No Message Body

[Updated on: Wed, 13 July 2016 05:06]

Report message to a moderator

Re: get-item doesn't find tree node given tree node name [message #1737891 is a reply to message #1737793] Wed, 13 July 2016 19:30 Go to previous messageGo to next message
Endi Wu is currently offline Endi WuFriend
Messages: 3
Registered: July 2016
Junior Member
Thanks a lot for your suggestion. Current Column is empty. We can't use this workaround to add Column into our TreeViewer to resolve issue.

Finally found root cause is our own labelprovider extends from OwnerDrawLabelProvider, when new treeitem is created, it won't update text for this treeitem, see OwnerDrawLabelProvider.update(ViewerCell cell), that's why all item under tree has empty name. We can't change our OwnerDrawLabelProvider implementation.

One thing I can think is:
1. Get all tree items under root
2. Use for loop to get each item
3. call get_object to get java object, then execute getData use invoke, it returns my model object
4. then user invoke to call toString method to get text of this tree item
5. Evaluate whether it is same as passed value
6 if it is same, stop the for loop, then call select to select this object

Do you think whether it is doable? Any better solution you can provide? Thanks.
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 Go to previous message
Endi Wu is currently offline Endi WuFriend
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

Previous Topic:Checking checkbox results to error org.eclipse.rcptt.tesla.core
Next Topic:Problems with Nebula Nattalbe
Goto Forum:
  


Current Time: Wed Apr 24 16:37:29 GMT 2024

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

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

Back to the top