Community
Participate
Working Groups
As extension of the implementation proposed in bug 188333 this enhancement request proposes support for styled multi-line viewer labels with automatic line wrapping: I.e. if your styled label is too long to fit your table cell, the label is automatically wrapped and its height is adapted. Support for styling the labels with multiple colors and fonts is already included in bug 188333, but if the labels are to contain multiple lines, an extension is needed. Currently you need a patched SWT to see all features of this patch, so I created a flash animation showing them. Please look at it here: http://michael.krkoska.googlepages.com/wrap.htm The implementation provided here implements the style bit StyledLabelSupport.CENTER_TEXT_VERTICALLY for multi-line labels, i.e. if the image in a line is higher than the text in the line, the text in the line is vertically centered - Bug 188333 does this only for single line labels. Currently multi-line labels are supported only by putting line breaks in the label. Support for automatic line wrapping is implemented here, but it uses Table.setItemHeight(int) and Tree.setItemHeight(int), two methods which are not part of the public SWT API yet. See bug 130024 and bug 148039. That's why three lines are commented and marked with TODO. Patching SWT is very easy for win32, carbon and the WS where Table and Tree are emulated: you only have to write public in front of the methods. Unfortunately the methods are not provided for gtk.
Created attachment 73166 [details] proposed implementation for the request
Created attachment 73273 [details] Implementation and snippet Fixed a strange bug under Windows Vista (not WPF) with line wrapping and multicolumned tables. Something seems to be different from XP there...
Adding dependency on bug 148039 which requests that Table.setItemHeight(int) be made public.
Added dep to bug 188333 as the comment below describes this is an enhancement, if the support is already wrapped into implementation of bug 188333. The we should close this one.
Created attachment 73700 [details] Implementation and snippet The most recent patch, reflecting the changes in Bug 188333 and fixing a carbon bug. The necessary code from Bug 188333 is included in the patch, so that this patch stays excecutable even if there are changes in Bug 188333. You still need a patched SWT to experience automatic wrapping. Uncomment the marked lines in StyledMultiLineProvider and the SWT.WRAP style in the snippet, if you have a patched SWT. Tested on Win XP, Vista and Carbon.
I tried it with wrapping, it works well, but there is no way how to collapse back, it just get bigger and bigger lines. Any idea how to solve this problem? Thanks.
That's the reason, why this bug is blocked by bug 148039. You need a patched SWT, to make it work. The patched SWT has to expose Table.setItemHeight(int) and Tree.setItemHeight(int). This is no problem on every WS except GTK: you only have to write public in front of the already existing methods. Also you have to uncomment three lines in the patch, which are marked with TODO tags. (they don't compile without a patched SWT, that's why I commented them) Please be aware, that this implementation probably won't make it into JFace, since it is based on my implementation from bug 188333, which was rejected.
[#7] I am sorry that I described my problem very briefly. I already patched SWT, maybe in inferior way (I run ant script without version information and then copied Table.java, Table.class, Tree.java and Tree.class into appropriate locations. Next step was removing RSA signature from plugin to avoid JavaSecurityException. Maybe strange, but it works). Instead of patching JFace, I placed these three classes into its own plugin. Problem I experienced occurs when content of TableViewer was changed (or during scrolling). Content is not very readable, only two rows are visible on whole display. After resizing columns (even after setting same width as before) is cell height significantly smaller than before. Note I am using ILazyContentProvider. Tested on Windows XP. Thanks for any ideas, links etc.
I just modified the snippet to use a ILazyContentProvider and a Table with SWT.VIRTUAL and experienced no problems during scrolling. I did not change the content, though. Did you try a Table.redraw() after changing the content? Can you provide a snippet showing the problem?
Created attachment 84293 [details] Snippet for demonstrating strange behavior I created simple snippet, try scroll down then up. Once increased height cannot decrease even if is not neccessary.
Created attachment 84307 [details] Snippet without strange behaviour (In reply to comment #10) > Once increased height cannot decrease even if is not neccessary. That's true. This is not supported yet. Item height is only increased automatically, decreasing is done only when resizing a column. I remember some infinite loop and flickering issues, but I hacked together a workaround, which might do the trick and seems to have no such issues. Please look at the inner class OnScrollResizer: It forces a height adjustment (by setting the column width, as you also did in your resize action), when the table gets scrolled. When setting a new input you can also call TableColumn.setWidth(.) as a workaround. Both workarounds might be included in a future version of the patch, if this patch has a future. But some testing on the other platforms must be done first.
*** Bug 150618 has been marked as a duplicate of this bug. ***
This bug has been quiet for a long time. Has another way been found to make auto-wrapping labels (i'm particularly interested in ViewerCells in a TreeViewer or TreeViewerColumn), or are we still blocked on 148039?
Still blocked on bug 148039, at least if you don't want to have the same height for all items. We do have styled labels as of 3.4, just not multi-line.
Nebula provides two non-native table implementations, which might satisfy your needs, CTableTree and Grid. http://www.eclipse.org/nebula/ And then there is a rather new table widget called AgileGrid, which looks powerful: http://agilegrid.sourceforge.net Don't know anything about the auto-wrapping capabilities of any of these widgets, though. Good luck!
Is there a plan to resolve this issue? We have a few tools at IBM that are waiting for this functionality.
(In reply to comment #14) > Still blocked on bug 148039, at least if you don't want to have the same height > for all items. > > We do have styled labels as of 3.4, just not multi-line. This still describes accurately what the status of this enhancement request is.
Hitesh is now responsible for watching bugs in the [Viewers] component area.
*** Bug 303401 has been marked as a duplicate of this bug. ***
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. If the bug is still relevant, please remove the stalebug whiteboard tag.