use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class TestContentFormatter method getModelForEdit.
/**
* must release model (from edit) after
*
* @param filename
* relative to this class (TestFormatProcessorCSS)
*/
private IStructuredModel getModelForEdit(final String filename) {
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(filename));
assertTrue("unable to find file: " + filename, file.exists());
IStructuredModel model = null;
try {
IModelManager modelManager = StructuredModelManager.getModelManager();
model = modelManager.getModelForEdit(file);
} catch (CoreException ce) {
ce.printStackTrace();
} catch (IOException io) {
io.printStackTrace();
}
return model;
}
use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class TestModelRelease method testJSPModel.
public void testJSPModel() {
IModelManager modelManager = getModelManager();
IDOMModel structuredModel = (IDOMModel) modelManager.createUnManagedStructuredModelFor(ContentTypeIdForJSP.ContentTypeID_JSP);
boolean test = structuredModel.getId().equals(IModelManager.UNMANAGED_MODEL);
assertTrue(test);
// even though model is unmanaged, release still required, since
// adapter factories, etc., may be depending on it.
structuredModel.releaseFromEdit();
// if above complete's normally (with no exceptions)
// consider passed.
assertTrue(true);
}
use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class JSPedCSSSourceParserTest method createModel.
private ICSSModel createModel(boolean isFragment) {
IStructuredModel model = null;
try {
IModelManager modelManager = StructuredModelManager.getModelManager();
model = // $NON-NLS-1$
!isFragment ? // $NON-NLS-1$
modelManager.getModelForEdit("cssjsptest" + index_jsp++ + ".jsp", new NullInputStream(), null) : // $NON-NLS-1$
modelManager.getModelForEdit("cssjsptest" + index_jspf++ + ".jspf", new NullInputStream(), null);
// $NON-NLS-1$
model.getStructuredDocument().setLineDelimiter(commonEOL);
} catch (Exception e) {
StringWriter s = new StringWriter();
e.printStackTrace(new PrintWriter(s));
fail(s.toString());
}
return (ICSSModel) model;
}
use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class TestStructuredDocumentClone method testCloneStructuredDocumentXML.
public void testCloneStructuredDocumentXML() throws IOException {
// First make (empty) structuredDocument
IModelManager modelManager = StructuredModelManager.getModelManager();
IStructuredDocument structuredDocument = modelManager.createStructuredDocumentFor("dummy.xml", (InputStream) null, null);
assertTrue("structuredDocument could not be created!", structuredDocument != null);
IStructuredDocument clonedStructuredDocument = structuredDocument.newInstance();
// make sure the critical variables are NOT identical, but that new instances
// have been made
boolean passed = true;
if (clonedStructuredDocument.getEncodingMemento() == structuredDocument.getEncodingMemento())
passed = false;
if (clonedStructuredDocument.getParser() == structuredDocument.getParser())
passed = false;
if (clonedStructuredDocument.getReParser() == structuredDocument.getReParser())
passed = false;
assertTrue("newInstance of XML structuredDocument is not correct", passed);
}
use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class TestStructuredDocumentClone method testCloneStructuredDocumentJSP.
/**
* This test is most useful to check breakpoints and dig deep in object
* to check clones values
*/
public void testCloneStructuredDocumentJSP() throws IOException {
// First make (empty) structuredDocument
IModelManager modelManager = StructuredModelManager.getModelManager();
IStructuredDocument structuredDocument = modelManager.createStructuredDocumentFor("dummy.jsp", (InputStream) null, null);
assertTrue("structuredDocument could not be created!", structuredDocument != null);
IStructuredDocument clonedStructuredDocument = structuredDocument.newInstance();
// make sure the critical variables are NOT identical, but that new instances
// have been made
boolean passed = true;
if (clonedStructuredDocument.getEncodingMemento() == structuredDocument.getEncodingMemento())
passed = false;
if (clonedStructuredDocument.getParser() == structuredDocument.getParser())
passed = false;
if (clonedStructuredDocument.getReParser() == structuredDocument.getReParser())
passed = false;
assertTrue("newInstance of JSP structuredDocument is not correct", passed);
}
Aggregations