examples on how to show volumes/folder structure in rTree

This is a forum focused on providing support for rTree

Moderators: heatherlaine, robinmiller, kevinmiller, wilstrand

Post Reply
matthiasr
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 70
Joined: Sat Apr 08, 2006 7:55 am
Location: Lübbecke, Germany
Contact:

examples on how to show volumes/folder structure in rTree

Post by matthiasr » Sat Sep 17, 2011 11:18 pm

Hi,

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

Regards,

Matthias

wilstrand
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 114
Joined: Mon Jan 03, 2011 3:02 pm
Contact:

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

Post by wilstrand » Sun Sep 18, 2011 1:38 pm

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
http:www.tapirsoft.on-rev.com
Open Source LiveCode Plugins - rIDE, rGrid, rTree
LiveCode projects

matthiasr
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 70
Joined: Sat Apr 08, 2006 7:55 am
Location: Lübbecke, Germany
Contact:

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

Post by matthiasr » Wed Sep 21, 2011 9:27 am

Thanks so far. I will try and report.

Matthias

hoburne
Posts: 40
Joined: Tue Oct 04, 2011 11:13 am

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

Post by hoburne » Tue Oct 11, 2011 8:09 pm

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!

wilstrand
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 114
Joined: Mon Jan 03, 2011 3:02 pm
Contact:

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

Post by wilstrand » Tue Oct 11, 2011 10:34 pm

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
http:www.tapirsoft.on-rev.com
Open Source LiveCode Plugins - rIDE, rGrid, rTree
LiveCode projects

hoburne
Posts: 40
Joined: Tue Oct 04, 2011 11:13 am

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

Post by hoburne » Wed Oct 12, 2011 1:31 pm

Thanks Mats,
That works really well :)

Thanks.

hoburne
Posts: 40
Joined: Tue Oct 04, 2011 11:13 am

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

Post by hoburne » Thu Oct 13, 2011 10:06 am

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.
Attachments
Capture.PNG
rTree view
Capture.PNG (5.43 KiB) Viewed 7027 times

wilstrand
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 114
Joined: Mon Jan 03, 2011 3:02 pm
Contact:

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

Post by wilstrand » Thu Oct 13, 2011 10:45 am

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
http:www.tapirsoft.on-rev.com
Open Source LiveCode Plugins - rIDE, rGrid, rTree
LiveCode projects

hoburne
Posts: 40
Joined: Tue Oct 04, 2011 11:13 am

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

Post by hoburne » Thu Oct 13, 2011 11:16 am

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.

wilstrand
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 114
Joined: Mon Jan 03, 2011 3:02 pm
Contact:

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

Post by wilstrand » Thu Oct 13, 2011 11:22 am

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
http:www.tapirsoft.on-rev.com
Open Source LiveCode Plugins - rIDE, rGrid, rTree
LiveCode projects

hoburne
Posts: 40
Joined: Tue Oct 04, 2011 11:13 am

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

Post by hoburne » Thu Oct 13, 2011 3:56 pm

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.
Attachments
Capture2.PNG
Capture2.PNG (7.75 KiB) Viewed 7010 times

wilstrand
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 114
Joined: Mon Jan 03, 2011 3:02 pm
Contact:

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

Post by wilstrand » Fri Oct 14, 2011 12:56 am

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
http:www.tapirsoft.on-rev.com
Open Source LiveCode Plugins - rIDE, rGrid, rTree
LiveCode projects

hoburne
Posts: 40
Joined: Tue Oct 04, 2011 11:13 am

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

Post by hoburne » Fri Oct 14, 2011 10:24 am

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

Post Reply

Return to “rTree”