Search in sources :

Example 11 with CSSValue

use of org.w3c.dom.css.CSSValue in project webtools.sourceediting by eclipse.

the class CSSPropertyContext method initialize.

/**
 */
public void initialize(ICSSStyleDeclaration decl) {
    fProperties.clear();
    if (fModified != null)
        fModified.clear();
    if (decl == null)
        return;
    int nProperties = decl.getLength();
    for (int i = 0; i < nProperties; i++) {
        String propName = decl.item(i);
        if (propName != null) {
            String propN = propName.trim().toLowerCase();
            if (propN.length() != 0) {
                CSSValue val = decl.getPropertyCSSValue(propName);
                if (val != null)
                    fProperties.put(propN, val);
            }
        }
    }
}
Also used : ICSSValue(org.eclipse.wst.css.core.internal.provisional.document.ICSSValue) CSSValue(org.w3c.dom.css.CSSValue)

Example 12 with CSSValue

use of org.w3c.dom.css.CSSValue 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());
}
Also used : ICSSValue(org.eclipse.wst.css.core.internal.provisional.document.ICSSValue) CSSValue(org.w3c.dom.css.CSSValue) CSSRule(org.w3c.dom.css.CSSRule) ICSSValue(org.eclipse.wst.css.core.internal.provisional.document.ICSSValue) ICSSModel(org.eclipse.wst.css.core.internal.provisional.document.ICSSModel) CSSStyleRule(org.w3c.dom.css.CSSStyleRule) CSSStyleSheet(org.w3c.dom.css.CSSStyleSheet) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) CSSStyleDeclaration(org.w3c.dom.css.CSSStyleDeclaration) CSSRuleList(org.w3c.dom.css.CSSRuleList)

Example 13 with CSSValue

use of org.w3c.dom.css.CSSValue 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));
}
Also used : CSSPageRule(org.w3c.dom.css.CSSPageRule) CSSValue(org.w3c.dom.css.CSSValue) CSSValueList(org.w3c.dom.css.CSSValueList) CSSRule(org.w3c.dom.css.CSSRule) ICSSModel(org.eclipse.wst.css.core.internal.provisional.document.ICSSModel) CSSStyleSheet(org.w3c.dom.css.CSSStyleSheet) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) CSSStyleDeclaration(org.w3c.dom.css.CSSStyleDeclaration) CSSRuleList(org.w3c.dom.css.CSSRuleList)

Example 14 with CSSValue

use of org.w3c.dom.css.CSSValue 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"));
}
Also used : CSSPageRule(org.w3c.dom.css.CSSPageRule) CSSValue(org.w3c.dom.css.CSSValue) CSSRule(org.w3c.dom.css.CSSRule) ICSSModel(org.eclipse.wst.css.core.internal.provisional.document.ICSSModel) CSSStyleSheet(org.w3c.dom.css.CSSStyleSheet) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) CSSStyleDeclaration(org.w3c.dom.css.CSSStyleDeclaration) CSSRuleList(org.w3c.dom.css.CSSRuleList)

Example 15 with CSSValue

use of org.w3c.dom.css.CSSValue in project webtools.sourceediting by eclipse.

the class CSSPageRuleTest method testInsertText2.

public void testInsertText2() 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 2
    rule = ruleList.item(1);
    assertEquals(CSSRule.PAGE_RULE, rule.getType());
    assertTrue(rule instanceof CSSPageRule);
    declaration = ((CSSPageRule) rule).getStyle();
    assertEquals(2, declaration.getLength());
    value = declaration.getPropertyCSSValue("size");
    checkPrimitiveString(value, new PrimitiveString(CSSPrimitiveValue.CSS_IDENT, "auto"));
    value = declaration.getPropertyCSSValue("margin");
    checkPrimitiveNumber(value, new PrimitiveNumber(CSSPrimitiveValue.CSS_PERCENTAGE, 10));
}
Also used : CSSPageRule(org.w3c.dom.css.CSSPageRule) CSSValue(org.w3c.dom.css.CSSValue) CSSRule(org.w3c.dom.css.CSSRule) ICSSModel(org.eclipse.wst.css.core.internal.provisional.document.ICSSModel) CSSStyleSheet(org.w3c.dom.css.CSSStyleSheet) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) CSSStyleDeclaration(org.w3c.dom.css.CSSStyleDeclaration) CSSRuleList(org.w3c.dom.css.CSSRuleList)

Aggregations

CSSValue (org.w3c.dom.css.CSSValue)19 CSSRule (org.w3c.dom.css.CSSRule)15 CSSRuleList (org.w3c.dom.css.CSSRuleList)15 CSSStyleDeclaration (org.w3c.dom.css.CSSStyleDeclaration)15 CSSStyleSheet (org.w3c.dom.css.CSSStyleSheet)15 ICSSModel (org.eclipse.wst.css.core.internal.provisional.document.ICSSModel)14 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)14 CSSValueList (org.w3c.dom.css.CSSValueList)7 CSSPageRule (org.w3c.dom.css.CSSPageRule)6 CSSStyleRule (org.w3c.dom.css.CSSStyleRule)5 CSSFontFaceRule (org.w3c.dom.css.CSSFontFaceRule)4 ICSSValue (org.eclipse.wst.css.core.internal.provisional.document.ICSSValue)3 CSSPrimitiveValue (org.w3c.dom.css.CSSPrimitiveValue)3 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 CSSStylableElement (org.eclipse.e4.ui.css.core.dom.CSSStylableElement)1 Gradient (org.eclipse.e4.ui.css.core.dom.properties.Gradient)1 CSS2FontProperties (org.eclipse.e4.ui.css.core.dom.properties.css2.CSS2FontProperties)1 CSSElementContext (org.eclipse.e4.ui.css.core.engine.CSSElementContext)1