Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Multiple lines of text in one tablecell?
Multiple lines of text in one tablecell? [message #447953] Wed, 22 December 2004 09:43 Go to next message
Frank is currently offline FrankFriend
Messages: 49
Registered: July 2009
Member
Hi!

I wonder if it is possible to display text in a table in several lines?

I want to use a table to display the comments a user made to a list of
elements. Of course, this works quite fine with the comments presented one
line, but with lengthier comments its not very readable.

Thanks in advance,

Frank
Re: Multiple lines of text in one tablecell? [message #447954 is a reply to message #447953] Wed, 22 December 2004 11:09 Go to previous messageGo to next message
cloudor Mising name is currently offline cloudor Mising nameFriend
Messages: 34
Registered: July 2009
Member
Hi,

See http://www.kupzog.de/fkmk_uk/Programming/Downloads/downloads .html

Frank wrote:
> Hi!
>
> I wonder if it is possible to display text in a table in several lines?
>
> I want to use a table to display the comments a user made to a list of
> elements. Of course, this works quite fine with the comments presented
> one line, but with lengthier comments its not very readable.
>
> Thanks in advance,
>
> Frank
>


--
Cloudor Pu
http://cloudor.mysmth.net/
Re: Multiple lines of text in one tablecell? [message #447997 is a reply to message #447954] Thu, 23 December 2004 09:38 Go to previous message
Phill Perryman is currently offline Phill PerrymanFriend
Messages: 214
Registered: July 2009
Senior Member
<br><font size=1 face="sans-serif">I had the same problem and could not find any way to use a variable height table.</font>
<br>
<br><font size=1 face="sans-serif">i ended up doing it in absolute code, hope it of some use. I also added a move and size listener which both call the layout method for when the size changes.</font>
<br>
<br><font size=1 face="sans-serif">Major problem is that is does not scroll so my view sets the composite provided in create part layout to fill layout and adds a scrolled composite. Then create a new composite and fill it up with the layout method shown below and then set that as the input of the scrolled composite.</font>
<br>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; protected void layout(Composite panel) {</font>
<br>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; // make sure we have something to layout</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; if (quoteItem == null)</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;</font>
<br>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; // get the quote as that is where the data model is</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; Quote quote = quoteItem.getQuote();</font>
<br>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; // if not one then give up</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; if (quote == null)</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;</font>
<br>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; // get the size of the area to fill up</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; Rectangle client = panel.getClientArea();</font>
<br>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; // going to allocate a quarter of it to the quote item name</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; int col1 = client.width / 4;</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; int col2 = client.width - col1;</font>
<br>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; // start at the top</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; int y = 0;</font>
<br>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; // find out how many rows are in the table model</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; ConfigWarning[] warnings = quote.getConfigWarnings();</font>
<br>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; // each row has two columns, the first is the name</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; // of the quote item, the next the problem description</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; i &lt; warnings.length; i++) {</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // build the name from the data cell</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Label name = new Label(panel, SWT.WRAP);</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name.setText(warnings[i].getQuoteItemName());</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name.setLocation(0, y);</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Point p1 = name.computeSize(col1, SWT.DEFAULT, true);</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name.setSize(p1.x, p1.y);</font>
<br>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // and the description</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Label desc = new Label(panel, SWT.WRAP);</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; desc.setText(warnings[i].getWarningMessage());</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (warnings[i].isLockPrevention())</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; desc.setForeground(red);</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; desc.setLocation(col1, y);</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Point p2 = desc.computeSize(col2, SWT.DEFAULT, true);</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; desc.setSize(p2.x, p2.y);</font>
<br>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // move down the number of pixels of the tallest</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // column</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (p1.y &gt; p2.y)</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y += p1.y;</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else {</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y += p2.y;</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; }</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; }</font>
Previous Topic:A question about Menu
Next Topic:Combo with font facenames
Goto Forum:
  


Current Time: Fri Apr 26 13:50:00 GMT 2024

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

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

Back to the top