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());
}
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());
}
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());
}
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();
}
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();
}
}
Aggregations