Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » How to draw hyperlink in TreeViewer column?
How to draw hyperlink in TreeViewer column? [message #655622] Tue, 22 February 2011 01:16 Go to next message
David Whiteman is currently offline David WhitemanFriend
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: Tue, 22 February 2011 01:19]

Report message to a moderator

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


Current Time: Wed Apr 24 23:17:57 GMT 2024

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

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

Back to the top