Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Applying CSS to NatTable
Applying CSS to NatTable [message #1061400] Fri, 31 May 2013 13:18 Go to next message
Raptor X is currently offline Raptor XFriend
Messages: 34
Registered: November 2012
Member

Hi,

We are using NatTable in our application and want to apply styles on it using CSS.
Currently, is there any built-in support for applying CSS on NatTable? if not than what is the best way to do this.


Thanks
Re: Applying CSS to NatTable [message #1061450 is a reply to message #1061400] Fri, 31 May 2013 16:22 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2903
Registered: July 2012
Senior Member
No we do not support CSS styling in NatTable at the moment. There is an open feature request to add that support.

What do you need to add CSS support? Well I guess you need an engine that is able to read a CSS file and translates it into NatTable styles. You would also need to specify NatTable specific styles like for example the eclipse or JavaFX styles. And there needs to be a way to put those styles into the NatTable ConfigRegistry.

We provide sponsored developments if you are interested.

Greez,
Dirk
Re: Applying CSS to NatTable [message #1061589 is a reply to message #1061450] Mon, 03 June 2013 07:45 Go to previous messageGo to next message
Raptor X is currently offline Raptor XFriend
Messages: 34
Registered: November 2012
Member
So, one option is that we use something like CSS engine for getting styles from CSS file and set the colors/styles in TableStyle. But in this case, we will have to recreate the table if CSS values are changed at runtime? ,because TableStyle is applied once during the creation of the table..


Thanks,
Asim
Re: Applying CSS to NatTable [message #1061592 is a reply to message #1061589] Mon, 03 June 2013 07:56 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2903
Registered: July 2012
Senior Member
No, it is possible to register/unregister styles at runtime. Only adding new configurations is causing issues with the current architecture AFAIK.

I already implemented functionality in other projects that support changing of styles at runtime, and NatTable even has a dialog to change styles interactively. So that shouldn't be an issue.
Re: Applying CSS to NatTable [message #1061647 is a reply to message #1061400] Mon, 03 June 2013 11:47 Go to previous messageGo to next message
Raptor X is currently offline Raptor XFriend
Messages: 34
Registered: November 2012
Member

Thanks you.

I am already applying dynamic styling to rows and columns by registering config attributes at runtime based on labels.

But, my concern is to change those styles that we specify in TableStyles like tableStyle.evenRowCellSelectionBgColor etc.. This technique hide the internal complexities of dealing with configurations. For example at runtime I want to do something like

tableStyle.evenRowCellSelectionBgColor = Color
Re: Applying CSS to NatTable [message #1061652 is a reply to message #1061647] Mon, 03 June 2013 11:59 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2903
Registered: July 2012
Senior Member
That's what the CSS engine would need to do. Check if the CSS has changed, and if so apply the new styles
Re: Applying CSS to NatTable [message #1061655 is a reply to message #1061652] Mon, 03 June 2013 12:10 Go to previous messageGo to next message
Raptor X is currently offline Raptor XFriend
Messages: 34
Registered: November 2012
Member
But in this case I will have to recreate the table because, if I am not wrong tablestyles are applied during table creation
Re: Applying CSS to NatTable [message #1061660 is a reply to message #1061655] Mon, 03 June 2013 12:20 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2903
Registered: July 2012
Senior Member
Quote:
No, it is possible to register/unregister styles at runtime


configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, myStyle, DisplayMode.NORMAL, myLabel);

configRegistry.unregisterConfigAttribute(CellConfigAttributes.CELL_STYLE, DisplayMode.NORMAL, myLabel);
Re: Applying CSS to NatTable [message #1061667 is a reply to message #1061660] Mon, 03 June 2013 12:31 Go to previous messageGo to next message
Raptor X is currently offline Raptor XFriend
Messages: 34
Registered: November 2012
Member

Dirk I am sorry I am unable to communicate properly.

You are talking about registering cell styles based on labels at runtime. I am aware of this but I am asking whether the following will work at runtime

tableStyle.evenRowCellSelectionBgColor = newColor

Suppose I don't have labels and cells styles, I just want to change evenRowCellSelectionBgColor at runtime without using config registry.

Re: Applying CSS to NatTable [message #1061671 is a reply to message #1061667] Mon, 03 June 2013 12:48 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2903
Registered: July 2012
Senior Member
Quote:
Suppose I don't have labels and cells styles


If you are using the NatTable even/odd row coloring than you do! Even if you don't know it.

Everything in NatTable is configured via ConfigRegistry! There is no way around it!

The color for the even row is an attribute of the style that is registered for the EVEN_ROW_CONFIG_TYPE label. If you have a reference to that style you should be able to change the value of the attribute at runtime. Maybe you need to refresh after the change.
Re: Applying CSS to NatTable [message #1061846 is a reply to message #1061671] Tue, 04 June 2013 10:54 Go to previous messageGo to next message
Raptor X is currently offline Raptor XFriend
Messages: 34
Registered: November 2012
Member
Thanks very much Smile
Re: Applying CSS to NatTable [message #1062186 is a reply to message #1061846] Thu, 06 June 2013 12:44 Go to previous messageGo to next message
Raptor X is currently offline Raptor XFriend
Messages: 34
Registered: November 2012
Member

So now I am done with the part of creating the configurations and adding them

Get styles -> create configurations -> addConfiguration

But now I want to take it one level above. In css we define an element for each control, for example in css I say set background color of all composites to black, thats it and we don't need to do anything else and application itself appky style to all the composites.

But in case of nattable we will have to apply configurations manually.

Read CSS -> MISSING PART -> create configurations -> addConfiguration


I am confused about the above missing part. I need to do something like this

if( nattable )
{
apply styles manually
}



Any suggestion?
Re: Applying CSS to NatTable [message #1062319 is a reply to message #1062186] Fri, 07 June 2013 07:52 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2903
Registered: July 2012
Senior Member
Sorry, I don't understand the question or even what you are trying to do now
Re: Applying CSS to NatTable [message #1062351 is a reply to message #1062319] Fri, 07 June 2013 11:02 Go to previous messageGo to next message
Raptor X is currently offline Raptor XFriend
Messages: 34
Registered: November 2012
Member
I want to listen to theme change event of the eclipse application in which my nattable is embedded. Every time theme is changed I need to create and load new configurations for the nattable based on the CSS styles. What is the proper way to do this?
Re: Applying CSS to NatTable [message #1062354 is a reply to message #1062351] Fri, 07 June 2013 11:05 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2903
Registered: July 2012
Senior Member
Ah ok ... you don't need to create new configurations. You should modify the existing configurations by registering/unregistering config attributes in the ConfigRegistry at runtime as I suggested some posts ago.

So you need to hold the reference to your ConfigRegistry and operate on it on theme switches.
Previous Topic:Issue with tree grid in 1.0.0
Next Topic:Multi-cell editing changes between 0.9.0 and 1.0.0
Goto Forum:
  


Current Time: Sun Nov 10 17:50:24 GMT 2024

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

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

Back to the top