Skip to main content



      Home
Home » Eclipse Projects » JFace » How to draw hyperlink in TreeViewer column?
How to draw hyperlink in TreeViewer column? [message #655622] Mon, 21 February 2011 20:16 Go to next message
Eclipse UserFriend
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

[Updated on: Mon, 21 February 2011 20:19] by Moderator

icon3.gif  Re: How to draw hyperlink in TreeViewer column? [message #655831 is a reply to message #655622] Tue, 22 February 2011 13:33 Go to previous message
Eclipse UserFriend
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.
Previous Topic:Background Image Adjustment in TreeViewer/Control
Next Topic:TextViewer and scroll down
Goto Forum:
  


Current Time: Wed Jul 23 06:05:40 EDT 2025

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

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

Back to the top