Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Overriding CSS styling in RCP(Once a generic css style is applied, the programmatic .setXX do no longer work)
Overriding CSS styling in RCP [message #1746069] Fri, 21 October 2016 09:25 Go to next message
Matthias Nowak is currently offline Matthias NowakFriend
Messages: 2
Registered: May 2016
Junior Member
CSS works nice. I can per default set the background of all Text widgets to white:
Text {
background-color: #ffffff;
}

If I now create my widgets in a @PostConstruct function and set the background color according to values (red== outside bounds) then those changes are not visible. My guess is that right after the creation and visualization of the part, the style engine is applied and overrides those values.

I tried to change the background color in a delayed function (timeExec...) and the background color changes. The changed background color is visible until focus or similar changes, and the style engine overrides my values.

From the inspection of the code, there is no possibility to stop the style engine at one place in the widget hierarchy. There is probably no possibility in SWT to set the "default" values for each widget, hence styling has to be applied to the current values. CSS styling would in this case also stop decorators from working.

I'm not sure how CSS is supposed to work together with the programmatic setting of colors and similar.
Re: Overriding CSS styling in RCP [message #1746116 is a reply to message #1746069] Sat, 22 October 2016 09:09 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2602
Registered: July 2012
Senior Member
The css engine frequently applies style options at runtime to support dynamic styling. So it doesn't work in combination with programmatic styling as such settings will be overwritten constantly
Re: Overriding CSS styling in RCP [message #1746154 is a reply to message #1746116] Mon, 24 October 2016 07:40 Go to previous messageGo to next message
Matthias Nowak is currently offline Matthias NowakFriend
Messages: 2
Registered: May 2016
Junior Member
Yes, this was my impression how it works. However, it would be nice, if one could protect a widget subtree from the general styling. This is useful for tables, where one likes to color the background according to the values. The applyStyles function could check a certain attribute and jump over the widget having this attribute and its children. It could be something like widget.setData("noCss", Boolean.True); .
Re: Overriding CSS styling in RCP [message #1746181 is a reply to message #1746154] Mon, 24 October 2016 16:02 Go to previous message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 756
Registered: January 2012
Senior Member

You accomplish this as you would in the HTML world: via widget classes.

Your CSS:
Text {
   color: black;
   background: white;
}
Text#error {
   color: white;
   background: red;
}

In your Java code:
WidgetElement.setCSSClass(textWidget, "error");


Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Previous Topic:Launch e4 RCP application by code?
Next Topic:splash.bmp
Goto Forum:
  


Current Time: Wed Jun 20 00:31:01 GMT 2018

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

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

Back to the top