Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » TreeViewer and TabFolder
TreeViewer and TabFolder [message #464359] Mon, 21 November 2005 22:05 Go to next message
Matt is currently offline Matt
Messages: 40
Registered: July 2009
Member
Hi,

My TreeViewer works fine on my Composite (parent), but I want it to appear
within a TabItem. But TabItem isn't a Composite, so I created a second
Composite to hold the viewer. The TabFolder looks fine, but there's no
Tree.

Here's my code:

TabFolder folder = new TabFolder(parent, SWT.BOTTOM);
TabItem projectTab = new TabItem(folder, SWT.NONE, 0);
Composite projectComp = new Composite(folder, SWT.NONE);
TreeViewer treeViewer = new TreeViewer(projectComp);
...
projectTab.setControl(projectComp);
projectTab.setText("Project");

Any thoughts? Thanks.

Matt
Re: TreeViewer and TabFolder [message #464361 is a reply to message #464359] Mon, 21 November 2005 23:19 Go to previous messageGo to next message
Aaron is currently offline Aaron
Messages: 13
Registered: July 2009
Junior Member
you have to use setControl for the tab's contents. For you I think there
are two ways of doing this, just putting in the tree, or making a function
for the composite (if you want more on the tab than the tree). The first
way of doing this would be something like:

TabFolder folder = new TabFolder(parent, SWT.BOTTOM);
TabItem projectTab = new TabItem(folder, SWT.NONE, 0);
projectTab.setControl(new TreeViewer(projectComp));

Note that this will only allow for the tree to be on the tab. If you
wanted more stuff on the tab you can still use a composite, and just pass
the composite to setControl like this:

TabFolder folder = new TabFolder(parent, SWT.BOTTOM);
TabItem projectTab = new TabItem(folder, SWT.NONE, 0);

// set up your composite here
Composite projectComp = new Composite(folder, SWT.NONE);
TreeViewer treeViewer = new TreeViewer(projectComp);
.....
// and anything else you want

// now pass the composite to setControl
projectTab.setControl(projectComp);

I think this is what you're looking for, but someone feel free to correct
me if I am wrong.

Aaron
Re: TreeViewer and TabFolder [message #464364 is a reply to message #464361] Tue, 22 November 2005 00:53 Go to previous messageGo to next message
Matt is currently offline Matt
Messages: 40
Registered: July 2009
Member
Aaron,

Thanks for the response! You're quite right about the importance of
setControl(), but there's a large difference between a Tree and a
TreeViewer.

setControl(new TreeViewer()) won't work because TreeViewers aren't
controls. But you can use:

treeName = new Tree(...);
new TreeViewer(treeName);
tabItem.setControl(treeName);

I'd forgotten that TreeViewers can be initialized with Trees as well as
with Composites. Your helpful reply jogged my memory, so I couldn't have
done it without you.

Thanks again.

Matt
Re: TreeViewer and TabFolder [message #464380 is a reply to message #464364] Tue, 22 November 2005 08:54 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika Irvine
Messages: 1272
Registered: July 2009
Senior Member
You can always use TreeViewer.getControl() to get the Tree widget from the
TreeViewer regardless of how it was created. You do not need to create the
TreeViewer with a Tree.

e.g. :

TreeViewer tv = new TreeViewer(tabFolder);
TabItem item = new TabItem(tabFolder, SWT.NONE);
item.setControl(tv.getControl);


"Matt" <mattscar@yahoo.com> wrote in message
news:099cf4aa4f3b71004797b1cbf5b74cdf$1@www.eclipse.org...
> Aaron,
>
> Thanks for the response! You're quite right about the importance of
> setControl(), but there's a large difference between a Tree and a
> TreeViewer.
> setControl(new TreeViewer()) won't work because TreeViewers aren't
> controls. But you can use:
> treeName = new Tree(...);
> new TreeViewer(treeName);
> tabItem.setControl(treeName);
>
> I'd forgotten that TreeViewers can be initialized with Trees as well as
> with Composites. Your helpful reply jogged my memory, so I couldn't have
> done it without you.
>
> Thanks again.
>
> Matt
>
>
>
>
>
Re: TreeViewer and TabFolder [message #464399 is a reply to message #464380] Tue, 22 November 2005 16:37 Go to previous message
Aaron is currently offline Aaron
Messages: 13
Registered: July 2009
Junior Member
Matt...glad I could help a little...I've just started with SWT and haven't
used trees so I missed that part. Good to hear you got it though.

Aaron
Previous Topic:Combo in a form has not flat look
Next Topic:Using SWT to create an advanced ListView type control
Goto Forum:
  


Current Time: Thu Aug 28 23:37:14 EDT 2014

Powered by FUDForum. Page generated in 0.01726 seconds