Search in sources :

Example 41 with ICSSModel

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

the class CSSUrlTest method testDeclaration3.

/**
 * Declaration: with single quote
 */
public void testDeclaration3() {
    ICSSModel model = FileUtil.createModel();
    IStructuredDocument document = model.getStructuredDocument();
    ((CSSSourceParser) document.getParser()).setParserMode(CSSSourceParser.MODE_DECLARATION_VALUE);
    // $NON-NLS-1$
    document.set("background-image: url(\'white space.gif\');");
    UrlInfo[] urls = pickupUrl(document);
    assertEquals(1, urls.length);
    assertEquals(CSSRegionContexts.CSS_DECLARATION_VALUE_URI, urls[0].getType());
    // $NON-NLS-1$
    assertEquals("white space.gif", urls[0].getUrl());
}
Also used : ICSSModel(org.eclipse.wst.css.core.internal.provisional.document.ICSSModel) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) CSSSourceParser(org.eclipse.wst.css.core.internal.parser.CSSSourceParser)

Example 42 with ICSSModel

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

the class CSSUrlTest method testSomeRules1.

/**
 * Import rule and style rule: without quotes
 */
public void testSomeRules1() {
    ICSSModel model = FileUtil.createModel();
    IStructuredDocument document = model.getStructuredDocument();
    // $NON-NLS-1$
    document.set("@import url(white space.css);LI { background-image: url(white space.gif);list-style-image: url(style image.gif); }");
    UrlInfo[] urls = pickupUrl(document);
    assertEquals(3, urls.length);
    assertEquals(CSSRegionContexts.CSS_URI, urls[0].getType());
    // $NON-NLS-1$
    assertEquals("white space.css", urls[0].getUrl());
    assertEquals(CSSRegionContexts.CSS_DECLARATION_VALUE_URI, urls[1].getType());
    // $NON-NLS-1$
    assertEquals("white space.gif", urls[1].getUrl());
    assertEquals(CSSRegionContexts.CSS_DECLARATION_VALUE_URI, urls[2].getType());
    // $NON-NLS-1$
    assertEquals("style image.gif", urls[2].getUrl());
}
Also used : ICSSModel(org.eclipse.wst.css.core.internal.provisional.document.ICSSModel) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)

Example 43 with ICSSModel

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

the class CSSUrlTest method testDeclaration1.

/**
 * Declaration: without quotes
 */
public void testDeclaration1() {
    ICSSModel model = FileUtil.createModel();
    IStructuredDocument document = model.getStructuredDocument();
    ((CSSSourceParser) document.getParser()).setParserMode(CSSSourceParser.MODE_DECLARATION_VALUE);
    // $NON-NLS-1$
    document.set("background-image: url(white space.gif);");
    UrlInfo[] urls = pickupUrl(document);
    assertEquals(1, urls.length);
    assertEquals(CSSRegionContexts.CSS_DECLARATION_VALUE_URI, urls[0].getType());
    // $NON-NLS-1$
    assertEquals("white space.gif", urls[0].getUrl());
}
Also used : ICSSModel(org.eclipse.wst.css.core.internal.provisional.document.ICSSModel) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) CSSSourceParser(org.eclipse.wst.css.core.internal.parser.CSSSourceParser)

Example 44 with ICSSModel

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

the class CSSModelLoadTest method testLoadCSSfromStream.

public void testLoadCSSfromStream() throws UnsupportedEncodingException, IOException {
    InputStream input = null;
    input = CSSModelLoadTest.class.getResourceAsStream(HTML4_CSS);
    IStructuredModel model = StructuredModelManager.getModelManager().getModelForEdit(HTML4_CSS, input, null);
    assertNotNull(model);
    assertTrue("IStructuredModel was not a ICSSModel", model instanceof ICSSModel);
    assertTrue("contents are incomplete", model.getStructuredDocument().get().indexOf("Basic HTML style information") > 4);
    model.releaseFromEdit();
}
Also used : ICSSModel(org.eclipse.wst.css.core.internal.provisional.document.ICSSModel) InputStream(java.io.InputStream) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)

Example 45 with ICSSModel

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

the class CSSNodeAdapter method addElements.

private void addElements(Object element, ArrayList v) {
    ICSSNode node;
    if (element instanceof ICSSModel) {
        ICSSModel model = (ICSSModel) element;
        ICSSDocument doc = model.getDocument();
        node = doc.getFirstChild();
    } else if (element instanceof ICSSNode) {
        node = ((ICSSNode) element).getFirstChild();
    } else
        return;
    while (node != null) {
        if (node instanceof CSSRule) {
            v.add(node);
        }
        node = node.getNextSibling();
    }
}
Also used : CSSRule(org.w3c.dom.css.CSSRule) ICSSModel(org.eclipse.wst.css.core.internal.provisional.document.ICSSModel) ICSSNode(org.eclipse.wst.css.core.internal.provisional.document.ICSSNode) ICSSDocument(org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument)

Aggregations

ICSSModel (org.eclipse.wst.css.core.internal.provisional.document.ICSSModel)82 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)41 CSSRule (org.w3c.dom.css.CSSRule)21 CSSRuleList (org.w3c.dom.css.CSSRuleList)20 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)15 CSSStyleDeclaration (org.w3c.dom.css.CSSStyleDeclaration)14 CSSStyleSheet (org.w3c.dom.css.CSSStyleSheet)14 CSSValue (org.w3c.dom.css.CSSValue)14 ICSSDocument (org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument)12 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)12 ICSSNode (org.eclipse.wst.css.core.internal.provisional.document.ICSSNode)11 IModelProvideAdapter (org.eclipse.wst.css.core.internal.provisional.adapters.IModelProvideAdapter)8 CSSSourceParser (org.eclipse.wst.css.core.internal.parser.CSSSourceParser)7 INodeNotifier (org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)7 CSSStyleRule (org.w3c.dom.css.CSSStyleRule)7 IFile (org.eclipse.core.resources.IFile)6 Path (org.eclipse.core.runtime.Path)6 CSSSourceFormatter (org.eclipse.wst.css.core.internal.formatter.CSSSourceFormatter)6 IndexedRegion (org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)6 Element (org.w3c.dom.Element)6