|
Re: DeferredTree: unexpected image gap in first column [message #637990 is a reply to message #637164] |
Tue, 09 November 2010 09:39   |
Eclipse User |
|
|
|
Hi Thomas,
Once an image is set on one item, the native tree reserves a gap with this
size for all other items in the column. The only workaround for this is to
custom draw your items. If most of your items do not have an image to show
then this may be a reasonable thing to do if the additional gaps that you're
currently getting are really problematic. If you want to investigate doing
this then the following links should be helpful:
article on custom drawing at the swt level:
http://www.eclipse.org/articles/article.php?file=Article-Cus tomDrawingTableAndTreeItems/index.html
swt-level snippet that demonstrates drawing items with various image sizes:
http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org. eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet349 .java
swt-level snippet that demonstrates drawing just trailing images (less
intrusive/effort than the previous snippet):
http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org. eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet220 .java
jface-level snippet of using custom draw:
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.s nippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippet s/viewers/Snippet010OwnerDraw.java?view=markup
HTH,
Grant
"Jens Kreidler" <jenskreidler@yahoo.de> wrote in message
news:iau8vh$k9o$1@news.eclipse.org...
>I 've set up a deferred tree with JFace treeViewer and by using the
>DeferredTreeContentManager.
>
> When the tree viewers input is set, then first the pending update adapter
> tree item is show as long the job progresses to fetch the initial data.
>
> After cleanup of the pending update adapter and creation of the displayed
> data, you get an unexpected gap between the expand icons and the text in
> the first column. You see that in the attached image.
>
> The LabelProvider ( a type of BaseLabelProvider implementing
> ITableLabel/Font/ColorProvider ) looks concerning getColumnImage(Object,
> int) as the following:
>
>
>
> @Override
> public Image getColumnImage( Object element, int columnIndex ) {
> if( element instanceof ITreeNode && columnIndex == 0 ) {
> ITreeNode node = (ITreeNode)element;
> return node.getImage();
> }
> return null;
> }
>
> For all but the PendingUpdateAdapter (own type and also a custom
> ITreeNode) this method returns null.
>
> When I comment out the whole method, then the gap dissappears as wanted.
>
> How does this happen and how can you solve this unexpected space / gap?
>
> Any hints or help are appreciated,
>
> Thanks in advance,
>
> Thomas
>
>
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.44921 seconds