update an rtree dynamically

This is a forum focused on providing support for rTree

Moderators: heatherlaine, kevinmiller, robinmiller, wilstrand

Post Reply
strayeye
Posts: 5
Joined: Thu Apr 07, 2011 2:28 pm

update an rtree dynamically

Post by strayeye » Tue Oct 11, 2011 12:49 pm

Hi.

Firstly I am new to this so am sorry if im asking a question with a simple answer.

I have built my rtree within my project from a file system. Is there a way to dynamically update my tree ? i.e if I add another file into one of the folders can I get rtree to display the file without having to rebuild the tree ? I would assume you can write some code to do this on preopenstack ???

Any help would be appreciated

Thanks
Jimmy

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

Re: update an rtree dynamically

Post by wilstrand » Wed Oct 12, 2011 11:10 am

Hi Jimmy!

No need to excuse yourself! Your question is highly valid!

Besides rebuilding the tree, there is no easy way to dynamically update (synchronize) rTree with changes in a file system. Problem is that you have to keep track of if a file or folder has been added or deleted and compare that with the rTree node data. This requires some way to have a unique identifier for every file/folder in your file system with the same identifier as a property of the corresponding node in your tree. One way forward here could be to use the creation time stamp of the files/folders in your file system as unique identifiers. From the time stamps you could then also check if a file/folder is newer than the latest node in your rTree. Depending on what synchronizing functionality you want, this becomes rather complicated though.

In most cases it is much easier and more reliable to rebuild the whole tree when changes to the file system has been made or as you suggests, when opening the app in an preOpenStack handler.

With my best regards

Mats
http:www.tapirsoft.on-rev.com
Open Source LiveCode Plugins - rIDE, rGrid, rTree
LiveCode projects

strayeye
Posts: 5
Joined: Thu Apr 07, 2011 2:28 pm

Re: update an rtree dynamically

Post by strayeye » Tue Oct 18, 2011 9:04 am

Hi Mats.

Many thanks for your reply. I ended up rebuilding the whole tree. Just put the code on the preOpen Stack script so when I open the app it checks what is there and then renders the tree. I also added a refresh button to my app to re-render the tree on the push of a button.

Thanks again

Jimmy

Post Reply

Return to “rTree”