Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » TreeItem.setExpanded() not showing the desired effect
TreeItem.setExpanded() not showing the desired effect [message #459319] Fri, 05 August 2005 13:17 Go to next message
Eclipse UserFriend
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 #459322 is a reply to message #459319] Fri, 05 August 2005 14:40 Go to previous messageGo to next message
Max Rotvel is currently offline Max RotvelFriend
Messages: 21
Registered: July 2009
Junior Member
On Fri, 05 Aug 2005 15:17:27 +0200, Christian Riedel
<sarek@nurfuerspam.de> wrote:

> 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

I think the 'while' is the problem...

> 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.

--
Max - rotvel AT bolignet-aarhus DOT dk
Re: TreeItem.setExpanded() not showing the desired effect [message #459325 is a reply to message #459322] Fri, 05 August 2005 15:53 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: TreeItem.setExpanded() not showing the desired effect [message #459340 is a reply to message #459325] Sat, 06 August 2005 08:53 Go to previous message
Max Rotvel is currently offline Max RotvelFriend
Messages: 21
Registered: July 2009
Junior Member
On Fri, 05 Aug 2005 17:53:10 +0200, Christian Riedel
<sarek@nurfuerspam.de> wrote:

>> 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?

You have to use this strategy when you add TreeItems to the Tree.
--
Max - rotvel AT bolignet-aarhus DOT dk
Previous Topic:Initial selection problem on TableViewer
Next Topic:ScrolledComposite WizardPage Problem
Goto Forum:
  


Current Time: Thu Apr 25 23:16:48 GMT 2024

Powered by FUDForum. Page generated in 0.02900 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top