Search in sources :

Example 71 with IDOMModel

use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel 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)

Example 72 with IDOMModel

use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel in project webtools.sourceediting by eclipse.

the class ModelTest method createHTMLModel.

public static IDOMModel createHTMLModel() {
    // return new XMLModelImpl();
    IStructuredModel model = null;
    try {
        IModelManager modelManager = StructuredModelManager.getModelManager();
        model = modelManager.getModelForEdit("test.html", new NullInputStream(), null);
        // always use the same line delimiter for these tests, regardless
        // of
        // plaform or preference settings
        model.getStructuredDocument().setLineDelimiter(TestWriter.commonEOL);
    } catch (Exception e) {
        e.printStackTrace();
    }
    // null);
    return (IDOMModel) model;
}
Also used : IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) IModelManager(org.eclipse.wst.sse.core.internal.provisional.IModelManager) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) IOException(java.io.IOException)

Example 73 with IDOMModel

use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel in project webtools.sourceediting by eclipse.

the class ParserTest2 method testModel.

public void testModel() {
    IDOMModel model = createXMLModel();
    try {
        IStructuredDocument structuredDocument = model.getStructuredDocument();
        Document document = model.getDocument();
        structuredDocument.replaceText(null, 0, 0, "<a b=\"\"  c=\"c\">");
        printSource(model);
        printTree(model);
        Element a = (Element) document.getFirstChild();
        NamedNodeMap attributes = a.getAttributes();
        for (int i = 0; i < attributes.getLength(); i++) {
            Node attr = attributes.item(i);
            String name = attr.getNodeName();
            String value = attr.getNodeValue();
            fOutputWriter.writeln(name + "=[" + value + "]");
        }
        structuredDocument.replaceText(null, 8, 0, "d");
        printSource(model);
        printTree(model);
        a = (Element) document.getFirstChild();
        attributes = a.getAttributes();
        for (int i = 0; i < attributes.getLength(); i++) {
            Node attr = attributes.item(i);
            String name = attr.getNodeName();
            String value = attr.getNodeValue();
            fOutputWriter.writeln(name + "=[" + value + "]");
        }
        structuredDocument.replaceText(null, 8, 1, "");
        printSource(model);
        printTree(model);
        a = (Element) document.getFirstChild();
        attributes = a.getAttributes();
        for (int i = 0; i < attributes.getLength(); i++) {
            Node attr = attributes.item(i);
            String name = attr.getNodeName();
            String value = attr.getNodeValue();
            fOutputWriter.writeln(name + "=[" + value + "]");
        }
        saveAndCompareTestResults();
    } finally {
        model.releaseFromEdit();
    }
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) Element(org.w3c.dom.Element) Node(org.w3c.dom.Node) 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 74 with IDOMModel

use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel in project webtools.sourceediting by eclipse.

the class ParserTest4 method testModel.

public void testModel() {
    IDOMModel model = createXMLModel();
    try {
        IStructuredDocument structuredDocument = model.getStructuredDocument();
        // Document document = model.getDocument();
        structuredDocument.replaceText(null, 0, 0, "<a>\n\n<% a %>\n<% b %>\n</a>");
        printSource(model);
        printTree(model);
        structuredDocument.replaceText(null, 4, 0, "<");
        printSource(model);
        printTree(model);
        structuredDocument.replaceText(null, 5, 0, "b");
        printSource(model);
        printTree(model);
        structuredDocument.replaceText(null, 6, 0, "c");
        printSource(model);
        printTree(model);
        structuredDocument.replaceText(null, 7, 0, "d");
        printSource(model);
        printTree(model);
        structuredDocument.replaceText(null, 8, 0, "e");
        printSource(model);
        printTree(model);
        structuredDocument.replaceText(null, 9, 0, ">");
        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)

Example 75 with IDOMModel

use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel in project webtools.sourceediting by eclipse.

the class SplitTextTest3 method testModel.

public void testModel() {
    IDOMModel model = createHTMLModel();
    try {
        Document document = model.getDocument();
        Element p = document.createElement("P");
        document.appendChild(p);
        Text text = document.createTextNode("aa");
        p.appendChild(text);
        printSource(model);
        printTree(model);
        Element b = document.createElement("B");
        Text text2 = document.createTextNode("bbbb");
        b.appendChild(text2);
        p.appendChild(b);
        printSource(model);
        printTree(model);
        Text text3 = document.createTextNode("ccc");
        p.appendChild(text3);
        printSource(model);
        printTree(model);
        p.removeChild(b);
        printSource(model);
        printTree(model);
        p.insertBefore(b, text3);
        printSource(model);
        printTree(model);
        saveAndCompareTestResults();
    } finally {
        model.releaseFromEdit();
    }
}
Also used : IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) Element(org.w3c.dom.Element) Text(org.w3c.dom.Text) Document(org.w3c.dom.Document)

Aggregations

IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)433 Document (org.w3c.dom.Document)123 IDOMDocument (org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)120 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)110 Element (org.w3c.dom.Element)109 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)103 Node (org.w3c.dom.Node)57 IFile (org.eclipse.core.resources.IFile)56 NodeList (org.w3c.dom.NodeList)47 IModelManager (org.eclipse.wst.sse.core.internal.provisional.IModelManager)45 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)44 IJsTranslation (org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation)41 JsTranslationAdapter (org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter)41 Text (org.w3c.dom.Text)39 INodeNotifier (org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)35 IJSPTranslation (org.eclipse.jst.jsp.core.internal.java.IJSPTranslation)28 IOException (java.io.IOException)26 CoreException (org.eclipse.core.runtime.CoreException)26 JSPTranslationAdapter (org.eclipse.jst.jsp.core.internal.java.JSPTranslationAdapter)26 INodeAdapter (org.eclipse.wst.sse.core.internal.provisional.INodeAdapter)25