Search in sources :

Example 91 with IStructuredDocument

use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument in project webtools.sourceediting by eclipse.

the class CSSPageRuleTest method testInsertText5.

public void testInsertText5() 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 5
    rule = ruleList.item(4);
    assertEquals(CSSRule.PAGE_RULE, rule.getType());
    assertTrue(rule instanceof CSSPageRule);
    assertEquals("narrow", ((CSSPageRule) rule).getSelectorText());
    declaration = ((CSSPageRule) rule).getStyle();
    assertEquals(1, 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_CM, 9));
    checkPrimitiveNumber(valueList.item(1), new PrimitiveNumber(CSSPrimitiveValue.CSS_CM, 18));
}
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 92 with IStructuredDocument

use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument in project webtools.sourceediting by eclipse.

the class AttrTest3 method testModel.

public void testModel() {
    IDOMModel model = createXMLModel();
    try {
        IStructuredDocument structuredDocument = model.getStructuredDocument();
        Document document = model.getDocument();
        structuredDocument.setText(this, "<a xmlns='default-uri' xmlns:b='b-uri'><c d='d-value' b:e='e-value'/></a>");
        printSource(model);
        printTree(model);
        Element a = (Element) document.getFirstChild();
        Element c = (Element) a.getFirstChild();
        Attr xmlns = a.getAttributeNode("xmlns");
        fOutputWriter.writeln("xmlns [" + xmlns.getNamespaceURI() + "]");
        Attr xmlns_b = a.getAttributeNode("xmlns:b");
        fOutputWriter.writeln("xmlns:b [" + xmlns_b.getNamespaceURI() + "]");
        Attr d = c.getAttributeNode("d");
        fOutputWriter.writeln("d [" + d.getNamespaceURI() + "]");
        Attr b_e = c.getAttributeNode("b:e");
        fOutputWriter.writeln("b:e [" + b_e.getNamespaceURI() + "]");
        saveAndCompareTestResults();
    } finally {
        model.releaseFromEdit();
    }
}
Also used : IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) Element(org.w3c.dom.Element) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) Document(org.w3c.dom.Document) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) Attr(org.w3c.dom.Attr)

Example 93 with IStructuredDocument

use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument in project webtools.sourceediting by eclipse.

the class AttrValueTest method testModel.

/* (non-Javadoc)
	 * @see org.eclipse.wst.html.core.tests.parser.ModelTest#testModel()
	 */
public void testModel() {
    IDOMModel model = createHTMLModel();
    try {
        assertNotNull(model);
        IStructuredDocument document = model.getStructuredDocument();
        assertNotNull(document);
        document.setText(this, "<button value=\"" + VALUES[0] + "\"></button><button value=\"" + VALUES[1] + "\"></button><button value=\"" + VALUES[2] + "\"></button>");
        IDOMDocument dom = model.getDocument();
        NodeList nodes = dom.getElementsByTagName("button");
        assertTrue("Must be 3 button elements in the document.", nodes.getLength() == 3);
        for (int i = 0; i < nodes.getLength(); i++) {
            Node node = nodes.item(i);
            Node attr = node.getAttributes().getNamedItem("value");
            assertTrue("Attribute 'value' not present.", attr != null && attr.getNodeValue().length() > 0);
            assertEquals("Attribute values are not equal", VALUES[i], attr.getNodeValue());
        }
    } finally {
        if (model != null) {
            model.releaseFromEdit();
        }
    }
}
Also used : IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)

Example 94 with IStructuredDocument

use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument in project webtools.sourceediting by eclipse.

the class EleTest method testModel.

public void testModel() {
    IDOMModel model = createHTMLModel();
    try {
        IStructuredDocument structuredDocument = model.getStructuredDocument();
        Document document = model.getDocument();
        structuredDocument.replaceText(null, 0, 0, "<html><body><DL>\n\n<DD>Add a \"set top\" rule for the specified parameters1.\n<DD>Add a \"set top\" rule for the specified parameters2.\n<DD>Add a \"set top\" rule for the specified parameters3.\n<DD>Add a \"set top\" rule for the specified parameters4.\n<DD>Add a \"set top\" rule for the specified parameters5.\n<DD>Add a \"set top\" rule for the specified parameters6.\n<DD>Add a \"set top\" rule for the specified parameters7.\n<DD>Add a \"set top\" rule for the specified parameters8.\n<DD>Add a \"set top\" rule for the specified parameters9.\n<DD>Add a \"set top\" rule for the specified parameters10.\n<DD>Add a \"set top\" rule for the specified parameters11.\n<DD>Add a \"set top\" rule for the specified parameters12.\n<DD>Add a \"set top\" rule for the specified parameters.\n<DD>Add a \"set top\" rule for the specified parameters.\n<DD>Add a \"set top\" rule for the specified parameters.\n<DD>Add a \"set top\" rule for the specified parameters.\n<DD>Add a \"set top\" rule for the specified parameters.\n<DD>Add a \"set top\" rule for the specified parameters.\n<DD>Add a \"set top\" rule for the specified parameters.\n<DD>Add a \"set top\" rule for the specified parameters.\n</DL></body></html>");
        Node a = document.getElementsByTagName("DL").item(0);
        System.out.println(((Element) a).getElementsByTagName("DD").getLength());
    } finally {
        model.releaseFromEdit();
    }
}
Also used : IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) Document(org.w3c.dom.Document) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)

Example 95 with IStructuredDocument

use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument in project webtools.sourceediting by eclipse.

the class EntityTest8 method testModel.

public void testModel() {
    IDOMModel model = createXMLModel();
    try {
        // Document document = model.getDocument();
        IStructuredDocument structuredDocument = model.getStructuredDocument();
        structuredDocument.setText(this, "&ibm;&rtp;");
        printSource(model);
        printTree(model);
        saveAndCompareTestResults();
    } finally {
        model.releaseFromEdit();
    }
}
Also used : IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)

Aggregations

IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)432 IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)96 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)79 IStructuredDocumentRegion (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)68 CSSCleanupStrategy (org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy)44 Node (org.w3c.dom.Node)42 ICSSModel (org.eclipse.wst.css.core.internal.provisional.document.ICSSModel)41 Document (org.w3c.dom.Document)36 BadLocationException (org.eclipse.jface.text.BadLocationException)35 IndexedRegion (org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)34 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)34 ITextRegion (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)33 Element (org.w3c.dom.Element)30 IDocument (org.eclipse.jface.text.IDocument)29 IDOMDocument (org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)28 IModelManager (org.eclipse.wst.sse.core.internal.provisional.IModelManager)26 StructuredDocumentEvent (org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent)23 Test (org.junit.Test)22 INodeAdapter (org.eclipse.wst.sse.core.internal.provisional.INodeAdapter)20 RegionChangedEvent (org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent)20