Question regarding TreeViewer [message #462610] |
Fri, 14 October 2005 20:11  |
Eclipse User |
|
|
|
Hi,
I am using a TreeViewer with additional columns.
Since such a tree with table columns right to the tree can be hard to
read once it get's larger and one adds more columns, I would like to
introduce a nice color banding for odd and even rows.
I have not found a solution to my problem yet. The only piece of code I
found was for a table, there it worked by setting the background of the
TableItems.
I tested to set the background of the root item and it worked partially
in the sense that the tree column was not completely background colored
with my color (only the label, not the space right to it up to the next
column). The subsequent columns to the right were correctly colored
though. Good.
The problems I have are firstly how to do it in a hierarchy of items and
secondly when to do it - perhaps in some listener?
In Swing I always used a renderer for such kind of stuff so I'm kind of
lost now.
Thanks
Andre
|
|
|
|
|
|
Re: Question regarding TreeViewer [message #462711 is a reply to message #462704] |
Mon, 17 October 2005 16:50   |
Eclipse User |
|
|
|
Grant Gayed schrieb:
> The approach that you're taking is correct. You can make the background
> colour span the full width, excluding the expand/collapse box, by creating
> your Tree with style SWT.FULL_SELECTION.
>
> Ideally, style FULL_SELECTION should not be needed to make this work, but
> this seems to be the case on win32. I'm not sure if this is a bug or native
> platform behaviour, so I've logged
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=112791 to investigate.
>
> Grant
Great - or not so great, but I can live with that small bug for the time
being. I added FULL_SELECTION, now the row is colored completely.
I still have no idea how to do the banding with alternating colors on a
tree correctly. The problem is that I just can't go through the
hierarchy and apply alternating background colors to the TreeItems on my
way, because I have to consider the expansion state of each node so that
no two rows will result in the same background color.
I'm sure this is FAQ, but I have no idea where to hook for listening to
expansion events - if there are such ???
Can somebody point me into the right direction?
andre
|
|
|
Re: Question regarding TreeViewer [message #462731 is a reply to message #462711] |
Tue, 18 October 2005 09:57   |
Eclipse User |
|
|
|
Tree.addTreeListener() will let you listen for expands and collapses.
"Andre R. Pareis" <andre.pareis@entura.ch> wrote in message
news:dj12rd$n6e$1@news.eclipse.org...
> Grant Gayed schrieb:
> > The approach that you're taking is correct. You can make the background
> > colour span the full width, excluding the expand/collapse box, by
creating
> > your Tree with style SWT.FULL_SELECTION.
> >
> > Ideally, style FULL_SELECTION should not be needed to make this work,
but
> > this seems to be the case on win32. I'm not sure if this is a bug or
native
> > platform behaviour, so I've logged
> > https://bugs.eclipse.org/bugs/show_bug.cgi?id=112791 to investigate.
> >
> > Grant
>
> Great - or not so great, but I can live with that small bug for the time
> being. I added FULL_SELECTION, now the row is colored completely.
>
> I still have no idea how to do the banding with alternating colors on a
> tree correctly. The problem is that I just can't go through the
> hierarchy and apply alternating background colors to the TreeItems on my
> way, because I have to consider the expansion state of each node so that
> no two rows will result in the same background color.
>
> I'm sure this is FAQ, but I have no idea where to hook for listening to
> expansion events - if there are such ???
>
> Can somebody point me into the right direction?
>
> andre
|
|
|
|
|
Re: Question regarding TreeViewer [message #462805 is a reply to message #462791] |
Wed, 19 October 2005 16:00  |
Eclipse User |
|
|
|
Grant Gayed wrote:
> A slightly less hacky approach to deferring the banding is to do it in an
> asyncExec. This would make your applyBanding method look like:
>
> private void applyBanding() {
> final Tree tree = treeViewerWithColumns.getTree();
> tree.getDisplay().asyncExec(new Runnable() {
> public void run() {
> if (!tree.isDisposed()) {
> applyBandingOnTree(tree.getItem(0), 0);
> }
> }
> });
> }
thanks Grant, workes fine and makes expansion visually a bit smoother
andre
|
|
|
Powered by
FUDForum. Page generated in 0.06231 seconds