[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.platform.swt] Re: Invisible root TreeItem?

The doubled functions were just a quick thing, because I also create new 
items in them.  I could just split them up.

What happened was I had everything working nicely but all my items have been 
created under a folder I created under the tree called MyFolder.  Then when 
I put in pop up menus to let users create new items and folders, I realized 
that they should be able to create them at the same level as MyFolder, which 
means calls to createTreeItem( tree, style).  It really just comes down to 
an if-then block to check if the creation is at the top level, but I need 
them in a few places since my data is dynamic and there are things needed to 
be applied to items created.  On top of that, I have drag-n-drop so the user 
can move items anywhere freely.  And they can move an entire folder also. 
So to handle a drop, I also have to check if the item's been dropped to the 
top level.  This is no biggy really, but I just thought, "well, if Tree had 
a dummy place holder TreeItem from which I create the rest of my items, then 
I wouldn't have to worry about checking for top level."



"Stefan Zeiger" <szeiger@xxxxxxxxxxxx> wrote in message 
news:d7c3mo$l6n$1@xxxxxxxxxxxxxxxxxxx
> Joel Chen wrote:
>
>> Is is possible to create a TreeItem that's invisble to serve as the root 
>> item?  I found myself end up with a bunch of functions with identical 
>> body but one takes Tree and another takes TreeItem in its parameters.  I 
>> could get around this by just creating a rootTreeItem but now I lost some 
>> space in the left margin in my tree display.
>
> I don't know your design, so I could be completely wrong, but it might be 
> a design flaw on your end. Maybe those doubled functions should really be 
> working on a TreeItem[] instead of a Tree or a TreeItem.
>
> -- 
> Stefan Zeiger - Developer of Novocode Application Framework
> Build SWT-based MVC GUIs via XML: http://www.novocode.com/naf/