Does setKeys() only update leaf nodes?

View: New views
1 Messages — Rating Filter:   Alert me  

Does setKeys() only update leaf nodes?

by erisch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi folks,

I've built an explorer view to visualize some data structures in my app.
At the moment I have three levels of nodes which can contain child nodes
and one layer with plain leaf nodes. For testing purposes I have simply
created some of my nodes as BeanNodes to be able to use the standard
properties dialog to change some properties of the nodes. To get notfied
about updates of bean properties each node or node container attaches
itself as a PropertyChangeListener to the corresponding object(s) of the
data structures.

The problem is now when I change some properties of some nodes, for
example a simple "name" property which is also used by the nodes for the
display name! I've debugged this and I can assure you the listeners work
correctly, the data attached to each node are up-to-date etc. To update
the nodes accordingly to PropertyChangeEvents I use setKeys() at the
moment in the Children containers. Unfortunately this seems to update
only the leaf nodes. For them everything works fine. Even the leaf nodes
which are reused in multiple branches of the node hierarchy get updated
simultaneously only by calling setKeys() in the corresponding Children
container. Every node changes its display name accordingly to the
underlying data object they represent.

For other nodes which are also BeanNodes and are implemented almost
exactly like the said leaf nodes this doesn't work. Events are fired,
setKeys() is called with the updated collection data but the visual
appearance of the child nodes gets not refreshed automatically. In fact
createNodes() isn't even called. When I open the properties dialog for
these beans I see the updated values. But the child nodes are not
re-created and therefore display the old names. I have to call
refreshKey() manually for all children or the updated child node to
update its view.

Now my question is: Why do the Children container behave differenty? Is
this behavior intended? If so is it the best solution to call
refreshKey()? And why do they work differently? Is it the difference
between leaf nodes and nodes somewhere in the middle of the hierarchy?
Or is it simply not appropriate to update nodes just to have them change
their display name? Anyway it's not clear (for me) why some nodes are
re-created when I call setKeys() and some are not.

Thanks in advance for clarification!

Marco
LightInTheBox - Buy quality products at wholesale price