Search in sources :

Example 26 with CSSStyleDeclaration

use of org.w3c.dom.css.CSSStyleDeclaration in project kie-wb-common by kiegroup.

the class SVGStyleTranslator method parseElementStyleDefinition.

private static StyleDefinition parseElementStyleDefinition(final String styleRaw) throws TranslatorException {
    final CSSStyleSheetImpl sheet = parseElementStyleSheet(styleRaw);
    final CSSRuleList cssRules = sheet.getCssRules();
    for (int i = 0; i < cssRules.getLength(); i++) {
        final CSSRule item = cssRules.item(i);
        if (CSSRule.STYLE_RULE == item.getType()) {
            final CSSStyleRuleImpl rule = (CSSStyleRuleImpl) item;
            final CSSStyleDeclaration declaration = rule.getStyle();
            return parseStyleDefinition(declaration);
        }
    }
    return null;
}
Also used : CSSRule(org.w3c.dom.css.CSSRule) CSSStyleSheetImpl(com.steadystate.css.dom.CSSStyleSheetImpl) CSSStyleRuleImpl(com.steadystate.css.dom.CSSStyleRuleImpl) CSSStyleDeclaration(org.w3c.dom.css.CSSStyleDeclaration) CSSRuleList(org.w3c.dom.css.CSSRuleList)

Example 27 with CSSStyleDeclaration

use of org.w3c.dom.css.CSSStyleDeclaration 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 28 with CSSStyleDeclaration

use of org.w3c.dom.css.CSSStyleDeclaration 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

CSSStyleDeclaration (org.w3c.dom.css.CSSStyleDeclaration)28 CSSRule (org.w3c.dom.css.CSSRule)17 CSSRuleList (org.w3c.dom.css.CSSRuleList)17 CSSValue (org.w3c.dom.css.CSSValue)17 CSSStyleSheet (org.w3c.dom.css.CSSStyleSheet)15 ICSSModel (org.eclipse.wst.css.core.internal.provisional.document.ICSSModel)14 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)14 CSSPageRule (org.w3c.dom.css.CSSPageRule)6 CSSStyleRule (org.w3c.dom.css.CSSStyleRule)5 CSSValueList (org.w3c.dom.css.CSSValueList)5 ICSSNode (org.eclipse.wst.css.core.internal.provisional.document.ICSSNode)4 CSSFontFaceRule (org.w3c.dom.css.CSSFontFaceRule)4 ICSSStyleDeclItem (org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclItem)3 CSSStyleRuleImpl (com.steadystate.css.dom.CSSStyleRuleImpl)2 CSSStyleSheetImpl (com.steadystate.css.dom.CSSStyleSheetImpl)2 IThemeEngine (org.eclipse.e4.ui.css.swt.theme.IThemeEngine)2 IThemeManager (org.eclipse.e4.ui.css.swt.theme.IThemeManager)2 Shell (org.eclipse.swt.widgets.Shell)2 ICSSValue (org.eclipse.wst.css.core.internal.provisional.document.ICSSValue)2 BundleContext (org.osgi.framework.BundleContext)2