Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-ui-dev] Question regarding theming

Well, you can reset the color as you were doing first and the apply the style later (so, if it's a no-op it'd work ok).

The other choice as Leo pointed would be using a color from the preferences (although I can see it being an issue if the user does edit that particular preference to another color out of the themeing and it ends up changing your unrelated control too).

Best Regards,

Fabio

On Wed, Jun 28, 2017 at 12:03 PM, Becker, Matthias <ma.becker@xxxxxxx> wrote:

Dear Fabio,

 

I just tested this. This works fine if one of the CSS-Themes is selected. In this case themeEngine.applyStyles(control, applyToChildren); does set the color back.

 

But, if I use the “Light” Theme on my mac (which is the default) the colors that are set via setForeground/setBackground are not reset when calling themeEngine.applyStyles(control, applyToChildren);

That’s because in CSSSWTEngineImpl(AbstractCSSEngine).applyStyles(Object, boolean, boolean)  the “style” variable in CSSStyleDeclaration style = viewCSS.getComputedStyle(elt, null); is null.

So the method basically does nothing.

 

Any ideas how to solve this?

 

Regards,

Matthias

 

From: <platform-ui-dev-bounces@eclipse.org> on behalf of Fabio Zadrozny <fabiofz@xxxxxxxxx>
Reply-To: "Eclipse Platform UI component developers list." <platform-ui-dev@xxxxxxxxxxx>
Date: Wednesday, 28. June 2017 at 15:04


To: "Eclipse Platform UI component developers list." <platform-ui-dev@xxxxxxxxxxx>
Subject: Re: [platform-ui-dev] Question regarding theming

 

For me that's:

 

    public static IWorkbenchWindow getActiveWorkbenchWindow() {

        if (!PlatformUI.isWorkbenchRunning()) {

            return null;

        }

        IWorkbench workbench = PlatformUI.getWorkbench();

        if (workbench == null) {

            return null;

        }

        return workbench.getActiveWorkbenchWindow();

    }

 

Yes, it's optional... you should be able to just do:

 

IThemeEngine themeEngine = (IThemeEngine) Display.getDefault().getData("org.eclipse.e4.ui.css.swt.theme");

themeEngine.applyStyles(control, applyToChildren);

 

(so far I only use that when I set some id to a given widget and have it reskinned after the ID is set, but this is just my use-case... for resetting the skin, only the applyStyles is needed).

 

I also agree about having some official API to set id/reskin... it's been in provisional state for quite a while, so, 4.8 may be a good point to start committing to some API in the themeing (probably not all of it, but some basic functions could definitely be available).

 

Best Regards,

 

Fabio

 

 

On Wed, Jun 28, 2017 at 9:46 AM, Becker, Matthias <ma.becker@xxxxxxx> wrote:

Dear Fabio,

 

thanks for your answer. In the below code snippet, there you use a class called “UIUtils”. This does not seem to be part of the eclipse platform code.

What does UIUtils.getActiveWorkbenchWindow() do?

 

Is the engine.setId(control, id); call optional?

 

If this is the “preferred” way then we should think about providing something similar as official API.

 

Regards,

Matthias

 

Matthias Becker

Development, PI Tech Core ABAP Server (SE)

SAP SE, Dietmar-Hopp-Allee 16, 69190 Walldorf, Germany

 

T +49 6227 7-60223, M +49 151 53858523, E ma.becker@xxxxxxx

 

 

Pflichtangaben/Mandatory Disclosure Statement:

http://www.sap.com/company/legal/impressum.epx/

 

Diese E-Mail kann Betriebs- oder Geschäftsgeheimnisse oder sonstige vertrauliche Informationen enthalten. Sollten Sie diese E-Mail irrtümlich erhalten haben, ist Ihnen eine Kenntnisnahme des Inhalts, eine Vervielfältigung oder Weitergabe der E-Mail ausdrücklich untersagt. Bitte benachrichtigen Sie uns und vernichten Sie die empfangene E-Mail. Vielen Dank.

 

This e-mail may contain trade secrets or privileged, undisclosed, or otherwise confidential information. If you have received this e-mail in error, you are hereby notified that any review, copying, or distribution of it is strictly prohibited. Please inform us immediately and destroy the original transmittal. Thank you for your cooperation.

 

 

From: <platform-ui-dev-bounces@eclipse.org> on behalf of Fabio Zadrozny <fabiofz@xxxxxxxxx>
Reply-To: "Eclipse Platform UI component developers list." <platform-ui-dev@xxxxxxxxxxx>
Date: Wednesday, 28. June 2017 at 13:02
To: "Eclipse Platform UI component developers list." <platform-ui-dev@xxxxxxxxxxx>
Subject: Re: [platform-ui-dev] Question regarding theming

 

Hi Matthias,

 

Not sure if there's a better way, but you can ask any control to be reskinned by using:

 

IThemeEngine themeEngine = (IThemeEngine) Display.getDefault().getData("org.eclipse.e4.ui.css.swt.theme");

themeEngine.applyStyles(control, applyToChildren);

 

On PyDev I have a utility method that does:

 

    @SuppressWarnings("restriction")

    public static void setCssId(Object control, String id, boolean applyToChildren) {

        IStylingEngine engine = (IStylingEngine) UIUtils.getActiveWorkbenchWindow().

                getService(IStylingEngine.class);

        if (engine != null) {

            engine.setId(control, id);

            IThemeEngine themeEngine = (IThemeEngine) Display.getDefault().getData(

                    "org.eclipse.e4.ui.css.swt.theme");

            themeEngine.applyStyles(control, applyToChildren);

        }

    }

 

So, you can set a given id to some widget (so that you can use specific selectors on the css theme) and ask it to be reskinned...

 

The only annoying thing is that org.eclipse.e4.ui.css.swt.theme.IThemeEngine is not considered to be an API... when I added that code back in 2013 I'm sure there wasn't a better way, but maybe someone else can provide a better API today?

 

Cheers,

 

Fabio

 


_______________________________________________
platform-ui-dev mailing list
platform-ui-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/platform-ui-dev

 


_______________________________________________
platform-ui-dev mailing list
platform-ui-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/platform-ui-dev


Back to the top