Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Dynamic conditional highlighting(Is it possible to dynamically add Excel-like conditional highlighting?)
Dynamic conditional highlighting [message #1693629] Mon, 27 April 2015 06:57 Go to next message
Michael Gerlich is currently offline Michael GerlichFriend
Messages: 2
Registered: April 2015
Junior Member
Hi all,

I'm currently investigating if NatTable would be a suitable replacement for our current SWT/JFace TableViewers. In fact, the NatTable examples are really promising and I already could mimic some tables with NatTable.

I was wondering if it is possible to add some conditional highlighting based on a range of data. Like numeric values <= 100 are red, values between 101 and 150 are yellow and everything >151 would be green.
Currently, I only saw examples (and could modify them to my needs) where exact values are highlighted, which is fine if there aren't that many different values or they are backed by an enumeration.
But could this labeling system also deal with ranges of data values like my example before?

In addition, as all labeling/layers need to be registered prior to configuring the NatTable, the only way I could currently think of to make things work would be to keep some sort of "label stack" which stores the user defined labels and then disposes & reconfigures the NatTable again every time a label is added, deleted or modified.
So if in the above example the values for <= 100 should be blue, then one would need to remove/modify the existing label for red and re-iterate all values.

Would this be the only way for many different numeric values to provide conditional highlighting or am I missing something?


All the best,
Michael
Re: Dynamic conditional highlighting [message #1693704 is a reply to message #1693629] Mon, 27 April 2015 17:03 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Sorry, I'm not sure if I understand your question.

First, of course it is possible to add dynamic conditional styling. Just implement and register a custom IConfigLabelAccumulator that fits your needs.
https://www.eclipse.org/nattable/documentation.php?page=styling
http://www.vogella.com/tutorials/NatTable/article.html#architecture_labels

If you speak German, there are also some articles about that in the Related Articles.

Typically there is no need for you to check the LabelStack and remove labels yourself, because for most of the styling configurations the first label in the stack wins. So LabelStack#addLabelOnTop(String) will usually override prior configurations.

I hope the links help in better understanding the configuration and label concepts in NatTable. Because your question doesn't make much sense when knowing about it. Wink

P.S. If you want to add support for users to add dynamic conditional stylings at runtime, you will need to implement some mechanisms that allow this. But you are able to add style configurations and labels at runtime. But that is some more advanced usage of NatTable. We even provide a style dialog for changing styling at runtime, but it doesn't support conditional styling.
Re: Dynamic conditional highlighting [message #1693909 is a reply to message #1693704] Wed, 29 April 2015 09:17 Go to previous message
Michael Gerlich is currently offline Michael GerlichFriend
Messages: 2
Registered: April 2015
Junior Member
Hello Dirk,

thank you for the additional documentation and explanation. Using the IConfigLabelAccumulator is a great hint. I'm really excited trying those things out.

All the best,
Michael
Previous Topic:object is not an instance of declaring class Problem in example _6042_TreeStructureGridExample
Next Topic:Problem with adding FilterRowHeaderComposite to CompositeLayer
Goto Forum:
  


Current Time: Thu Apr 25 16:37:58 GMT 2024

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

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

Back to the top