Search in sources :

Example 66 with IDOMDocument

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

the class ModelModifications method testRepDocumentHTMLMods.

public void testRepDocumentHTMLMods() throws UnsupportedEncodingException, IOException {
    // assumes 0-byte html empty file
    IDOMModel model = null;
    model = createHTMLModel();
    try {
        IDOMDocument doc = model.getDocument();
        Element ele = doc.createElement(HTML40Namespace.ElementName.P);
        doc.appendChild(ele);
        IStructuredDocument structuredDocument = model.getStructuredDocument();
        structuredDocument.replaceText(this, 0, structuredDocument.getLength(), "<tag>text</tag>");
        Element ele2 = doc.createElement(HTML40Namespace.ElementName.P);
        doc.appendChild(ele2);
    } finally {
        if (model != null) {
            model.releaseFromEdit();
        }
    }
}
Also used : IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) Element(org.w3c.dom.Element) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)

Example 67 with IDOMDocument

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

the class ModelModifications method testRepDocumentJSPMods.

public void testRepDocumentJSPMods() throws UnsupportedEncodingException, IOException {
    // assumes 0-byte html empty file
    IDOMModel model = null;
    model = createJSPModel();
    try {
        IDOMDocument doc = model.getDocument();
        Element ele = doc.createElement(HTML40Namespace.ElementName.P);
        doc.appendChild(ele);
        IStructuredDocument structuredDocument = model.getStructuredDocument();
        structuredDocument.replaceText(this, 0, structuredDocument.getLength(), "<tag>text</tag>");
        Element ele2 = doc.createElement(HTML40Namespace.ElementName.P);
        doc.appendChild(ele2);
    } finally {
        if (model != null) {
            model.releaseFromEdit();
        }
    }
}
Also used : IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) Element(org.w3c.dom.Element) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)

Example 68 with IDOMDocument

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

the class ModelModifications method testSetDocumentXMLMods.

public void testSetDocumentXMLMods() throws UnsupportedEncodingException, IOException {
    // assumes 0-byte html empty file
    IDOMModel model = null;
    model = createXMLModel();
    try {
        IDOMDocument doc = model.getDocument();
        Element ele = doc.createElement(HTML40Namespace.ElementName.P);
        doc.appendChild(ele);
        IStructuredDocument structuredDocument = model.getStructuredDocument();
        structuredDocument.setText(this, "");
        Element ele2 = doc.createElement(HTML40Namespace.ElementName.P);
        doc.appendChild(ele2);
    } finally {
        if (model != null) {
            model.releaseFromEdit();
        }
    }
}
Also used : IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) Element(org.w3c.dom.Element) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)

Example 69 with IDOMDocument

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

the class ModelModifications method testSetDocumentHTMLMods.

public void testSetDocumentHTMLMods() throws UnsupportedEncodingException, IOException {
    // assumes 0-byte html empty file
    IDOMModel model = null;
    model = createHTMLModel();
    try {
        IDOMDocument doc = model.getDocument();
        Element ele = doc.createElement(HTML40Namespace.ElementName.P);
        doc.appendChild(ele);
        IStructuredDocument structuredDocument = model.getStructuredDocument();
        structuredDocument.setText(this, "");
        Element ele2 = doc.createElement(HTML40Namespace.ElementName.P);
        doc.appendChild(ele2);
    } finally {
        if (model != null) {
            model.releaseFromEdit();
        }
    }
}
Also used : IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) Element(org.w3c.dom.Element) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)

Example 70 with IDOMDocument

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

the class ModelModifications method testRepDocumentXMLMods.

public void testRepDocumentXMLMods() throws UnsupportedEncodingException, IOException {
    // assumes 0-byte html empty file
    IDOMModel model = null;
    model = createXMLModel();
    try {
        IDOMDocument doc = model.getDocument();
        Element ele = doc.createElement(HTML40Namespace.ElementName.P);
        doc.appendChild(ele);
        IStructuredDocument structuredDocument = model.getStructuredDocument();
        structuredDocument.replaceText(this, 0, structuredDocument.getLength(), "<tag>text</tag>");
        Element ele2 = doc.createElement(HTML40Namespace.ElementName.P);
        doc.appendChild(ele2);
    } finally {
        if (model != null) {
            model.releaseFromEdit();
        }
    }
}
Also used : IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) Element(org.w3c.dom.Element) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)

Aggregations

IDOMDocument (org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)176 IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)109 IFile (org.eclipse.core.resources.IFile)48 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)39 Element (org.w3c.dom.Element)39 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)33 NodeList (org.w3c.dom.NodeList)27 IStatus (org.eclipse.core.runtime.IStatus)23 Node (org.w3c.dom.Node)21 CoreException (org.eclipse.core.runtime.CoreException)15 ArrayList (java.util.ArrayList)14 IJsTranslation (org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation)14 JsTranslationAdapter (org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter)14 Document (org.w3c.dom.Document)14 IJSPTranslation (org.eclipse.jst.jsp.core.internal.java.IJSPTranslation)12 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)12 IOException (java.io.IOException)11 CMDocument (org.eclipse.wst.xml.core.internal.contentmodel.CMDocument)11 JSPTranslationAdapter (org.eclipse.jst.jsp.core.internal.java.JSPTranslationAdapter)10 IModelManager (org.eclipse.wst.sse.core.internal.provisional.IModelManager)9