Search in sources :

Example 1 with ICSSPrimitiveValue

use of org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue in project webtools.sourceediting by eclipse.

the class CSSStyleDeclItemImpl method setCssValueText.

/**
 * @param value
 *            java.lang.String
 * @exception org.w3c.dom.DOMException
 *                The exception description.
 */
public void setCssValueText(String value) throws DOMException {
    ICSSNode child = getFirstChild();
    while (child != null) {
        ICSSNode next = child.getNextSibling();
        if (child instanceof ICSSPrimitiveValue) {
            removeChild((CSSNodeImpl) child);
        }
        child = next;
    }
    setCssValueTextCore(value);
}
Also used : ICSSPrimitiveValue(org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue) ICSSNode(org.eclipse.wst.css.core.internal.provisional.document.ICSSNode)

Example 2 with ICSSPrimitiveValue

use of org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue in project webtools.sourceediting by eclipse.

the class CSSSourceFormatterFactory method getSourceFormatter.

/**
 */
public CSSSourceGenerator getSourceFormatter(INodeNotifier target) {
    ICSSNode node = (ICSSNode) target;
    short type = node.getNodeType();
    switch(type) {
        case ICSSNode.CHARSETRULE_NODE:
            return CharsetRuleFormatter.getInstance();
        case ICSSNode.FONTFACERULE_NODE:
            return FontFaceRuleFormatter.getInstance();
        case ICSSNode.IMPORTRULE_NODE:
            return ImportRuleFormatter.getInstance();
        case ICSSNode.MEDIALIST_NODE:
            return MediaListFormatter.getInstance();
        case ICSSNode.MEDIARULE_NODE:
            return MediaRuleFormatter.getInstance();
        case ICSSNode.PRIMITIVEVALUE_NODE:
            ICSSPrimitiveValue value = (ICSSPrimitiveValue) node;
            if (value.getPrimitiveType() == org.w3c.dom.css.CSSPrimitiveValue.CSS_COUNTER)
                return CounterFormatter.getInstance();
            else if (value.getPrimitiveType() == org.w3c.dom.css.CSSPrimitiveValue.CSS_RECT)
                return RectFormatter.getInstance();
            else if (value.getPrimitiveType() == org.w3c.dom.css.CSSPrimitiveValue.CSS_RGBCOLOR)
                return RGBFormatter.getInstance();
            else
                return PrimitiveValueFormatter.getInstance();
        case ICSSNode.PAGERULE_NODE:
            return PageRuleFormatter.getInstance();
        case ICSSNode.STYLEDECLARATION_NODE:
            return StyleDeclarationFormatter.getInstance();
        case ICSSNode.STYLEDECLITEM_NODE:
            return StyleDeclItemFormatter.getInstance();
        case ICSSNode.STYLERULE_NODE:
            return StyleRuleFormatter.getInstance();
        case ICSSNode.STYLESHEET_NODE:
            return StyleSheetFormatter.getInstance();
        case ICSSNode.ATTR_NODE:
            return AttrFormatter.getInstance();
        default:
            return UnknownRuleFormatter.getInstance();
    }
}
Also used : ICSSPrimitiveValue(org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue) ICSSNode(org.eclipse.wst.css.core.internal.provisional.document.ICSSNode)

Example 3 with ICSSPrimitiveValue

use of org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue in project webtools.sourceediting by eclipse.

the class BackgroundPositionXSubStyleAdapter method get.

/**
 */
public String get(ICSS2Properties properties) {
    String str = null;
    Object obj = properties.get(PropCMProperty.getInstanceOf(PropCMProperty.P_BG_POSITION));
    if (obj != null) {
        PropCMProperty propX = PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_X);
        PropCMProperty propY = PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_Y);
        if (obj instanceof ICSSValueList) {
            ICSSValueList list = (ICSSValueList) obj;
            ICSSValue value = (ICSSValue) list.item(0);
            if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
                ICSSPrimitiveValue prim = (ICSSPrimitiveValue) value;
                if (prim.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) {
                    // check not top or bottom
                    if (!propX.canHave(prim.getStringValue()) && propY.canHave(prim.getStringValue())) {
                        // case order is vertical -> horizontal
                        value = (ICSSValue) list.item(1);
                    }
                }
            }
            str = value.getCSSValueText();
        } else if (obj instanceof ICSSValue) {
            str = ((ICSSValue) obj).getCSSValueText();
            if (str.equalsIgnoreCase(IValID.V_BOTTOM) || str.equalsIgnoreCase(IValID.V_TOP))
                // $NON-NLS-1$
                str = "";
        } else {
            str = obj.toString();
            CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, str);
            CSSTextToken[] tokens = parser.getTokens();
            tokens = correctMeaningToken(tokens);
            if (tokens.length == 0)
                // $NON-NLS-1$
                str = "";
            else if (tokens.length == 1 && (tokens[0].image.equalsIgnoreCase(IValID.V_BOTTOM) || tokens[0].image.equalsIgnoreCase(IValID.V_TOP)))
                // $NON-NLS-1$
                str = "";
            else
                str = tokens[0].image;
        }
    }
    // $NON-NLS-1$
    return (str != null) ? str : "";
}
Also used : PropCMProperty(org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty) ICSSValue(org.eclipse.wst.css.core.internal.provisional.document.ICSSValue) ICSSPrimitiveValue(org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue) CSSTextParser(org.eclipse.wst.css.core.internal.parserz.CSSTextParser) ICSSValueList(org.eclipse.wst.css.core.internal.provisional.document.ICSSValueList)

