Just a quick tip about JFace viewers.

JFace Bug 9262
Wondering where this bug comes from ??? After 10mn about reading again and again my code to figure out why my SWT tree was showing recursively (infinitely) my root object, I finally suspected JFace (without convictions) and reached this bug, source of my problem.
According to the Javadoc of the IStructuredContentProvider. public Object[] getElements(Object inputElement) method you can’t return a single item object array containing only inputElement.
“NOTE: For instances where the viewer is displaying a tree containing a single ‘root’ element it is still necessary that the ‘input’ does not return itself from this method. This leads to recursion issues (see bug 9262).”
To solve this issue I just created a new class for my root object and instead of returning an object containing the inputElement I return an array containing a new instance of this root element (having of course a reference on the inputElement).
Manuel
January 16, 2009 at 4:38 pm |
I think this happens to everybody the first time they try to write a content provider for a tree viewer. Thanks for pointing out that there is a bug open about it.
October 23, 2009 at 4:41 am |
Thanks Manuel,
fortunately I realised pretty quickly about the bug (thanks to Javadoc).
I had no idea how to fix it until I read your post.