Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Ignore CSS for some Widgets
Ignore CSS for some Widgets [message #889729] Tue, 19 June 2012 14:18 Go to next message
Quang Tran is currently offline Quang TranFriend
Messages: 25
Registered: June 2012
Junior Member
Hi,
we have in our Application some Labels which shows depending on a state the text in green or red (background)
This doesn't harmonise with the CSS Binding in E4, because we set the background before the CSS Databinding is running.
So the text, at first creation, no matter in what state we are, is the default color defined in CSS.
I did a workaround by adding a paint listener to the label.
label.addListener( SWT.Paint, new Listener() {

            @Override
            public void handleEvent(final Event event) {
                if( isActive ) {
                    label.setBackground( green );
                } else {
                    label.setBackground( red );
                }
            }
        } );


But I don't like this solution, is there any other way?
Re: Ignore CSS for some Widgets [message #889803 is a reply to message #889729] Tue, 19 June 2012 17:20 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 242
Registered: July 2009
Senior Member
Quang Tran wrote on Tue, 19 June 2012 10:18

This doesn't harmonise with the CSS Binding in E4, because we set the background before the CSS Databinding is running.


Could you expand on this, please? Why isn't the CSS theme running?

Quote:
But I don't like this solution, is there any other way?


I can think of a couple of approaches:

1. Ensure the CSS engine is started before you create your GUI. The CSS is applied quickly -- I've never seen any flash from it being applied after the UI has been rendered.

2. Explicitly query the CSS Engine to calculate the CSS property values that are to be applied to your table (see WidgetElement.getCSSEngine() and CSSEngine.getViewCSS()) and use those values to populate the foreground and background.

Brian.
Re: Ignore CSS for some Widgets [message #889906 is a reply to message #889729] Wed, 20 June 2012 08:14 Go to previous messageGo to next message
Quang Tran is currently offline Quang TranFriend
Messages: 25
Registered: June 2012
Junior Member
Here is another example why we need a function to ignore css for some widgets:
If you have a dark css theme and a part of your css file is defined as follows:

.MPartStack.active ExpandBar {
	background-color: #101010;
	color: black;
}

.MPartStack ExpandBar {
	background-color: #101010;
	color: black;
}

Label {
	font: Verdana 8px;
	color: white;
}

Composite Label {
	color: white;
}


And you have a viewpart, which shows the text color of the labels, depending on a state, in red or green. This does not work if your view loose the focus and gain it again later, because the label colors will be white again due to the CSS binding.

Quang

[Updated on: Wed, 20 June 2012 08:15]

Report message to a moderator

Re: Ignore CSS for some Widgets [message #889941 is a reply to message #889906] Wed, 20 June 2012 10:25 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Am 20.06.12 10:14, schrieb Quang Tran:
> Here is another example why we need a function to ignore css for some
> widgets:
> If you have a dark css theme and a part of your css file is defined as
> follows:
>
>
> MPartStack.active ExpandBar {
> background-color: #101010;
> color: black;
> }
>
> MPartStack ExpandBar {
> background-color: #101010;
> color: black;
> }
>
> Label {
> font: Verdana 8px;
> color: white;
> }
>
> Composite Label {
> color: white;
> }
>
> And you have a viewpart, which shows the text color of the labels,
> depending on a state, in red or green. This does not work if your view
> loose the focus and gain it again later, because the labels will be in
> white again due to the CSS binding.
>
> Quang

Why are you need creating a CSS-Rule for highlighted labels?


Current-Code:
-------------
Label l = ...
l.setForegroundColor(....)


CSS/Java-Code:
---------
Css:
Label.highlight {
color: red;
}

Java:
IStylingEngine se = ...
Label l = ...
se.setClassname("highlighted");



Tom
Re: Ignore CSS for some Widgets [message #891505 is a reply to message #889729] Mon, 25 June 2012 06:14 Go to previous message
Quang Tran is currently offline Quang TranFriend
Messages: 25
Registered: June 2012
Junior Member
Hi Tom,

Quote:
Why are you need creating a CSS-Rule for highlighted labels?


What do you mean by that?


Current-Code:
-------------
Label l = ...
l.setForegroundColor(....)


CSS/Java-Code:
---------
Css:
Label.highlight {
color: red;
}

Java:
IStylingEngine se = ...
Label l = ...
se.setClassname("highlighted");


this seems like a good solution for us, thanks!
Previous Topic:Updating fails 4.2.0 - I20120315-1300 [SOLVED -THANKS]
Next Topic:EModelService findElement()
Goto Forum:
  


Current Time: Tue Apr 23 12:18:54 GMT 2024

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

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

Back to the top