Example 4 with ICSSPrimitiveValue

use of org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue in project webtools.sourceediting by eclipse.

the class BackgroundPositionYSubStyleAdapter method get.

/**
 */
public String get(ICSS2Properties properties) {
    String str = null;
    Object obj = properties.get(PropCMProperty.getInstanceOf(PropCMProperty.P_BG_POSITION));
    if (obj != null) {
        PropCMProperty propX = PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_X);
        PropCMProperty propY = PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_Y);
        if (obj instanceof ICSSValueList) {
            ICSSValueList list = (ICSSValueList) obj;
            int index = 1;
            ICSSValue value = (ICSSValue) list.item(0);
            if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
                ICSSPrimitiveValue prim = (ICSSPrimitiveValue) value;
                if (prim.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) {
                    // check not top or bottom
                    if (!propX.canHave(prim.getStringValue()) && propY.canHave(prim.getStringValue())) {
                        // case order is vertical -> horizontal
                        index = 0;
                    }
                }
            }
            str = ((ICSSValue) list.item(index)).getCSSValueText();
        } else if (obj instanceof ICSSValue) {
            str = ((ICSSValue) obj).getCSSValueText();
            if (!str.equalsIgnoreCase(IValID.V_BOTTOM) && !str.equalsIgnoreCase(IValID.V_TOP))
                // $NON-NLS-1$
                str = "";
        } else {
            str = obj.toString();
            CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, str);
            CSSTextToken[] tokens = parser.getTokens();
            tokens = correctMeaningToken(tokens);
            if (tokens.length == 1 && (tokens[0].image.equalsIgnoreCase(IValID.V_BOTTOM) || tokens[0].image.equalsIgnoreCase(IValID.V_TOP)))
                str = tokens[0].image;
            else if (tokens.length > 1)
                str = tokens[1].image;
            else
                // $NON-NLS-1$
                str = "";
        }
    }
    // $NON-NLS-1$
    return (str != null) ? str : "";
}
Also used : PropCMProperty(org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty) ICSSValue(org.eclipse.wst.css.core.internal.provisional.document.ICSSValue) ICSSPrimitiveValue(org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue) CSSTextParser(org.eclipse.wst.css.core.internal.parserz.CSSTextParser) ICSSValueList(org.eclipse.wst.css.core.internal.provisional.document.ICSSValueList)

Example 5 with ICSSPrimitiveValue

use of org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue in project webtools.sourceediting by eclipse.

the class CSSContentSelectionProvider method getFilteredNode.

private Object getFilteredNode(Object object) {
    // If the selection is a primitive value, get the property that contains it */
    if (object instanceof ICSSPrimitiveValue) {
        ICSSPrimitiveValue value = (ICSSPrimitiveValue) object;
        object = value.getParentNode();
    }
    return object;
}
Also used : ICSSPrimitiveValue(org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue)

Aggregations

ICSSPrimitiveValue (org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue)11 ICSSNode (org.eclipse.wst.css.core.internal.provisional.document.ICSSNode)6 ICSSStyleDeclItem (org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclItem)3 CSSCleanupStrategy (org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy)2 PropCMProperty (org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty)2 CSSTextParser (org.eclipse.wst.css.core.internal.parserz.CSSTextParser)2 ICSSStyleDeclaration (org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclaration)2 ICSSValue (org.eclipse.wst.css.core.internal.provisional.document.ICSSValue)2 ICSSValueList (org.eclipse.wst.css.core.internal.provisional.document.ICSSValueList)2 IndexedRegion (org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)2 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)2 ITextRegion (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Preferences (org.eclipse.core.runtime.Preferences)1 CSSRegionContainer (org.eclipse.wst.css.core.internal.document.CSSRegionContainer)1 ICSSMediaRule (org.eclipse.wst.css.core.internal.provisional.document.ICSSMediaRule)1 ICSSPageRule (org.eclipse.wst.css.core.internal.provisional.document.ICSSPageRule)1 ICSSStyleRule (org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule)1 ICSSStyleSheet (org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet)1