TreeItem.setExpanded() not showing the desired effect [message #459319] |
Fri, 05 August 2005 13:17 |
Eclipse User |
|
|
|
Originally posted by: sarek.nurfuerspam.de
Hi all,
I have some trouble with handling tree items ...
Let's say I have a tree with the follwing structure:
a--
| |-- a1
| |-- a2
|
b--
| |-- b1
| |-- b2
|
c--
|-- c1
|-- c2
Here's a scenario: The user works with the tree and collapses node b.
Then he performs some action that causes the tree to be rebuilt by my
application.
Therefore I keep a reference to the old tree and while adding new items
to the new tree, I look, if such an entry already existed in the old
tree and if so, if it was expanded. If that was the case, I want to have
it expanded in the new tree as well.
So, I set newNode.setExpanded(true)
But when the new tree is shown, all node are NOT expanded. What I was
expecting is something like this:
a--
| |-- a1
| |-- a2
|
b (not expanded)
|
c--
| |-- c1
| |-- c2
|
d
Node d is new in the tree and b is not expanded because the user
collapsed it before the tree was refreshed.
At first I thought that my checking for a node to be expanded was
faulty, so I changed the node text to make it more obvious. If I
determine a node in the new tree to be expanded I prepend "EXPANDED" to
that node.
And see what I get:
EXPANDED a
|
b
|
EXPANDED c
|
d
Which is exactly what I was expecting, except that the nodes marked for
being expanded are NOT expanded.
Can anyone give me a hint what might be the cause of that strange behaviour?
TIA
Christian
--
To reply to this posting directly use the following address and
remove the 'NO-SPAM' part: Riedel.Christian.NO-SPAM@gmx.net
|
|
|
|
Re: TreeItem.setExpanded() not showing the desired effect [message #459325 is a reply to message #459322] |
Fri, 05 August 2005 15:53 |
Eclipse User |
|
|
|
Originally posted by: sarek.nurfuerspam.de
Hi,
Max Rotvel wrote:
>> to the new tree, I look, if such an entry already existed in the old
>> tree and if so, if it was expanded. If that was the case, I want to have
>> it expanded in the new tree as well.
>
> You need to store the references to the expanded TreeItems and _after_
> you've finished manipulating your Tree, run through that list and
> 're-expand' them.
Thanks a lot! Works great.
Do I have to do this every time I add or remove a treeItem to the tree
or is this only necessary, when the tree is completely constructed from
scartch?
Anyways, now it work :-)
CU
Christian
--
To reply to this posting directly you have to remove
the 'NO-SPAM' part from the email address.
|
|
|
|
Powered by
FUDForum. Page generated in 0.02900 seconds