Search in sources :

Example 36 with ICSSNode

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

the class CSSModelUpdateContext method getCSSPrimitiveValueAny.

/**
 */
CSSPrimitiveValueImpl getCSSPrimitiveValueAny() {
    ICSSNode node = getNode();
    if (node instanceof CSSPrimitiveValueImpl) {
        return (CSSPrimitiveValueImpl) node;
    } else {
        CSSUtil.debugOut(// $NON-NLS-1$
        "CSSPrimitiveValueImpl 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)

Example 37 with ICSSNode

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

the class CSSModelUpdateContext method getRect.

/**
 */
// ICSSNode getParentNode() {
// return fParentNode;
// }
/**
 */
RectImpl getRect() {
    ICSSNode node = getNode();
    if (node instanceof RectImpl) {
        return (RectImpl) node;
    } else {
        CSSUtil.debugOut(// $NON-NLS-1$
        "RectImpl 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)

Example 38 with ICSSNode

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

the class CSSModelUpdateContext method setupContext.

/**
 */
void setupContext(short updateMode, ICSSNode parentNode, ICSSNode targetNode) {
    fUpdateMode = updateMode;
    ICSSNode traverseRoot;
    if (updateMode == UPDATE_REMOVE_RCONTAINER || updateMode == UPDATE_INSERT_RCONTAINER || updateMode == UPDATE_CHANGE_RCONTAINER) {
        traverseRoot = parentNode;
        while (traverseRoot instanceof CSSRegionContainer) {
            traverseRoot = traverseRoot.getParentNode();
        }
    } else {
        traverseRoot = targetNode;
    }
    if (// region
    updateMode == UPDATE_REMOVE_RCONTAINER || updateMode == UPDATE_INSERT_RCONTAINER || // node
    updateMode == UPDATE_CHANGE_RCONTAINER || updateMode == UPDATE_REMOVE_FNCONTAINER) {
        fDeletionTarget = traverseRoot;
        if (fDeletionTarget == targetNode) {
            fDeletionTargetParent = parentNode;
        } else {
            fDeletionTargetParent = fDeletionTarget.getParentNode();
        }
    } else {
        fDeletionTarget = null;
        fDeletionTargetParent = null;
    }
    if (// region
    updateMode == UPDATE_INSERT_RCONTAINER || updateMode == UPDATE_INSERT_FNCONTAINER || updateMode == UPDATE_REMOVE_RCONTAINER || // node
    updateMode == UPDATE_CHANGE_RCONTAINER) {
        CSSNodeUpdateTraverser traverser = new CSSNodeUpdateTraverser();
        traverser.apply(traverseRoot);
        fNodeList = traverser.getNodeList();
    } else {
        fNodeList = null;
    }
}
Also used : ICSSNode(org.eclipse.wst.css.core.internal.provisional.document.ICSSNode)

Example 39 with ICSSNode

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

the class CSSModelUpdateContext method getCSSCharsetRule.

/**
 */
CSSCharsetRuleImpl getCSSCharsetRule() {
    ICSSNode node = getNode();
    if (node instanceof CSSCharsetRuleImpl) {
        return (CSSCharsetRuleImpl) node;
    } else {
        CSSUtil.debugOut(// $NON-NLS-1$
        "CSSCharsetRuleImpl 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)

Example 40 with ICSSNode

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

the class CSSNodeImpl method cloneChildNodes.

/**
 * currently public but may be made default access protected in future.
 */
protected void cloneChildNodes(ICSSNode newParent, boolean deep) {
    if (newParent == null || newParent == this)
        return;
    CSSNodeImpl container = (CSSNodeImpl) newParent;
    container.removeChildNodes();
    for (ICSSNode child = getFirstChild(); child != null; child = child.getNextSibling()) {
        CSSNodeImpl cloned = (CSSNodeImpl) child.cloneNode(deep);
        if (cloned != null)
            container.appendChild(cloned);
    }
}
Also used : 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