List of usage examples for org.w3c.dom.css CSSValue getCssText
public String getCssText();
From source file:com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleDeclaration.java
/** * Gets the CSS property value./*from w ww. j a v a 2 s. c om*/ * @param name the name of the property to retrieve * @return the value */ @JsxFunction(@WebBrowser(FF)) public CSSValue getPropertyCSSValue(final String name) { LOG.info("getPropertyCSSValue(" + name + "): getPropertyCSSValue support is experimental"); // following is a hack, just to have basic support for getPropertyCSSValue // TODO: rework the whole CSS processing here! we should *always* parse the style! if (styleDeclaration_ == null) { final String uri = getDomNodeOrDie().getPage().getWebResponse().getWebRequest().getUrl() .toExternalForm(); final String styleAttribute = jsElement_.getDomNodeOrDie().getAttribute("style"); final InputSource source = new InputSource(new StringReader(styleAttribute)); source.setURI(uri); final ErrorHandler errorHandler = getWindow().getWebWindow().getWebClient().getCssErrorHandler(); final CSSOMParser parser = new CSSOMParser(new SACParserCSS3()); parser.setErrorHandler(errorHandler); try { styleDeclaration_ = parser.parseStyleDeclaration(source); } catch (final IOException e) { throw new RuntimeException(e); } } org.w3c.dom.css.CSSValue cssValue = styleDeclaration_.getPropertyCSSValue(name); if (cssValue == null) { final CSSValueImpl newValue = new CSSValueImpl(); newValue.setFloatValue(CSSPrimitiveValue.CSS_PX, 0); cssValue = newValue; } // FF has spaces next to "," final String cssText = cssValue.getCssText(); if (cssText.startsWith("rgb(")) { final String formatedCssText = StringUtils.replace(cssText, ",", ", "); cssValue.setCssText(formatedCssText); } return new CSSPrimitiveValue(jsElement_, (org.w3c.dom.css.CSSPrimitiveValue) cssValue); }
From source file:org.talend.themes.core.elements.handlers.TalendTabbedPropertyUserProfileCSSHandler.java
@Override protected void applyCSSProperty(Control control, String property, CSSValue value, String pseudo, CSSEngine engine) throws Exception { if (control instanceof ITalendTabbedPropertyListWidget) { ITalendTabbedPropertyListWidget userProfileWidget = (ITalendTabbedPropertyListWidget) control; TalendTabbedPropertyColorHelper colorHelper = userProfileWidget.getColorHelper(); if (value != null && CSSValue.CSS_PRIMITIVE_VALUE == value.getCssValueType()) { RGB newColor = ((Color) engine.convert(value, Color.class, control.getDisplay())).getRGB(); if (WIDGET_FOREGROUND_COLOR.equalsIgnoreCase(property)) { colorHelper.setWidgetForeground(CommonCSSStyleSetting.getColorByRGB(newColor)); }//from w w w. j av a 2 s . c o m if (WIDGET_BACKGROUND_COLOR.equalsIgnoreCase(property)) { colorHelper.setWidgetBackground(CommonCSSStyleSetting.getColorByRGB(newColor)); } if (WIDGET_NORMAL_SHADOW_COLOR.equalsIgnoreCase(property)) { colorHelper.setWidgetNormalShadow(CommonCSSStyleSetting.getColorByRGB(newColor)); } if (WIDGET_DARK_SHADOW_COLOR.equalsIgnoreCase(property)) { colorHelper.setWidgetDarkShadow(CommonCSSStyleSetting.getColorByRGB(newColor)); } if (WIDGET_VERTICAL_LINE_COLOR.equalsIgnoreCase(property)) { colorHelper.setWidgetVerticalLineColor(CommonCSSStyleSetting.getColorByRGB(newColor)); } if (LIST_BACKGROUND_COLOR.equalsIgnoreCase(property)) { colorHelper.setListBackground(CommonCSSStyleSetting.getColorByRGB(newColor)); } if (BORDER_VISIBLE.equalsIgnoreCase(property)) { String isVisibleBorderValue = value.getCssText(); if (StringUtils.isNotEmpty(isVisibleBorderValue)) { boolean isVisibleBorder = Boolean.parseBoolean(isVisibleBorderValue); if (colorHelper.isVisibleBorder() != isVisibleBorder) { colorHelper.setVisibleBorder(isVisibleBorder); } } } if (WIDGET_IS_SHOW_NORMAL_SHADOW.equalsIgnoreCase(property)) { String isShowNormalShadowValue = value.getCssText(); if (StringUtils.isNotEmpty(isShowNormalShadowValue)) { boolean isShowNormalShadow = Boolean.parseBoolean(isShowNormalShadowValue); if (colorHelper.isShowNormalShadow() != isShowNormalShadow) { colorHelper.setShowNormalShadow(isShowNormalShadow); } } } } } if (control instanceof ITalendTabbedPropertyTitleWidget) { ITalendTabbedPropertyTitleWidget tabbedPropertyTitle = (ITalendTabbedPropertyTitleWidget) control; TalendTabbedPropertyColorHelper colorHelper = tabbedPropertyTitle.getColorHelper(); if (value != null && CSSValue.CSS_PRIMITIVE_VALUE == value.getCssValueType()) { RGB newColor = ((Color) engine.convert(value, Color.class, control.getDisplay())).getRGB(); if (TITLE_FOREGROUND_COLOR.equalsIgnoreCase(property)) { colorHelper.setTitleForeground(CommonCSSStyleSetting.getColorByRGB(newColor)); } if (TITLE_BACKGROUND_COLOR.equalsIgnoreCase(property)) { colorHelper.setTitleBackground(CommonCSSStyleSetting.getColorByRGB(newColor)); } if (TITLE_BOTTOM_FOREGROUND_KEYLINE1_COLOR.equalsIgnoreCase(property)) { colorHelper.setTitleBottomForegroundKeyline1(CommonCSSStyleSetting.getColorByRGB(newColor)); } if (TITLE_BOTTOM_FOREGROUND_KEYLINE2_COLOR.equalsIgnoreCase(property)) { colorHelper.setTitleBottomForegroundKeyline2(CommonCSSStyleSetting.getColorByRGB(newColor)); } if (BORDER_VISIBLE.equalsIgnoreCase(property)) { String isVisibleBorderValue = value.getCssText(); if (isVisibleBorderValue != null) { boolean isVisibleBorder = Boolean.parseBoolean(isVisibleBorderValue); if (!isVisibleBorder) { colorHelper.setVisibleBorder(isVisibleBorder); } } } } } }