Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Invisible root TreeItem?
Invisible root TreeItem? [message #456259] Sat, 28 May 2005 00:43 Go to next message
Eclipse UserFriend
Originally posted by: joel_chen.yahoo.com

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.
Re: Invisible root TreeItem? [message #456261 is a reply to message #456259] Sat, 28 May 2005 01:27 Go to previous messageGo to next message
Daniel Spiewak is currently offline Daniel SpiewakFriend
Messages: 263
Registered: July 2009
Senior Member
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<font face="serif">You can create multiple root tree items on the Tree
itself.&nbsp; Unlike with Swing, you can have more than one root.&nbsp; Thus,
accomplishing in actuality what Swing accomplishes by illusion.<br>
<br>
Daniel<br>
</font><br>
Joel Chen wrote:
<blockquote cite="midd78f3p$vtb$1@news.eclipse.org" type="cite">
<pre wrap="">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.


</pre>
</blockquote>
</body>
</html>
Re: Invisible root TreeItem? [message #456263 is a reply to message #456261] Sat, 28 May 2005 02:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: joel_chen.yahoo.com

This is a multi-part message in MIME format.

------=_NextPart_000_003B_01C562F2.F1EBFE70
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I am not sure what you mean, but I am not that good with SWT and a bit =
rusty with Java itself, however I see no remedy to my situation from =
what you said. The fact that there are two ways I can create a TreeItem =
like:

new TreeItem( Tree, style )=20
or=20
new TreeItem( TreeItem, style )=20

and that you can't cast Tree to TreeItem is kind of clunky and I have to =
have two versions of some of my code to deal with it. =20

If Tree creates a default root item that's invisible, then I don't have =
this problem. Even then, you can still have multiple "root" items under =
the default root item, right?

I am sure I am missing something here since no one seem to complain =
about this, but I see no clear way around it.


"Daniel Spiewak" <djspiewak@hotpop.com> wrote in message =
news:d78hll$1rl$1@news.eclipse.org...
You can create multiple root tree items on the Tree itself. Unlike =
with Swing, you can have more than one root. Thus, accomplishing in =
actuality what Swing accomplishes by illusion.

Daniel

Joel Chen wrote:=20
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=20
but one takes Tree and another takes TreeItem in its parameters. I =
could=20
get around this by just creating a rootTreeItem but now I lost some =
space in=20
the left margin in my tree display.=20



------=_NextPart_000_003B_01C562F2.F1EBFE70
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE></TITLE>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2900.2627" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>I am not sure what you mean, but I am =
not that good=20
with SWT and a bit rusty with Java itself, however I see no remedy to my =

situation from what you said.&nbsp; The fact that there are two ways I =
can=20
create a TreeItem like:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>new TreeItem( Tree, style ) =
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>or </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>new TreeItem( TreeItem, style ) =
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>and that you can't cast Tree to =
TreeItem is kind of=20
clunky and I have to have two versions of some of my code to deal with =
it.&nbsp;=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>If Tree creates a default root item =
that's=20
invisible, then I don't have this problem.&nbsp; Even then, you can =
still have=20
multiple "root" items under the default root item, right?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I am sure I am missing something here =
since no one=20
seem to complain about this, but I see no clear way around =
it.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Daniel Spiewak" &lt;<A=20
href=3D"mailto:djspiewak@hotpop.com">djspiewak@hotpop.com</A>&gt; =
wrote in=20
message <A=20
=
href=3D"news:d78hll$1rl$1@news.eclipse.org">news:d78hll$1rl$1@news.eclips=
e.org</A>...</DIV><FONT=20
face=3Dserif>You can create multiple root tree items on the Tree =
itself.&nbsp;=20
Unlike with Swing, you can have more than one root.&nbsp; Thus, =
accomplishing=20
in actuality what Swing accomplishes by=20
illusion.<BR><BR>Daniel<BR></FONT><BR>Joel Chen wrote:=20
<BLOCKQUOTE cite=3Dmidd78f3p$vtb$1@news.eclipse.org type=3D"cite"><PRE =
wrap=3D"">Is is possible to create a TreeItem that's invisble to serve =
as the root=20
item? I found myself end up with a bunch of functions with identical =
body=20
but one takes Tree and another takes TreeItem in its parameters. I =
could=20
get around this by just creating a rootTreeItem but now I lost some =
space in=20
the left margin in my tree display.=20


</PRE></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_003B_01C562F2.F1EBFE70--
Re: Invisible root TreeItem? [message #456265 is a reply to message #456263] Sat, 28 May 2005 18:15 Go to previous messageGo to next message
Daniel Spiewak is currently offline Daniel SpiewakFriend
Messages: 263
Registered: July 2009
Senior Member
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<font face="serif">You don't cast anything to anything.&nbsp; Nor does SWT
create a default root item for you.&nbsp; What you do is as follows:<br>
<br>
&nbsp;&nbsp;&nbsp; ...<br>
&nbsp;&nbsp;&nbsp; Tree tree = <b>new</b> Tree(parent, SWT.BORDER | SWT.SINGLE |
SWT.FULL_SELECTION);<br>
<br>
&nbsp;&nbsp;&nbsp; TreeItem root1 = <b>new</b> TreeItem(tree, SWT.NONE);<br>
&nbsp;&nbsp;&nbsp; root1.setText(<i>"This is the first root item"</i>);<br>
<br>
&nbsp;&nbsp;&nbsp; TreeItem root2 = <b>new</b> TreeItem(tree, SWT.NONE);<br>
&nbsp;&nbsp;&nbsp; root2.setText(<i>"This is the second root item"</i>);<br>
<br>
&nbsp;&nbsp;&nbsp; TreeItem child1 = <b>new</b> TreeItem(root2, SWT.NONE);<br>
&nbsp;&nbsp;&nbsp; child1.setText("<i>This item is the first child item"</i>);<br>
&nbsp;&nbsp;&nbsp; ...<br>
</font><br>
This code will create a tree structure as follows:<br>
<br>
&nbsp;&nbsp;&nbsp; | - This is the first root item<br>
&nbsp;&nbsp;&nbsp; | - This is the second root item<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; | - This is the first child item<br>
<br>
As you see, there are litterally two root items, not one invisible root
item.&nbsp; This simplifies things conceptually and saves on memory.&nbsp; As to
the overloaded constructors for TreeItem, I suggest that you do as I do
when I work with Tree(s): create a method to add a TreeItem to a Tree
based on data passed to it, and then overload the method for adding a
TreeItem to another TreeItem.&nbsp; You can litterally cut and paste your
code from one method to the other as long as you keep your parameter
names straight.<br>
<br>
Daniel<br>
<br>
Joel Chen wrote:
<blockquote cite="midd78lh2$4fa$1@news.eclipse.org" type="cite">
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<meta content="MSHTML 6.00.2900.2627" name="GENERATOR">
<style></style>
<div><font face="Arial" size="2">I am not sure what you mean, but I
am not that good with SWT and a bit rusty with Java itself, however I
see no remedy to my situation from what you said.&nbsp; The fact that there
are two ways I can create a TreeItem like:</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">new TreeItem( Tree, style ) </font></div>
<div><font face="Arial" size="2">or </font></div>
<div><font face="Arial" size="2">new TreeItem( TreeItem, style ) </font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">and that you can't cast Tree to
TreeItem is kind of clunky and I have to have two versions of some of
my code to deal with it.&nbsp; </font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">If Tree creates a default root item
that's invisible, then I don't have this problem.&nbsp; Even then, you can
still have multiple "root" items under the default root item, right?</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">I am sure I am missing something
here since no one seem to complain about this, but I see no clear way
around it.</font></div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;"
dir="ltr">
<div>"Daniel Spiewak" &lt;<a href="mailto:djspiewak@hotpop.com">djspiewak@hotpop.com</a>&gt;
wrote in message <a href="news:d78hll$1rl$1@news.eclipse.org">news:d78hll$1rl$1@news.eclipse.org</a>...</div>
<font face="serif">You can create multiple root tree items on the
Tree itself.&nbsp; Unlike with Swing, you can have more than one root.&nbsp;
Thus, accomplishing in actuality what Swing accomplishes by illusion.<br>
<br>
Daniel<br>
</font><br>
Joel Chen wrote:
<blockquote cite="midd78f3p$vtb$1@news.eclipse.org" type="cite">
<pre wrap="">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.


</pre>
</blockquote>
</blockquote>
</blockquote>
</body>
</html>
Re: Invisible root TreeItem? [message #456266 is a reply to message #456265] Sun, 29 May 2005 02:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: joel_chen.yahoo.com

This is a multi-part message in MIME format.

------=_NextPart_000_0005_01C563BD.0FABC010
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I know how to create a tree. I guess what I have in mind is odd and no =
one else really care about doing it that way. I have no trouble with =
the concept of tree and programming, just haven't used Java language for =
a few years. =20

I will just do what everyone else do. That is, MyFolder =3D new =
TreeItem(tree, style) and create the rest of my structure (ie. Items) =
under MyFolder. You see, originally, I was thinking to allow having =
Items at the same level as MyFolder, but that would mean I have to =
handle the case of creating Items by calling items =3D new =
TreeItem(tree, style) instead of only have to call items =3D new =
TreeItem(MyFolder, style). So I'd only need to call new =
TreeItem(tree,style) once at the begining, which is exactly what I have =
implemented. Now that I've described my whole idea without ever using =
the words root or cast, I hope we are clear on that. =20

Note: Of course in the structure under MyFolder, an Item can be a folder =
as well. =20

My conclusion is that the answer to my original question is simply "No".

Thank you for you time. =20

"Daniel Spiewak" <djspiewak@hotpop.com> wrote in message =
news:d7aco7$d4q$1@news.eclipse.org...
You don't cast anything to anything. Nor does SWT create a default =
root item for you. What you do is as follows:

...
Tree tree =3D new Tree(parent, SWT.BORDER | SWT.SINGLE | =
SWT.FULL_SELECTION);

TreeItem root1 =3D new TreeItem(tree, SWT.NONE);
root1.setText("This is the first root item");

TreeItem root2 =3D new TreeItem(tree, SWT.NONE);
root2.setText("This is the second root item");

TreeItem child1 =3D new TreeItem(root2, SWT.NONE);
child1.setText("This item is the first child item");
...

This code will create a tree structure as follows:

| - This is the first root item
| - This is the second root item
| - This is the first child item

As you see, there are litterally two root items, not one invisible =
root item. This simplifies things conceptually and saves on memory. As =
to the overloaded constructors for TreeItem, I suggest that you do as I =
do when I work with Tree(s): create a method to add a TreeItem to a Tree =
based on data passed to it, and then overload the method for adding a =
TreeItem to another TreeItem. You can litterally cut and paste your =
code from one method to the other as long as you keep your parameter =
names straight.

Daniel

Joel Chen wrote:=20
I am not sure what you mean, but I am not that good with SWT and a =
bit rusty with Java itself, however I see no remedy to my situation from =
what you said. The fact that there are two ways I can create a TreeItem =
like:

new TreeItem( Tree, style )=20
or=20
new TreeItem( TreeItem, style )=20

and that you can't cast Tree to TreeItem is kind of clunky and I =
have to have two versions of some of my code to deal with it. =20

If Tree creates a default root item that's invisible, then I don't =
have this problem. Even then, you can still have multiple "root" items =
under the default root item, right?

I am sure I am missing something here since no one seem to complain =
about this, but I see no clear way around it.


"Daniel Spiewak" <djspiewak@hotpop.com> wrote in message =
news:d78hll$1rl$1@news.eclipse.org...
You can create multiple root tree items on the Tree itself. =
Unlike with Swing, you can have more than one root. Thus, accomplishing =
in actuality what Swing accomplishes by illusion.

Daniel

Joel Chen wrote:=20
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=20
but one takes Tree and another takes TreeItem in its parameters. I =
could=20
get around this by just creating a rootTreeItem but now I lost some =
space in=20
the left margin in my tree display.=20



------=_NextPart_000_0005_01C563BD.0FABC010
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE></TITLE>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2900.2627" name=3DGENERATOR></HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>I know how to create a tree.&nbsp; I =
guess what I=20
have in mind is odd and no one else really care about doing it that =
way.&nbsp; I=20
have no trouble with the concept of tree and programming, just haven't =
used Java=20
language for a few years.&nbsp; </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I will just do what everyone else =
do.&nbsp; That=20
is, <EM>MyFolder =3D new TreeItem(tree, style)</EM> and create the rest =
of my=20
structure (ie. Items) under MyFolder.&nbsp; You see, originally, I was =
thinking=20
to allow having Items at the same level as MyFolder, but that would mean =
I have=20
to handle the case of creating Items by calling <EM>items =3D new =
TreeItem(tree,=20
style)</EM> instead of only have to call <EM>items =3D new =
TreeItem(MyFolder,=20
style)</EM>.&nbsp; So I'd only need to call new TreeItem(tree,style) =
once at the=20
begining, which is exactly what I have implemented.&nbsp; Now that I've=20
described my whole idea without ever using the words root or cast, I =
hope we are=20
clear on that.&nbsp; </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Note: Of course in the structure under =
MyFolder, an=20
Item can be a folder as well.&nbsp; </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>My conclusion is that the answer to my =
original=20
question is simply "No".</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>
<DIV><FONT face=3DArial size=3D2>Thank you for you time.&nbsp; =
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Daniel Spiewak" &lt;<A=20
href=3D"mailto:djspiewak@hotpop.com">djspiewak@hotpop.com</A>&gt; =
wrote in=20
message <A=20
=
href=3D"news:d7aco7$d4q$1@news.eclipse.org">news:d7aco7$d4q$1@news.eclips=
e.org</A>...</DIV><FONT=20
face=3Dserif>You don't cast anything to anything.&nbsp; Nor does SWT =
create a=20
default root item for you.&nbsp; What you do is as=20
follows:<BR><BR>&nbsp;&nbsp;&nbsp; ...<BR>&nbsp;&nbsp;&nbsp; Tree tree =
=3D=20
<B>new</B> Tree(parent, SWT.BORDER | SWT.SINGLE |=20
SWT.FULL_SELECTION);<BR><BR>&nbsp;&nbsp;&nbsp; TreeItem root1 =3D =
<B>new</B>=20
TreeItem(tree, SWT.NONE);<BR>&nbsp;&nbsp;&nbsp; root1.setText(<I>"This =
is the=20
first root item"</I>);<BR><BR>&nbsp;&nbsp;&nbsp; TreeItem root2 =3D =
<B>new</B>=20
TreeItem(tree, SWT.NONE);<BR>&nbsp;&nbsp;&nbsp; root2.setText(<I>"This =
is the=20
second root item"</I>);<BR><BR>&nbsp;&nbsp;&nbsp; TreeItem child1 =3D =
<B>new</B>=20
TreeItem(root2, SWT.NONE);<BR>&nbsp;&nbsp;&nbsp; =
child1.setText("<I>This item=20
is the first child item"</I>);<BR>&nbsp;&nbsp;&nbsp; =
....<BR></FONT><BR>This=20
code will create a tree structure as =
follows:<BR><BR>&nbsp;&nbsp;&nbsp; | -=20
This is the first root item<BR>&nbsp;&nbsp;&nbsp; | - This is the =
second root=20
item<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; | - This is the =
first=20
child item<BR><BR>As you see, there are litterally two root items, not =
one=20
invisible root item.&nbsp; This simplifies things conceptually and =
saves on=20
memory.&nbsp; As to the overloaded constructors for TreeItem, I =
suggest that=20
you do as I do when I work with Tree(s): create a method to add a =
TreeItem to=20
a Tree based on data passed to it, and then overload the method for =
adding a=20
TreeItem to another TreeItem.&nbsp; You can litterally cut and paste =
your code=20
from one method to the other as long as you keep your parameter names=20
straight.<BR><BR>Daniel<BR><BR>Joel Chen wrote:=20
<BLOCKQUOTE cite=3Dmidd78lh2$4fa$1@news.eclipse.org type=3D"cite">
<META content=3D"MSHTML 6.00.2900.2627" name=3DGENERATOR>
<STYLE></STYLE>

<DIV><FONT face=3DArial size=3D2>I am not sure what you mean, but I =
am not that=20
good with SWT and a bit rusty with Java itself, however I see no =
remedy to=20
my situation from what you said.&nbsp; The fact that there are two =
ways I=20
can create a TreeItem like:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>new TreeItem( Tree, style ) =
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>or </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>new TreeItem( TreeItem, style ) =
</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>and that you can't cast Tree to =
TreeItem is=20
kind of clunky and I have to have two versions of some of my code to =
deal=20
with it.&nbsp; </FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>If Tree creates a default root item =
that's=20
invisible, then I don't have this problem.&nbsp; Even then, you can =
still=20
have multiple "root" items under the default root item, =
right?</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I am sure I am missing something =
here since no=20
one seem to complain about this, but I see no clear way around=20
it.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Daniel Spiewak" &lt;<A=20
href=3D"mailto:djspiewak@hotpop.com">djspiewak@hotpop.com</A>&gt; =
wrote in=20
message <A=20
=
href=3D"news:d78hll$1rl$1@news.eclipse.org">news:d78hll$1rl$1@news.eclips=
e.org</A>...</DIV><FONT=20
face=3Dserif>You can create multiple root tree items on the Tree=20
itself.&nbsp; Unlike with Swing, you can have more than one =
root.&nbsp;=20
Thus, accomplishing in actuality what Swing accomplishes by=20
illusion.<BR><BR>Daniel<BR></FONT><BR>Joel Chen wrote:=20
<BLOCKQUOTE cite=3Dmidd78f3p$vtb$1@news.eclipse.org =
type=3D"cite"><PRE wrap=3D"">Is is possible to create a TreeItem that's =
invisble to serve as the root=20
item? I found myself end up with a bunch of functions with identical =
body=20
but one takes Tree and another takes TreeItem in its parameters. I =
could=20
get around this by just creating a rootTreeItem but now I lost some =
space in=20
the left margin in my tree display.=20


=
</PRE></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE ></BODY></HTML>

------=_NextPart_000_0005_01C563BD.0FABC010--
Re: Invisible root TreeItem? [message #456267 is a reply to message #456259] Sun, 29 May 2005 09:53 Go to previous messageGo to next message
Stefan Zeiger is currently offline Stefan ZeigerFriend
Messages: 102
Registered: July 2009
Senior Member
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/
Re: Invisible root TreeItem? [message #456414 is a reply to message #456267] Thu, 02 June 2005 19:00 Go to previous message
Eclipse UserFriend
Originally posted by: joel_chen.yahoo.com

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@novocode.com> wrote in message
news:d7c3mo$l6n$1@news.eclipse.org...
> 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/
Previous Topic:Problem with SWT under Mac os X
Next Topic:Tree and Table common interface?
Goto Forum:
  


Current Time: Fri Mar 29 07:58:49 GMT 2024

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

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

Back to the top