Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to underline text of an SWT TableItem?
How to underline text of an SWT TableItem? [message #666529] Wed, 20 April 2011 18:04 Go to next message
Mostafa ElShafei is currently offline Mostafa ElShafeiFriend
Messages: 39
Registered: October 2010
Member
Hello all,

Can you please guide me how to underline the text of a TableItem?

I would like the text to be blue and underlined as a reference link.

Thanks in Advance.

Best Regards,
Mostafa ElShafei.
Re: How to underline text of an SWT TableItem? [message #666587 is a reply to message #666529] Thu, 21 April 2011 07:42 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6523
Registered: July 2009
Senior Member
You need to use OwnerDraw in your Table. In JFace we provide you a
StyledTextLabelProvider which might help you make such a support easier
to implement.

Tom

Am 20.04.11 20:04, schrieb Mostafa ElShafei:
> Hello all,
>
> Can you please guide me how to underline the text of a TableItem?
>
> I would like the text to be blue and underlined as a reference link.
>
> Thanks in Advance.
>
> Best Regards,
> Mostafa ElShafei.
Re: How to underline text of an SWT TableItem? [message #666735 is a reply to message #666587] Fri, 22 April 2011 02:45 Go to previous messageGo to next message
jim liu is currently offline jim liuFriend
Messages: 37
Registered: February 2011
Location: shanghai
Member
Is there a class named with StyledTextLabelProvider,I can not find it.
for table viewer,you can try
IFontProvider
and return a font with underline style


java eclipse Search
http://javafind.appspot.com/

[Updated on: Fri, 22 April 2011 02:47]

Report message to a moderator

Re: How to underline text of an SWT TableItem? [message #666787 is a reply to message #666529] Fri, 22 April 2011 15:06 Go to previous messageGo to next message
Mostafa ElShafei is currently offline Mostafa ElShafeiFriend
Messages: 39
Registered: October 2010
Member
Hello Tom and Jim,

Thanks both for your help.

I succeeded implementing this function. However, I've did it using

swt.widgets.link & swt.custom.tableeditor

Here is the code for everybody.

Link link = new Link (dataTable, SWT.NULL);
link.setText("<A href=\"\">" + stringTemp + "</A>");
link.setSize(stringTemp.length(), 0);
tableEditor = new TableEditor (dataTable);
tableEditor.minimumWidth = link.getSize().x;
tableEditor.horizontalAlignment = SWT.CENTER;
tableEditor.setEditor(link, tableItem, 2);

Best Regards.
Re: How to underline text of an SWT TableItem? [message #666827 is a reply to message #666787] Fri, 22 April 2011 20:57 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6523
Registered: July 2009
Senior Member
I don't think this is a good idea if your table has a lot of items
you'll run out of handles quite soon.

Tom

Am 22.04.11 17:06, schrieb Mostafa ElShafei:
> Hello Tom and Jim,
>
> Thanks both for your help.
>
> I succeeded implementing this function. However, I've did it using
> swt.widgets.link & swt.custom.tableeditor
>
> Here is the code for everybody.
>
> Link link = new Link (dataTable, SWT.NULL);
> link.setText("<A href=\"\">" + stringTemp + "</A>");
> link.setSize(stringTemp.length(), 0);
> tableEditor = new TableEditor (dataTable);
> tableEditor.minimumWidth = link.getSize().x;
> tableEditor.horizontalAlignment = SWT.CENTER;
> tableEditor.setEditor(link, tableItem, 2);
>
> Best Regards.
Re: How to underline text of an SWT TableItem? [message #666834 is a reply to message #666827] Fri, 22 April 2011 21:48 Go to previous messageGo to next message
Mostafa ElShafei is currently offline Mostafa ElShafeiFriend
Messages: 39
Registered: October 2010
Member
Dear Tom,

Thanks for you advice.

What do you suggest? Very Happy

Best Regards.
Re: How to underline text of an SWT TableItem? [message #667031 is a reply to message #666834] Tue, 26 April 2011 13:55 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
His suggestion was to use custom/owner draw. This is described at the swt
level in
http://www.eclipse.org/articles/article.php?file=Article-Cus tomDrawingTableAndTreeItems/index.html .

Grant


"Mostafa ElShafei" <elshafei.mostafa@gmail.com> wrote in message
news:iosskn$a3r$1@news.eclipse.org...
> Dear Tom,
>
> Thanks for you advice.
>
> What do you suggest? :d
> Best Regards.
Re: How to underline text of an SWT TableItem? [message #667032 is a reply to message #666834] Tue, 26 April 2011 14:00 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6523
Registered: July 2009
Senior Member
Well with a StyledCellLabelProvider it is quite easy to do:

> public class ComponentLabelProvider extends StyledCellLabelProvider {
> private static Styler BOTH_STYLER = new Styler() {
> @Override
> public void applyStyles(TextStyle textStyle) {
> textStyle.underline = true;
> }
> };
> public void update(final ViewerCell cell) {
> StyledString styledString = new StyledString(cell.getElement().toString(), BOTH_STYLER);
> cell.setText(styledString.getString());
> cell.setStyleRanges(styledString.getStyleRanges());
> }





Am 22.04.11 23:48, schrieb Mostafa ElShafei:
> Dear Tom,
>
> Thanks for you advice.
>
> What do you suggest? :d
> Best Regards.
Previous Topic:Keyboard layout problem in SWT_AWT Bridge
Next Topic:Question on using a Javascript HTML Editor in a Browser widget
Goto Forum:
  


Current Time: Sat Feb 22 13:54:44 GMT 2020

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

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

Back to the top