Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » DeferredTree: unexpected image gap in first column(In the first column of a deferred tree you get an additional but unexpceted image gap between text and the expand/collapse icon)
DeferredTree: unexpected image gap in first column [message #637164] Thu, 04 November 2010 12:33 Go to next message
Jens Kreidler is currently offline Jens KreidlerFriend
Messages: 17
Registered: July 2009
Junior Member
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 below:

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

http://img530.imageshack.us/img530/6452/jfacequestion1.png

[Updated on: Thu, 04 November 2010 12:40]

Report message to a moderator

Re: DeferredTree: unexpected image gap in first column [message #637990 is a reply to message #637164] Tue, 09 November 2010 14:39 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2151
Registered: July 2009
Senior Member
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
>
>
>
Re: DeferredTree: unexpected image gap in first column [message #639094 is a reply to message #637990] Mon, 15 November 2010 09:45 Go to previous message
Jens Kreidler is currently offline Jens KreidlerFriend
Messages: 17
Registered: July 2009
Junior Member
Thank you Grant for your answer; I thought it could be a native issue, depending on the operating system.

The links you provided are very interesting, thank yout too for that!
Previous Topic:[DataBinding] How to bind a FileDialog to a bean property
Next Topic:many images in jface tableviewer
Goto Forum:
  


Current Time: Wed Nov 26 15:44:58 GMT 2014

Powered by FUDForum. Page generated in 0.03665 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software