Search in sources :

Example 51 with IStructuredModel

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

the class AbstractStructuredCleanupProcessor method cleanupFileName.

public void cleanupFileName(String fileName) throws IOException, CoreException {
    IStructuredModel structuredModel = null;
    InputStream inputStream = null;
    // OutputStream outputStream = null;
    try {
        // setup structuredModel
        inputStream = new FileInputStream(fileName);
        structuredModel = StructuredModelManager.getModelManager().getModelForRead(fileName, inputStream, null);
        // cleanup
        cleanupModel(structuredModel, 0, structuredModel.getStructuredDocument().getLength());
        // save output to file
        // outputStream = new FileOutputStream(fileName);
        structuredModel.save();
    } finally {
        // release from model manager
        if (structuredModel != null)
            structuredModel.releaseFromRead();
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) FileInputStream(java.io.FileInputStream)

Example 52 with IStructuredModel

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

the class ModelTest method testOKtoReleaseUnmanagedEdit.

public void testOKtoReleaseUnmanagedEdit() {
    IStructuredModel model = null;
    try {
        model = StructuredModelManager.getModelManager().createUnManagedStructuredModelFor("org.eclipse.core.runtime.xml");
        model.getStructuredDocument().set(getName());
    } finally {
        if (model != null)
            model.releaseFromEdit();
    }
}
Also used : IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)

Example 53 with IStructuredModel

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

the class ModelTest method testOKtoReleaseUnmanagedRead.

public void testOKtoReleaseUnmanagedRead() {
    IStructuredModel model = null;
    try {
        model = StructuredModelManager.getModelManager().createUnManagedStructuredModelFor("org.eclipse.core.runtime.xml");
        model.getStructuredDocument().set(getName());
    } finally {
        if (model != null)
            model.releaseFromRead();
    }
}
Also used : IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)

Example 54 with IStructuredModel

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

the class JSONDocumentTest method testModel.

@Test
public void testModel() throws Exception {
    IStructuredModel model = TestUtil.createModel();
    Assert.assertTrue(model instanceof IJSONModel);
    IJSONModel jsonModel = (IJSONModel) model;
    IJSONDocument document = jsonModel.getDocument();
    Assert.assertNotNull(document);
}
Also used : IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) Test(org.junit.Test)

Example 55 with IStructuredModel

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

the class JSONTemplatePreferencePage method doCreateViewer.

SourceViewer doCreateViewer(Composite parent, SourceViewerConfiguration viewerConfiguration) {
    SourceViewer viewer = null;
    String contentTypeID = ContentTypeIdForJSON.ContentTypeID_JSON;
    viewer = new StructuredTextViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    // $NON-NLS-1$
    viewer.getTextWidget().setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont"));
    IStructuredModel scratchModel = StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(contentTypeID);
    IDocument document = scratchModel.getStructuredDocument();
    viewer.configure(viewerConfiguration);
    viewer.setDocument(document);
    return viewer;
}
Also used : ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) SourceViewer(org.eclipse.jface.text.source.SourceViewer) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) StructuredTextViewer(org.eclipse.wst.sse.ui.internal.StructuredTextViewer) IDocument(org.eclipse.jface.text.IDocument)

Aggregations

IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)482 IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)110 IModelManager (org.eclipse.wst.sse.core.internal.provisional.IModelManager)102 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)81 IFile (org.eclipse.core.resources.IFile)75 IOException (java.io.IOException)69 CoreException (org.eclipse.core.runtime.CoreException)49 IDocument (org.eclipse.jface.text.IDocument)46 IDOMDocument (org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)42 InputStream (java.io.InputStream)40 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)36 Path (org.eclipse.core.runtime.Path)35 BadLocationException (org.eclipse.jface.text.BadLocationException)34 IJsTranslation (org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation)32 JsTranslationAdapter (org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter)32 IProject (org.eclipse.core.resources.IProject)31 IndexedRegion (org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)31 IPath (org.eclipse.core.runtime.IPath)27 ByteArrayInputStream (java.io.ByteArrayInputStream)22 Document (org.w3c.dom.Document)19