Wednesday, February 29, 2012

Eclipse JFace 'VIRTUAL' TreeViewer basically requires TreeColumnLayout?

When switching a TreeViewer from an ITreeContentProvider to a 'VIRTUAL' TreeViewer with ILazyTreeContentProvider, the tree display initially appeared blank. The items in the tree would only become visible after waiting a little, or by doing some window operations that result in a refresh of the tree. This happened especially on Mac OS X.

After looking closer, it became obvious that the one and only column of the tree had a nearly zero width. Note the arrow in the image that shows the column separator:




The issue seems to be that a non-VIRTUAL TreeViewer knows all its items right away and can size the tree columns appropriately. When swtiching to a VIRTUAL TreeViewer, the items are updated as needed, and the column refresh can lag.

Early "fixes" involved forcing a refresh after setting the TreeViewer input:

tree.setRedraw(false);
tree_viewer.setInput(config);
tree_viewer.refresh();
tree.setRedraw(true);

or

tree_viewer.expandAll();

But the best workaround seems to be to use a TreeColumnLayout that always auto-sizes the one and only column:


// Note that the TreeViewer needs to be the only widget
// under the parent widget. If necessary, add Composite
// to wrap the TreeViewer
final TreeColumnLayout layout = new TreeColumnLayout();
parent.setLayout(layout);
final TreeViewer v = new TreeViewer(shell, SWT.VIRTUAL | SWT.BORDER);
v.setLabelProvider(new LabelProvider());

Friday, February 3, 2012

Avoid Soft Links in Eclipse Headless build - or ant in general?

Ran into a really strange problem.
As a result of a headless Eclipse product build, I usually get an abc.app for Mac OS X.
But this time around I got an abc.app for Mac OS X that "worked", but the program icon was wrong. In addition, there was an Eclipse.app directory that's mostly empty.
Products for other architectures (Linux, Windows) looked OK.

Apparently, the build process had first put the Eclipse.app in place, tried to assign the icon etc., and then renamed it to the actual product name abc.app, but something failed in the process. The Eclipse.app partially remained in place, and there was no icon.

Solution: I had recently changed the build directory to /tmp. On Mac OS X, /tmp is a soft link (symbolic link) to /private/var. Either the Eclipse headless build or maybe ant in general has problems with soft links. After using a "real" directory path without any soft links as the build directory, things were fine again.