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();
}
}
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();
}
}
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();
}
}
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);
}
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;
}
Aggregations