Search in sources :

Example 81 with ICSSNode

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

the class CSSStyleDeclarationImpl method getLength.

/**
 * @return int
 */
public int getLength() {
    int i = 0;
    ICSSNode node = getFirstChild();
    while (node != null) {
        if (node instanceof CSSStyleDeclItemImpl)
            i++;
        node = node.getNextSibling();
    }
    return i;
}
Also used : ICSSNode(org.eclipse.wst.css.core.internal.provisional.document.ICSSNode)

Example 82 with ICSSNode

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

the class CSSModelDeletionContext method findContainer.

/**
 */
private CSSStructuredDocumentRegionContainer findContainer(CSSNodeImpl parent, IStructuredDocumentRegion flatNode) {
    if (parent instanceof CSSStructuredDocumentRegionContainer) {
        // Am i a container of flatNode?
        IStructuredDocumentRegion firstNode = ((CSSStructuredDocumentRegionContainer) parent).getFirstStructuredDocumentRegion();
        IStructuredDocumentRegion lastNode = ((CSSStructuredDocumentRegionContainer) parent).getLastStructuredDocumentRegion();
        int firstStart = getOriginalOffset(firstNode);
        int lastStart = getOriginalOffset(lastNode);
        int start = flatNode.getStart();
        if (firstStart <= start && start <= lastStart) {
            // I am a container, is my child a container ?
            for (ICSSNode node = parent.getFirstChild(); node != null; node = node.getNextSibling()) {
                if (node instanceof CSSNodeImpl) {
                    CSSStructuredDocumentRegionContainer container = findContainer((CSSNodeImpl) node, flatNode);
                    if (container != null) {
                        return container;
                    }
                }
            }
            return (CSSStructuredDocumentRegionContainer) parent;
        }
    }
    return null;
}
Also used : IStructuredDocumentRegion(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion) ICSSNode(org.eclipse.wst.css.core.internal.provisional.document.ICSSNode)

Example 83 with ICSSNode

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

the class CSSModelUpdateContext method getCSSStyleDeclItem.

/**
 */
CSSStyleDeclItemImpl getCSSStyleDeclItem(String propertyName) {
    ICSSNode node = getNode();
    if (node instanceof CSSStyleDeclItemImpl && ((CSSStyleDeclItemImpl) node).getPropertyName().equalsIgnoreCase(propertyName)) {
        return (CSSStyleDeclItemImpl) node;
    } else {
        CSSUtil.debugOut(// $NON-NLS-1$
        "CSSStyleDeclItemImpl(" + propertyName + ") is expected, but " + // $NON-NLS-1$
        CSSUtil.getClassString(node));
        ungetNode();
        // $NON-NLS-1$
        throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");
    }
}
Also used : DOMException(org.w3c.dom.DOMException) ICSSNode(org.eclipse.wst.css.core.internal.provisional.document.ICSSNode)

Example 84 with ICSSNode

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

the class CSSModelUpdateContext method getNode.

/**
 */
private ICSSNode getNode() {
    ICSSNode node = null;
    if (fNodeList != null && 0 < fNodeList.size()) {
        node = (ICSSNode) fNodeList.removeFirst();
    }
    fLastNode = node;
    return node;
}
Also used : ICSSNode(org.eclipse.wst.css.core.internal.provisional.document.ICSSNode)

Example 85 with ICSSNode

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

the class CSSModelUpdateContext method getCSSImportRule.

/**
 */
CSSImportRuleImpl getCSSImportRule() {
    ICSSNode node = getNode();
    if (node instanceof CSSImportRuleImpl) {
        return (CSSImportRuleImpl) node;
    } else {
        CSSUtil.debugOut(// $NON-NLS-1$
        "CSSImportRuleImpl is expected, but " + CSSUtil.getClassString(node));
        ungetNode();
        // $NON-NLS-1$
        throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");
    }
}
Also used : DOMException(org.w3c.dom.DOMException) ICSSNode(org.eclipse.wst.css.core.internal.provisional.document.ICSSNode)

Aggregations

ICSSNode (org.eclipse.wst.css.core.internal.provisional.document.ICSSNode)95 IndexedRegion (org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)21 IStructuredDocumentRegion (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)13 INodeNotifier (org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)12 DOMException (org.w3c.dom.DOMException)12 ICSSModel (org.eclipse.wst.css.core.internal.provisional.document.ICSSModel)11 ICSSStyleDeclItem (org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclItem)11 Iterator (java.util.Iterator)10 ArrayList (java.util.ArrayList)9 List (java.util.List)9 ICSSDocument (org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument)9 Region (org.eclipse.jface.text.Region)8 CSSSourceFormatter (org.eclipse.wst.css.core.internal.formatter.CSSSourceFormatter)6 ICSSPrimitiveValue (org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue)6 ICSSStyleRule (org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule)6 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)6 CSSCleanupStrategy (org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy)5 ICSSImportRule (org.eclipse.wst.css.core.internal.provisional.document.ICSSImportRule)5 ICSSStyleDeclaration (org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclaration)5 ITextRegion (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)5