Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Is it possible to make a tree item looking different than a Label ?
Is it possible to make a tree item looking different than a Label ? [message #463987] Wed, 16 November 2005 09:17 Go to next message
Eclipse UserFriend
Originally posted by: valerie.berthie.laposte.net

I'm trying to develop a tree with some tree items that are a bit more
complicated than simple labels. I was wondering what is the best practice to
do that. I'm quite new with SWT, so excuse me if my question is obvious, but
I couldn't find any example of that, neither in the doc, nor in the snippets
or tutorials...

Here is what I'm trying to do :
All tree items should have an icon on the left and a text : this is easy to
do.
But, some of the tree items should have several additional icons on the
right of the text...
A tree item could be like that :
[icon] [text] [first additional icon] [second aditional icon]

I thought I could use a TreeTable, but I would like the additional icons to
be displayed just near the text, and NOT in a separate column. So a
TreeTable doesn't fit my needs.

I had a look a the ILabelDecorator, but if my understanding is correct, it
is only useful to add a small image above an existing image, to create like
a rich icon that contain several piece of information. It is not useful for
me.

Then, I thought I have to write my own LabelProvider, exactly like I should
have to write my own CellRenderer with Swing.
But the interface ILabelProvider has already 2 methods : "getText" and
"getImage". How can I go round this behavior ? I expected to find an
interface with something like "getComposite" method, so that I would have
been able to construct my own composite with several images.

I've looked at the super interface : IBaseLabelProvider interface. In the
javadoc, it is written : "Certain label providers may allow multiple labels
per element" but it is not written what are these powerful label providers
!!!
It is also written : "This interface should never be diretly implemented"...
hmmm... So, how to do that ?

I'm sure my problem is quite common, and there is probably a "best practice"
to do such a thing. Could you please give me an advice or a code example, or
a tutorial that deals with that subject ?
Thanks a lot in advance

Val
Re: Is it possible to make a tree item looking different than a Label ? [message #464006 is a reply to message #463987] Wed, 16 November 2005 14:23 Go to previous message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
Native trees and tables only allow one image to be set for each cell.
You could try merging the mutiple images into one image. However, all cells
will reserve the same image width so in cases where your tree item only has
one image, the image will be stretched horizontally. You could get around
that by merging the single image into a wider image, however then there will
be a space between the image and the text.

"Valerie Berthie" <valerie.berthie@laposte.net> wrote in message
news:dletkc$66g$1@news.eclipse.org...
> I'm trying to develop a tree with some tree items that are a bit more
> complicated than simple labels. I was wondering what is the best practice
> to
> do that. I'm quite new with SWT, so excuse me if my question is obvious,
> but
> I couldn't find any example of that, neither in the doc, nor in the
> snippets
> or tutorials...
>
> Here is what I'm trying to do :
> All tree items should have an icon on the left and a text : this is easy
> to
> do.
> But, some of the tree items should have several additional icons on the
> right of the text...
> A tree item could be like that :
> [icon] [text] [first additional icon] [second aditional icon]
>
> I thought I could use a TreeTable, but I would like the additional icons
> to
> be displayed just near the text, and NOT in a separate column. So a
> TreeTable doesn't fit my needs.
>
> I had a look a the ILabelDecorator, but if my understanding is correct, it
> is only useful to add a small image above an existing image, to create
> like
> a rich icon that contain several piece of information. It is not useful
> for
> me.
>
> Then, I thought I have to write my own LabelProvider, exactly like I
> should
> have to write my own CellRenderer with Swing.
> But the interface ILabelProvider has already 2 methods : "getText" and
> "getImage". How can I go round this behavior ? I expected to find an
> interface with something like "getComposite" method, so that I would have
> been able to construct my own composite with several images.
>
> I've looked at the super interface : IBaseLabelProvider interface. In the
> javadoc, it is written : "Certain label providers may allow multiple
> labels
> per element" but it is not written what are these powerful label providers
> !!!
> It is also written : "This interface should never be diretly
> implemented"...
> hmmm... So, how to do that ?
>
> I'm sure my problem is quite common, and there is probably a "best
> practice"
> to do such a thing. Could you please give me an advice or a code example,
> or
> a tutorial that deals with that subject ?
> Thanks a lot in advance
>
> Val
Previous Topic:swt browser Show XML
Next Topic:Tree with only top level 'checkable'
Goto Forum:
  


Current Time: Fri Apr 26 13:41:12 GMT 2024

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

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

Back to the top