TreeViewer no longer sizes properly when using StyledCellLabels

56 Views Asked by At

I was using a JFace TreeViewer perfectly well for a while. It has a bunch of branches of varying lengths, but at the end of the day, the entire tree stretched to the size of its longest string. This was great.

Recently, I decided that the TreeItems labels should have some style to them fonts and highlights.

The trouble, is that the new fonts are a bit larger and stretch the size of the overall string. It seems that the Tree or TreeViewer doesn't recognize this expansion and still judges the size of the label by the amount of small characters in it. The result is that I get a TreeViewer with a horizontal scrollbar, which is highly inconvenient because now my users will have to scroll across each tree, rather than just being to quickly glance at the data.

Does anyone know how to get the Tree to properly fit the length of the longest string, and take into account the added length of the styling, etc?

Thanks!

1

There are 1 best solutions below

0
On

While this is not a complete answer, I hope it will help jogs someone's memory who has more advanced knowledge on this:

When I set the font to the ViewerCell object to a font that is wide, the entire row properly resizes. It seems that the Tree measures its width by checking the length of the text and the font, but disregards the Style Ranges.