use of org.eclipse.wst.css.core.internal.provisional.document.ICSSModel in project webtools.sourceediting by eclipse.
the class CSSContentAssistContext method getMetaModel.
/**
*/
CSSMetaModel getMetaModel() {
CSSMetaModelFinder finder = CSSMetaModelFinder.getInstance();
ICSSModel model = getModel();
if (model.getOwnerDOMNode() != null) {
return finder.findMetaModelFor(model.getOwnerDOMNode());
}
return finder.findMetaModelFor(getModel());
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSModel in project webtools.sourceediting by eclipse.
the class CSSLinkConverter method begin.
/**
*/
protected void begin(ICSSNode node) {
if (baseModel == null) {
baseModel = node.getOwnerDocument().getModel();
if (baseModel instanceof ICSSModel && ((ICSSModel) baseModel).getStyleSheetType() != ICSSModel.EXTERNAL) {
IDOMNode xmlNode = (IDOMNode) ((ICSSModel) baseModel).getOwnerDOMNode();
baseModel = xmlNode.getModel();
}
}
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSModel in project webtools.sourceediting by eclipse.
the class CSSFontFamilyTest method testValueModification.
public void testValueModification() throws IOException {
ICSSModel model = getModel();
IStructuredDocument structuredDocument = model.getStructuredDocument();
structuredDocument.set(FileUtil.createString("src/org/eclipse/wst/css/core/tests/testfiles", "CSSFontFamilyTest.css"));
CSSStyleSheet sheet = (CSSStyleSheet) model.getDocument();
CSSRuleList rules = sheet.getCssRules();
assertEquals(4, rules.getLength());
// Rule 1: No whitespace
CSSRule rule;
CSSStyleDeclaration declaration;
CSSValue value;
// Rule 1: No whitespace
rule = rules.item(0);
assertEquals(CSSRule.STYLE_RULE, rule.getType());
assertTrue(rule instanceof CSSStyleRule);
declaration = ((CSSStyleRule) rule).getStyle();
value = declaration.getPropertyCSSValue(FONT_FAMILY);
checkPrimitiveString(value, new PrimitiveString(CSSPrimitiveValue.CSS_IDENT, "Courier"));
declaration.setProperty(FONT_FAMILY, "\"Times New Roman\", Times, serif", "");
value = declaration.getPropertyCSSValue(FONT_FAMILY);
assertTrue(value instanceof ICSSValue);
assertEquals("\"Times New Roman\", Times, serif", ((ICSSValue) value).getCSSValueText());
declaration.setProperty(FONT_FAMILY, "\"Times New Roman\", Times", "");
value = declaration.getPropertyCSSValue(FONT_FAMILY);
assertTrue(value instanceof ICSSValue);
assertEquals("\"Times New Roman\", Times", ((ICSSValue) value).getCSSValueText());
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSModel in project webtools.sourceediting by eclipse.
the class CSSPageRuleTest method testInsertText1.
public void testInsertText1() throws IOException {
ICSSModel model = getModel();
IStructuredDocument structuredDocument = model.getStructuredDocument();
structuredDocument.set(FileUtil.createString("src/org/eclipse/wst/css/core/tests/testfiles", "CSSPageRuleTest.css"));
CSSStyleSheet sheet = (CSSStyleSheet) model.getDocument();
CSSRuleList ruleList = sheet.getCssRules();
assertEquals(6, ruleList.getLength());
CSSRule rule;
CSSStyleDeclaration declaration;
CSSValue value;
CSSValueList valueList;
// rule 1
rule = ruleList.item(0);
assertEquals(CSSRule.PAGE_RULE, rule.getType());
assertTrue(rule instanceof CSSPageRule);
declaration = ((CSSPageRule) rule).getStyle();
assertEquals(2, declaration.getLength());
value = declaration.getPropertyCSSValue("size");
assertTrue(value instanceof CSSValueList);
valueList = (CSSValueList) value;
assertEquals(2, valueList.getLength());
checkPrimitiveNumber(valueList.item(0), new PrimitiveNumber(CSSPrimitiveValue.CSS_IN, (float) 8.5));
checkPrimitiveNumber(valueList.item(1), new PrimitiveNumber(CSSPrimitiveValue.CSS_IN, 11));
value = declaration.getPropertyCSSValue("margin");
checkPrimitiveNumber(value, new PrimitiveNumber(CSSPrimitiveValue.CSS_CM, 2));
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSModel in project webtools.sourceediting by eclipse.
the class CSSPageRuleTest method testInsertText6.
public void testInsertText6() throws IOException {
ICSSModel model = getModel();
IStructuredDocument structuredDocument = model.getStructuredDocument();
structuredDocument.set(FileUtil.createString("src/org/eclipse/wst/css/core/tests/testfiles", "CSSPageRuleTest.css"));
CSSStyleSheet sheet = (CSSStyleSheet) model.getDocument();
CSSRuleList ruleList = sheet.getCssRules();
assertEquals(6, ruleList.getLength());
CSSRule rule;
CSSStyleDeclaration declaration;
CSSValue value;
// rule 6
rule = ruleList.item(5);
assertEquals(CSSRule.PAGE_RULE, rule.getType());
assertTrue(rule instanceof CSSPageRule);
assertEquals("rotated", ((CSSPageRule) rule).getSelectorText());
declaration = ((CSSPageRule) rule).getStyle();
assertEquals(1, declaration.getLength());
value = declaration.getPropertyCSSValue("size");
checkPrimitiveString(value, new PrimitiveString(CSSPrimitiveValue.CSS_IDENT, "landscape"));
}
Aggregations