Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Add TreeItems dynamically - How?
Add TreeItems dynamically - How? [message #457609] Wed, 29 June 2005 13:02 Go to next message
Flik is currently offline FlikFriend
Messages: 51
Registered: July 2009
Member
Hello there,

I've got a big (?) problem with the Tree widget in SWT.
The task is as follows:

I have a list which is nearly a tree-structure - the items are intended
by spaces.

example:

rootnode
first_child
aaaaaa
bbbbbb
cccccc
second_child
ddddddddd
eeeeeeeee
......

What I have to do is filling a tree widget with this list. I see quite a
lot example describing how to use tree/ Treeviewer but the always knew
the exact amount of nodes and "hard-code" the names within the code.

But I don't know how many items there are and so i cannot do things like:
TreeItem first_child = new TreeItem ............

So my question is: How can I fill a tree during runtime with content??
One addition: There are several methods which creates the list seen
above - so i cannot fill the tree in one method.... i have to add a node
when it is generated by the method. e.g:

method_one will generate only root_nodes -> add root to tree

method_two will generate childs -> add [number_child] to tree

method_three will generate abc's -> add abc to tree

I hope you can get an impression of my problem...

thx

flik
Re: Add TreeItems dynamically - How? [message #457839 is a reply to message #457609] Tue, 05 July 2005 19:26 Go to previous message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
This snippet might help you. It dynamically adds tree items when an item is
expanded.

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet8.java?rev=HEAD&am p;content-type=text/vnd.viewcvs-markup

"Flik" <flik04@gmx.de> wrote in message
news:d9u656$cuq$1@news.eclipse.org...
> Hello there,
>
> I've got a big (?) problem with the Tree widget in SWT.
> The task is as follows:
>
> I have a list which is nearly a tree-structure - the items are intended
> by spaces.
>
> example:
>
> rootnode
> first_child
> aaaaaa
> bbbbbb
> cccccc
> second_child
> ddddddddd
> eeeeeeeee
> .....
>
> What I have to do is filling a tree widget with this list. I see quite a
> lot example describing how to use tree/ Treeviewer but the always knew
> the exact amount of nodes and "hard-code" the names within the code.
>
> But I don't know how many items there are and so i cannot do things like:
> TreeItem first_child = new TreeItem ............
>
> So my question is: How can I fill a tree during runtime with content??
> One addition: There are several methods which creates the list seen
> above - so i cannot fill the tree in one method.... i have to add a node
> when it is generated by the method. e.g:
>
> method_one will generate only root_nodes -> add root to tree
>
> method_two will generate childs -> add [number_child] to tree
>
> method_three will generate abc's -> add abc to tree
>
> I hope you can get an impression of my problem...
>
> thx
>
> flik
Previous Topic:SWT Scrollbar drag properties
Next Topic:size of the closing-button
Goto Forum:
  


Current Time: Fri Apr 26 16:08:52 GMT 2024

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

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

Back to the top