Example usage for org.w3c.dom.css CSSValue getCssValueType

List of usage examples for org.w3c.dom.css CSSValue getCssValueType

Introduction

In this page you can find the example usage for org.w3c.dom.css CSSValue getCssValueType.

Prototype

public short getCssValueType();

Source Link

Document

A code defining the type of the value as defined above.

Usage

From source file:org.akrogen.tkui.css.swt.properties.css2.CSSPropertyBackgroundSWTHandler.java

@Override
public void applyCSSPropertyBackgroundColor(Object element, CSSValue value, String pseudo, CSSEngine engine)
        throws Exception {
    Control control = (Control) element;
    if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
        Color newColor = (Color) engine.convert(value, Color.class, control.getDisplay());
        if (control instanceof CTabFolder && "selected".equals(pseudo)) {
            ((CTabFolder) control).setSelectionBackground(newColor);
        } else {//from ww w . ja v a 2  s .  c o  m
            control.setBackground(newColor);
        }
    } else if (value.getCssValueType() == CSSValue.CSS_VALUE_LIST) {
        Gradient grad = (Gradient) engine.convert(value, Gradient.class, control.getDisplay());
        GradientBackgroundListener.handle(control, grad);
    }
}

From source file:org.akrogen.tkui.css.swt.properties.css2.CSSPropertyClassificationSWTHandler.java

@Override
public void applyCSSPropertyCursor(Object element, CSSValue value, String pseudo, CSSEngine engine)
        throws Exception {
    if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
        final Control control = (Control) element;
        Cursor cursor = (Cursor) engine.convert(value, Cursor.class, control.getDisplay());
        control.setCursor(cursor);/*from w ww.  j  a  v a2s .  c  o  m*/
    }
}

From source file:org.akrogen.tkui.css.swt.properties.css2.CSSPropertyClassificationSWTHandler.java

@Override
public void applyCSSPropertyVisibility(Object element, CSSValue value, String pseudo, CSSEngine engine)
        throws Exception {
    if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
        Control control = (Control) element;
        CSSPrimitiveValue primitiveValue = (CSSPrimitiveValue) value;
        String visibility = primitiveValue.getStringValue();
        if ("hidden".equals(visibility))
            control.setVisible(false);/*from  w w  w  .j a  va2s . c o m*/
        else if ("collapse".equals(visibility)) {
            // TODO : manage collapse
            control.setVisible(false);
        } else
            control.setVisible(true);
    }
}

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  .ja v  a2  s.  c om*/
            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);
                    }
                }
            }
        }
    }
}