Problem: I need a SWT table (JFace TableViewer) with a variable row height. In fact, I solved this on my development machine (running Ubuntu 10.10). Unfortunately, this does not work on Windows and Mac.
At first, I thought I used libraries incorrectly. But now I'm afraid that what I want to do is simply not possible on Windows. I hope someone here convinces me otherwise.
To reproduce: instead of providing my code here, I created a minimal program to reproduce the problem. I started with the following Snipplet:
http://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/examples/org.eclipse.jface.snippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippets/viewers/ Snippet049StyledCellLabelProvider.java
I modified the update () method to create two lines of text for directories and one line for files (to simulate an environment with a variable line height):
...
if (file.isDirectory ()) {
cell.setText (styledString.toString () + "\ n"
+ styledString.toString ());
cell.setImage (IMAGE1);
} else {
cell.setImage (IMAGE2);
}
...This works like on Linux, but on Windows all the lines are the same height. In particular, only one row is visible.
Then I tried to help SWT by making measure () more reasonable. So I rewrote measure () as follows:
protected void measure (Event event, Object element) {
if (((File) element) .isDirectory ()) {
event.height = 32;
} else {
event.height = 16;
}
super.measure(event, element);
}: 32. , Linux.
, Windows . showstopper. - ?
!