Search in sources :

Example 1 with IThemeManager

use of org.eclipse.e4.ui.css.swt.theme.IThemeManager in project archi by archimatetool.

the class GeneralPreferencePage method init.

public void init(IWorkbench workbench) {
    // e4 method (taken from org.eclipse.ui.internal.dialogs.ViewsPreferencePage init(IWorkbench))
    MApplication application = workbench.getService(MApplication.class);
    IEclipseContext context = application.getContext();
    // This is "org.eclipse.e4.ui.css.theme.e4_default" //$NON-NLS-1$
    fDefaultTheme = (String) context.get("cssTheme");
    fThemeEngine = context.get(IThemeEngine.class);
    fCurrentTheme = fThemeEngine.getActiveTheme();
/*
        // e3 method
        Bundle bundle = FrameworkUtil.getBundle(ArchiPlugin.class);
        BundleContext context = bundle.getBundleContext();
        ServiceReference<IThemeManager> ref = context.getServiceReference(IThemeManager.class);
        IThemeManager themeManager = context.getService(ref);
        fThemeEngine = themeManager.getEngineForDisplay(Display.getCurrent());
        fDefaultTheme = "org.eclipse.e4.ui.css.theme.e4_default"; //$NON-NLS-1$
*/
}
Also used : IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) IThemeEngine(org.eclipse.e4.ui.css.swt.theme.IThemeEngine) MApplication(org.eclipse.e4.ui.model.application.MApplication)

Example 2 with IThemeManager

use of org.eclipse.e4.ui.css.swt.theme.IThemeManager in project dbeaver by serge-rider.

the class E4ThemeColor method getCssValueFromTheme.

public static String getCssValueFromTheme(Display display, String value) {
    // use reflection so that this can build against Eclipse 3.x
    BundleContext context = FrameworkUtil.getBundle(E4ThemeColor.class).getBundleContext();
    ServiceReference<IThemeManager> reference = context.getServiceReference(IThemeManager.class);
    if (reference != null) {
        IThemeManager iThemeManager = context.getService(reference);
        if (iThemeManager != null) {
            IThemeEngine themeEngine = iThemeManager.getEngineForDisplay(display);
            if (themeEngine != null) {
                CSSStyleDeclaration shellStyle = getStyleDeclaration(themeEngine, display);
                if (shellStyle != null) {
                    CSSValue cssValue = shellStyle.getPropertyCSSValue(value);
                    if (cssValue != null) {
                        return cssValue.getCssText();
                    }
                }
            }
        }
    }
    return null;
}
Also used : CSSValue(org.w3c.dom.css.CSSValue) IThemeEngine(org.eclipse.e4.ui.css.swt.theme.IThemeEngine) IThemeManager(org.eclipse.e4.ui.css.swt.theme.IThemeManager) CSSStyleDeclaration(org.w3c.dom.css.CSSStyleDeclaration) BundleContext(org.osgi.framework.BundleContext)

Example 3 with IThemeManager

use of org.eclipse.e4.ui.css.swt.theme.IThemeManager in project dbeaver by dbeaver.

the class E4ThemeColor method getCssValueFromTheme.

public static String getCssValueFromTheme(Display display, String value) {
    // use reflection so that this can build against Eclipse 3.x
    BundleContext context = FrameworkUtil.getBundle(E4ThemeColor.class).getBundleContext();
    ServiceReference<IThemeManager> reference = context.getServiceReference(IThemeManager.class);
    if (reference != null) {
        IThemeManager iThemeManager = context.getService(reference);
        if (iThemeManager != null) {
            IThemeEngine themeEngine = iThemeManager.getEngineForDisplay(display);
            if (themeEngine != null) {
                CSSStyleDeclaration shellStyle = getStyleDeclaration(themeEngine, display);
                if (shellStyle != null) {
                    CSSValue cssValue = shellStyle.getPropertyCSSValue(value);
                    if (cssValue != null) {
                        return cssValue.getCssText();
                    }
                }
            }
        }
    }
    return null;
}
Also used : CSSValue(org.w3c.dom.css.CSSValue) IThemeEngine(org.eclipse.e4.ui.css.swt.theme.IThemeEngine) IThemeManager(org.eclipse.e4.ui.css.swt.theme.IThemeManager) CSSStyleDeclaration(org.w3c.dom.css.CSSStyleDeclaration) BundleContext(org.osgi.framework.BundleContext)

Aggregations

IThemeEngine (org.eclipse.e4.ui.css.swt.theme.IThemeEngine)3 IThemeManager (org.eclipse.e4.ui.css.swt.theme.IThemeManager)2 BundleContext (org.osgi.framework.BundleContext)2 CSSStyleDeclaration (org.w3c.dom.css.CSSStyleDeclaration)2 CSSValue (org.w3c.dom.css.CSSValue)2 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)1 MApplication (org.eclipse.e4.ui.model.application.MApplication)1