Bug 195597 - [Viewers] styled, multi-line viewer labels with automatic line wrapping
Summary: [Viewers] styled, multi-line viewer labels with automatic line wrapping
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 enhancement with 6 votes (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
: 150618 303401 (view as bug list)
Depends on: 148039 130024 188333
Blocks:
  Show dependency tree
 
Reported: 2007-07-05 18:09 EDT by Michael Chervil CLA
Modified: 2019-11-27 07:03 EST (History)
12 users (show)

See Also:


Attachments
proposed implementation for the request (20.74 KB, text/plain)
2007-07-05 18:10 EDT, Michael Chervil CLA
no flags Details
Implementation and snippet (20.32 KB, text/plain)
2007-07-08 15:16 EDT, Michael Chervil CLA
no flags Details
Implementation and snippet (42.93 KB, text/plain)
2007-07-12 16:15 EDT, Michael Chervil CLA
no flags Details
Snippet for demonstrating strange behavior (3.99 KB, text/plain)
2007-12-03 03:26 EST, Pavel Sklenak CLA
no flags Details
Snippet without strange behaviour (6.55 KB, application/octet-stream)
2007-12-03 07:36 EST, Michael Chervil CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Chervil CLA 2007-07-05 18:09:32 EDT
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.
Comment 1 Michael Chervil CLA 2007-07-05 18:10:50 EDT
Created attachment 73166 [details]
proposed implementation for the request
Comment 2 Michael Chervil CLA 2007-07-08 15:16:45 EDT
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...
Comment 3 Boris Bokowski CLA 2007-07-09 12:18:15 EDT
Adding dependency on bug 148039 which requests that Table.setItemHeight(int) be made public.
Comment 4 Thomas Schindl CLA 2007-07-12 03:22:56 EDT
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.
Comment 5 Michael Chervil CLA 2007-07-12 16:15:37 EDT
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.
Comment 6 Pavel Sklenak CLA 2007-11-30 10:20:45 EST
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.
Comment 7 Michael Chervil CLA 2007-11-30 11:40:10 EST
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.
Comment 8 Pavel Sklenak CLA 2007-12-01 05:16:48 EST
[#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.
Comment 9 Michael Chervil CLA 2007-12-02 12:52:01 EST
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?
Comment 10 Pavel Sklenak CLA 2007-12-03 03:26:18 EST
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.
Comment 11 Michael Chervil CLA 2007-12-03 07:36:47 EST
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.
Comment 12 Thomas Schindl CLA 2008-01-18 17:41:16 EST
*** Bug 150618 has been marked as a duplicate of this bug. ***
Comment 13 Jim Steel CLA 2008-09-23 00:33:28 EDT
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?
Comment 14 Boris Bokowski CLA 2008-09-23 08:44:43 EDT
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.
Comment 15 Michael Chervil CLA 2008-09-23 09:05:41 EDT
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!
Comment 16 Rohit Shetty CLA 2008-10-31 03:21:49 EDT
Is there a plan to resolve this issue? We have a few tools at IBM that are waiting for this functionality.
Comment 17 Boris Bokowski CLA 2008-10-31 08:53:00 EDT
(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.
Comment 18 Boris Bokowski CLA 2009-11-26 09:55:58 EST
Hitesh is now responsible for watching bugs in the [Viewers] component area.
Comment 19 Eric Moffatt CLA 2010-03-15 14:47:34 EDT
*** Bug 303401 has been marked as a duplicate of this bug. ***
Comment 20 Lars Vogel CLA 2019-11-27 07:03:02 EST
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.