Page 1 of 1

examples on how to show volumes/folder structure in rTree

Posted: Sat Sep 17, 2011 11:18 pm
by matthiasr
Hi,

are there any examples how to show volumes and folder structure in rTree

Regards,

Matthias

Re: examples on how to show volumes/folder structure in rTree

Posted: Sun Sep 18, 2011 1:38 pm
by wilstrand
Hi Matthias!

Use the sourcePath node property to "link" nodes to resources on a hard drive. You only need to set the sourcePath for the first node in a volume or folder! The rest is taken care of by rTree! Here comes an example on how to get the entire hard disk and other volumes into an rTree control:

Code: Select all

on mouseUp
   # Clear the tree from old data.
   dispatch "delete_nodeData" to control "Tree"
   # Create a node and set name and sourcePath for each volume.
   repeat for each line tVolume in the volumes
      dispatch "new_node" to control "Tree"
      get the lastNodeID of control "Tree"
      set the name_of_node_ID_[it] of control "Tree" to tVolume
      set the sourcePath_of_node_ID_[it] of control "Tree" to tVolume
   end repeat
   dispatch "renderTree" to control "Tree"
end mouseUp
Please let me know how it goes!

With my best regards,

Mats

Re: examples on how to show volumes/folder structure in rTree

Posted: Wed Sep 21, 2011 9:27 am
by matthiasr
Thanks so far. I will try and report.

Matthias

Re: examples on how to show volumes/folder structure in rTree

Posted: Tue Oct 11, 2011 8:09 pm
by hoburne
Hi,

I found your post and example really helpful - can you point me in the right direction to amend this to show only the "My Documents" folder or specific path?

Thanks in advance!

Re: examples on how to show volumes/folder structure in rTree

Posted: Tue Oct 11, 2011 10:34 pm
by wilstrand
Hi hoburne!

To show only the "My Documents" folder you can use the specialFolderPath function. Please see LC dictionary for more info!
You can try the following:

Code: Select all

on mouseUp
   # Clear the tree from old data.
   dispatch "delete_nodeData" to control "Tree"
   # Create a node and set name and sourcePath.
   dispatch "new_node" to control "Tree"
   get the lastNodeID of control "Tree"
   set the name_of_node_ID_[it] of control "Tree" to "My Documents"
   set the sourcePath_of_node_ID_[it] of control "Tree" to specialFolderPath ("documents")
   dispatch "renderTree" to control "Tree"
end mouseUp
To have a node show a specific path on your disks just set the sourcePath property of that node to the path. Like this:

Code: Select all

set the sourcePath_of_node_ID_[tNodeID] of control "Tree" to "C:/Users/MyName/MyFolder"
Hope this is useful for you!

With my best regards

Mats

Re: examples on how to show volumes/folder structure in rTree

Posted: Wed Oct 12, 2011 1:31 pm
by hoburne
Thanks Mats,
That works really well :)

Thanks.

Re: examples on how to show volumes/folder structure in rTree

Posted: Thu Oct 13, 2011 10:06 am
by hoburne
Morning,

Is there a way to pass the full system path of a file when you click on a node?
My rTree is displaying the Word documents (instruction sheets) inside a specified folder - this part works great. When you click a node the 'label' is passed to wordlib for displaying... also works (sort of!)
But I need to be able to have the full system path of the document associated to that node pass and not just the label - any ideas?

See attached image - might help explain better.

Thanks.

Re: examples on how to show volumes/folder structure in rTree

Posted: Thu Oct 13, 2011 10:45 am
by wilstrand
Hi hoburne!

I see you're making good use of rTree! :D

You can get the full system path for a node like this:

Code: Select all

get the sourcePath_of_node_ID_[tNodeID] of control "Tree"
The sourcePath property of a node is set automatically by rTree if the node is showing a file or folder of your file system.

Please also check the sourcePath property in the rTree Workbench dictionary for more info and tips!

Please let me know if this was what you where looking for!

With my best regards

Re: examples on how to show volumes/folder structure in rTree

Posted: Thu Oct 13, 2011 11:16 am
by hoburne
Perfect - thanks. Although I couldn't find any info on sourcePath in the Workbench - got it to work.

Just need to get the top node to expand as it renders then its done.
I assume this looks correct:

Code: Select all

set the expanded_of_node_ID_[1] of control "Tree 1318406276929" to true
Thanks again.

Re: examples on how to show volumes/folder structure in rTree

Posted: Thu Oct 13, 2011 11:22 am
by wilstrand
Good to hear!

Your code is correct. Do not forget to render the tree after setting the expanded property!

Good luck with your project!

Mats

Re: examples on how to show volumes/folder structure in rTree

Posted: Thu Oct 13, 2011 3:56 pm
by hoburne
hi again! Sorry to be a pain, i'm sure doing something wrong!

The tree is working perfectly, except I need to have the top level (node 1 as I understand it) expanded when it loads. So that I can see the Folder structure without any clicks...
Here's the code I am using:

Code: Select all

  dispatch "delete_nodeData" to control "Tree 1318509484973"
   dispatch "new_node" to control "Tree 1318509484973"
   set the treeType of control "Tree 1318509484973" to "filesystem"
   get the lastNodeID of control "Tree 1318509484973"
   set the name_of_node_ID_[it] of control "Tree 1318509484973" to "Group Common Documents"
   set the sourcePath_of_node_ID_[it] of control "Tree 1318509484973" to commonPath
   set the expanded_of_node_ID_[1] of control "Tree 1318509484973" to true
   dispatch "renderTree" to control "Tree 1318509484973"
   
note: commonPath is a link to a mapped network drive.

See the attached image. My tree seems to load with the top level expanded (showing minus sign) but doesnt load the rest of the structure?

Again, sorry if these are basic questions!

Thanks.

Re: examples on how to show volumes/folder structure in rTree

Posted: Fri Oct 14, 2011 12:56 am
by wilstrand
Hi hoburne!

Ahh! I see! I have to admit that this is a scenario that I had not thought of!

However this is of course a thing that you should be able to do with rTree! I have therefor implemented a new command scan_node that will let you do what you are describing! The new command lets you scan a nodes corresponding file structure from for example the hard disk by script. Here is some example code:

Code: Select all

on mouseUp
   # Clear the tree from old data.
   dispatch "delete_nodeData" to control "Tree"
   # Create a node and set name and sourcePath.
   dispatch "new_node" to control "Tree"
   get the lastNodeID of control "Tree"
   set the name_of_node_ID_[it] of control "Tree" to "My Documents"
   set the sourcePath_of_node_ID_[it] of control "Tree" to specialFolderPath ("documents")
   send "scan_node_ID" && it to control "Tree"
   set the expanded_of_node_ID_[it] of control "Tree" to true
   dispatch "renderTree" to control "Tree"
end mouseUp
I have uploaded a new version rTree Workbench 1.5.9 with the new feature and updated documentation. It is free for all 1.5 users. Please download from tapirsoft.com for now as there seems to be some problem in the RunRev store.

With my best regards

Mats

Re: examples on how to show volumes/folder structure in rTree

Posted: Fri Oct 14, 2011 10:24 am
by hoburne
Hi Mats,

That's it, works perfectly now. Also in this version I am able to see the instructions/command definitions on the left of the workbench stack.
Thanks again for all your help and a great tool.

Mike