Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » CSS styling a specific TreeItems text color(CSS styling TreeViewers and TreeItems)
CSS styling a specific TreeItems text color [message #1739016] Tue, 26 July 2016 20:21 Go to next message
Sean Horton is currently offline Sean HortonFriend
Messages: 7
Registered: June 2016
Junior Member
Hi guys,

I'm playing around with css styling and came across a problem I'm not sure how to solve.

We have a TreeViewer that has a custom css style set to it using WidgetElement.setCSSClass(), which is working great.

However, in the the TreeViewers ViewLabelProvider if the item is in a specific state we'd like to color that one specific items text color differently than the rest. For example, if we are showing a list of files in the TreeViewer and one of the files is deleted, we'd change that TreeItem to have 'red' text instead of 'black'.

This can be done in the ViewLabelProvider's update(ViewerCell cell) method by doing cell.setForeground(getSystemColor(SWT.COLOR_RED)); This works, but we'd like to remove the getSystemColor() call with a css styled color.

Another thing we tried was setting the css styling on the ViewerCell's item (a TreeItem). This would look like WidgetElement.setCSSClass(cell.getItem(), "someclass"); this had no effect in the ViewLabelProviders update(ViewerCell) method. It seemed the TreeItem was taking the values we set for the TreeViewers css.

Questions:
1) Can we read a color value directly from the css file without creating a widget, so we can set it directly using ViewerCell.setForeground(<color from css file>)?

2) Do TreeViewers support the changing of a single specific TreeItem using css styling?

Any help would be appreciated,
Thanks!

Re: CSS styling a specific TreeItems text color [message #1739022 is a reply to message #1739016] Wed, 27 July 2016 01:29 Go to previous messageGo to next message
Eclipse UserFriend
Your label provider can pick out information from CSS: check out the CSSRenderingUtils#getCSSValue() for how we do it internally.

Brian.
Re: CSS styling a specific TreeItems text color [message #1739153 is a reply to message #1739022] Wed, 27 July 2016 20:05 Go to previous message
Sean Horton is currently offline Sean HortonFriend
Messages: 7
Registered: June 2016
Junior Member
Thanks for responding!

I was able to get a working solution that followed similarly to CSSRenderingUtils#getCSSValue().

However, we ended up going with a similar approach to Vogella's custom CSS widgets here http://www.vogella.com/tutorials/Eclipse4CSS/article.html#css-support-for-custom-widgets

We set a custom css value that we then read from the TreeViewer itself.
Previous Topic:Need 64 bit version of GTK+ to Run SWT App on HPUX Itanium
Next Topic:Virtual machine lunch error
Goto Forum:
  


Current Time: Thu Mar 28 13:13:23 GMT 2024

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

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

Back to the top