Table with multiline columns [message #140164] |
Tue, 14 July 2009 02:49  |
Eclipse User |
|
|
|
Originally posted by: markus.wolf.nmmn.com
Hi there,
is it possible in RWT to have a table with multiline columns?
I've seen tutorials for SWT where this is done using PaintListeners and
thats not possible with RWT currently.
Thanks for any input on this.
Markus Wolf
--
NMMN - New Media Markets & Networks GmbH
Langbehnstrasse 6, 22761 Hamburg
Geschäftsführung: Kfm. Michael Schütt
Finanzamt HH-Altona - UStID DE 812 699 852 - HRB 71102 Hamburg
HypoVereinsbank - BLZ 200 300 00 - Konto-Nr. 156 29 82
http://www.nmmn.com
Tel.: +49 40 284 118-0 - Fax: +49 40 284118-999
Softwareentwicklung LLynch: -720
|
|
|
|
|
|
|
Re: Table with multiline columns [message #486333 is a reply to message #486299] |
Thu, 17 September 2009 06:13  |
Eclipse User |
|
|
|
Hi Cheney,
you could try a ContentProvider like this:
private static class MultilineContentProvider extends
ArrayContentProvider {
public Object[] getElements(final Object inputElement) {
if (inputElement instanceof List<?>) {
final List<Object> elements = new
LinkedList<Object>();
final List<Object> list = (List<Object>)
inputElement;
for (int i = 0; i < list.size(); i++) {
final Object pos = list.get(i);
final String[] lines = WordUtils.wrap
(pos.toString(),
100, "\n", true).split
("\n");
elements.add(lines[0]);
// Other lines
for (int j = 1; j < lines.length; j++) {
elements.add(lines[j]);
}
}
return elements.toArray();
}
return super.getElements(inputElement);
}
}
The code is not tested, since I removed the application specific party of
our application. So all places where Object is used was a business
specific class containing the data to present, but it should be quite
simple to adopt.
The WordUtils class is from commons-lang and wraps the content to display
at 100 characters.
HTH
Markus
Am Thu, 17 Sep 2009 08:16:08 +0000 schrieb Cheney Chen:
> Hi Austin and Markus,
>
> I also need a table with multiline columns, but I can't implement it.Can
> you give me some hints or some exactly simple code?
>
> Thanks,
> Cheney
>
> On Tue, 21 Jul 2009 07:44:50 +0000, Markus Wolf wrote:
>
>> Hello Austin,
>>
>> I helped myself with the problem by implementing a ContentProvider and
>> LabelProvider which splits up the long text into multiple table rows.
>> The input is wrapped by the ContentProvider and then send as model-
>> elements to the table viewer. This aproach works quite well but it is
>> not possible to have TableEditors with this. That the only drawback we
>> have.
>>
>> But thanks for your input. :)
>>
>> Markus
>>
>>
>>> There is a way to have some semblance of multi-line table rows in a
>>> TableViewer if you don't mind a bit of hacking.
>>>
>>> I have a small experimental implementation that will interpret '\n'
>>> characters in the text that is returned from the LabelProvider. It is
>>> limited in ability, and it is unconventional, but if you need the
>>> multi-line tables that bad you may find it helpful.
>>>
>>> Caveats:
>>> 1. You must manually set the row height on the TableViewer. 2. The row
>>> height will be consistent for all rows. 3. The text will be left
>>> justified.
>>> 4. Overflow is cut off.
>>>
>>>
>>> If you are still interested I can post it.
--
NMMN - New Media Markets & Networks GmbH
Langbehnstrasse 6, 22761 Hamburg
Geschäftsführung: Kfm. Michael Schütt
Finanzamt HH-Altona - UStID DE 812 699 852 - HRB 71102 Hamburg
HypoVereinsbank - BLZ 200 300 00 - Konto-Nr. 156 29 82
http://www.nmmn.com
Tel.: +49 40 284 118-0 - Fax: +49 40 284118-999
Softwareentwicklung LLynch: -720
|
|
|
Powered by
FUDForum. Page generated in 0.03880 seconds