Re: Treeview events

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I find your method quite hard.
It's strange that I need to watch the entire system to be aware of
files modification on a tree.
I won't load the entire tree at beginning too, it's taking too much
time ...

Is there a design pattern for treeview ?

On 27 sep, 23:08, "Peter Duniho" <NpOeStPe...@xxxxxxxxxxxxxxxx> wrote:
On Sat, 27 Sep 2008 13:58:20 -0700, <timor.su...@xxxxxxxxx> wrote:
Thanks for your answer. The "thing" is :
it's a treeview containing the files on the hard drive, so, deploy a
node load the files under the directory
Selecting the node, update the node with possible change on the hard
disk, clicking on the node too ...

When there's many files, the loading or updating (that is the same
task) can be quite long, that's why I would like to avoid loading this
too many times.

Any idea ?

Yes.  Don't do that.  :)

Instead, your nodes should retrieve the data as needed according to  
visibility and changes to the directory.  You can use FileSystemWatcher as  
a way to monitor the latter; it's not perfect (rapid changes can overwhelm  
it, especially if you're not careful to keep your event handlers simple),  
but it'd be automatic rather than relying on user input and would avoid  
the redundancy

If you insist on relying on user input to decide when to refresh, don't  
make it based on selection.  Retrieve the data as needed according to  
visibility, and then provide the user with an explicit option to refresh  
the data (e.g. context menu).

One final option, if you insist on this redundant behavior, is to handle  
the updating in a worker thread and only start it again if you're not  
already processing that node.  Of course, each node would have to keep  
track of whether it's waiting for such a worker thread to finish updating  
it, but that's not hard.

Pete

.



Relevant Pages

  • Re: automatic refreshing of JTree not working
    ... I'm having a hell of a time trying to get a JTree to automatically refresh to show that a node has been moved from one parent node to another. ... I tried the reloadmethod of the tree model and of course when I do that the entire tree collapses and that isn't what I want method useful). ... And *that* issue is due to how JNDI sends search requests to a server. ... I thought if I go back to simplifying my code to make the JTree update itself then I wouldn't even have to go back to my data source, at least for refreshing the node that had one of its children removed. ...
    (comp.lang.java.gui)
  • HList example using Entry, Label, and virtual Checkbuttons (part II)
    ... I always wanted my Tree to have widgets ... (callback function that refresh the gui:) ...
    (comp.lang.perl.tk)
  • Re: treeview refresh
    ... FormName.TreeViewname to refer to the control). ... If you want to learn lots about Treeview controls, ... > best way to refresh the treeview after changes are made? ... > I have one many to many relationship in the tree the keys may change. ...
    (microsoft.public.access.formscoding)
  • Re: Fragile Fences
    ... >as warnings/errors/whatever in the compile tree until you refresh. ... you are treating the flat files as the ... However, in either case, the copy that counts for Eclipse is its ...
    (comp.lang.java.programmer)