| How to draw hyperlink in TreeViewer column? [message #655622] |
Mon, 21 February 2011 20:16  |
David Whiteman Messages: 5 Registered: July 2009 Location: Research Triangle Park, N... |
Junior Member |
|
|
I'm trying to use a StyledString to draw text as if it were a hyperlink. I am doing this in the update() method of the column's label provider. It seems that simple methods on the ViewerCell such as setText(), setForeground(), and setFont() work as expected, but when I try to use setStyleRanges(), there is no effect.
Here's an excerpt:
Styler style = new Styler()
{
public void applyStyles(TextStyle textStyle)
{
textStyle.font = boldFont;
textStyle.foreground = display.getSystemColor(SWT.COLOR_BLUE);
textStyle.underline = true;
}
};
StyledString styledString = new StyledString(cell.getText(), style);
cell.setStyleRanges(styledString.getStyleRanges());
cell.setText(styledString.getString());
The style ranges appear to have no effect. The font, foreground, and underline settings are ignored, unlike when I call setFont() or setForeground() on the cell.
I also tried creating a StyleRange directly and set the characteristics that way, but still no luck in changing the cell's appearance.
Is style ranges simply unsupported by the TreeViewer?
I'm I going about this in too hard of a way? I just want to have hyperlink capability in one of the columns of my tree viewer.
Thanks in advance,
David
---
David Whiteman
Cisco Systems
[Updated on: Mon, 21 February 2011 20:19] Report message to a moderator
|
|
|
Re: How to draw hyperlink in TreeViewer column? [message #655831 is a reply to message #655622] |
Tue, 22 February 2011 13:33  |
David Whiteman Messages: 5 Registered: July 2009 Location: Research Triangle Park, N... |
Junior Member |
|
|
Apparently if your label provider subclasses ColumnLabelProvider, any style ranges you apply to the cell are ignored. I changed my label provide to subclass StyledCellLabelProvider, and now I can draw nice hyperlinked txt.
---
David Whiteman
Cisco Systems
|
|
|
Powered by
FUDForum. Page generated in 0.01438 seconds