Search in sources :

Example 91 with ICSSNode

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

the class CSSModelUpdateContext method getCSSFontFaceRule.

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

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

the class CSSModelUpdateContext method getCSSPrimitiveValue.

/**
 */
CSSPrimitiveValueImpl getCSSPrimitiveValue(short type) {
    ICSSNode node = getNode();
    if (node instanceof CSSPrimitiveValueImpl) {
        short nodeType = ((CSSPrimitiveValueImpl) node).getPrimitiveType();
        if (nodeType == type || ((nodeType == CSSPrimitiveValue.CSS_NUMBER || nodeType == ICSSPrimitiveValue.CSS_INTEGER) && (type == CSSPrimitiveValue.CSS_NUMBER || type == ICSSPrimitiveValue.CSS_INTEGER))) {
            return (CSSPrimitiveValueImpl) node;
        }
    }
    if (node instanceof CSSPrimitiveValueImpl) {
        CSSPrimitiveValueImpl value = (CSSPrimitiveValueImpl) node;
        CSSUtil.debugOut(// $NON-NLS-1$
        "CSSPrimitiveValueImpl [" + type + // $NON-NLS-1$
        "] is expected, but type is [" + value.getPrimitiveType() + "]: \"" + value.generateSource() + // $NON-NLS-2$//$NON-NLS-1$
        "\"");
    } else {
        CSSUtil.debugOut(// $NON-NLS-1$
        "CSSPrimitiveValueImpl(" + type + // $NON-NLS-1$
        ") 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 93 with ICSSNode

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

the class CSSNodeImpl method removeChildNodes.

/**
 */
void removeChildNodes() {
    ICSSNode nextChild = null;
    for (ICSSNode child = getFirstChild(); child != null; child = nextChild) {
        nextChild = child.getNextSibling();
        removeChild((CSSNodeImpl) child);
    }
}
Also used : ICSSNode(org.eclipse.wst.css.core.internal.provisional.document.ICSSNode)

Example 94 with ICSSNode

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

the class HTMLDocumentAdapter method getClasses.

/**
 */
public Enumeration getClasses() {
    StyleSheetList sheetList = getStyleSheets();
    int nSheets = sheetList.getLength();
    final ArrayList classes = new ArrayList();
    CSSClassTraverser traverser = new CSSClassTraverser();
    traverser.setTraverseImported(true);
    for (int i = 0; i < nSheets; i++) {
        org.w3c.dom.stylesheets.StyleSheet sheet = sheetList.item(i);
        if (sheet instanceof ICSSNode) {
            traverser.apply((ICSSNode) sheet);
        }
    }
    classes.addAll(traverser.getClassNames());
    return new Enumeration() {

        int i = 0;

        public boolean hasMoreElements() {
            return i < classes.size();
        }

        public Object nextElement() {
            return classes.get(i++);
        }
    };
}
Also used : StyleSheet(org.w3c.dom.stylesheets.StyleSheet) Enumeration(java.util.Enumeration) ArrayList(java.util.ArrayList) CSSClassTraverser(org.eclipse.wst.css.core.internal.util.CSSClassTraverser) ICSSNode(org.eclipse.wst.css.core.internal.provisional.document.ICSSNode) StyleSheetList(org.w3c.dom.stylesheets.StyleSheetList)

Example 95 with ICSSNode

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

the class EmbeddedCSSFormatter method getCSSContent.

/**
 */
private String getCSSContent(IDOMNode text) {
    ICSSModel model = getCSSModel(text);
    if (model == null)
        return null;
    ICSSNode document = model.getDocument();
    if (document == null)
        return null;
    INodeNotifier notifier = (INodeNotifier) document;
    CSSSourceFormatter formatter = (CSSSourceFormatter) notifier.getAdapterFor(CSSSourceFormatter.class);
    // try another way to get formatter
    if (formatter == null)
        formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter(notifier);
    if (formatter == null)
        return null;
    StringBuffer buffer = formatter.format(document);
    if (buffer == null)
        return null;
    return buffer.toString();
}
Also used : CSSSourceFormatter(org.eclipse.wst.css.core.internal.formatter.CSSSourceFormatter) ICSSModel(org.eclipse.wst.css.core.internal.provisional.document.ICSSModel) ICSSNode(org.eclipse.wst.css.core.internal.provisional.document.ICSSNode) INodeNotifier(org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)

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