use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class StructuredDocumentToDOMUnitTests method testNodeDeletion3.
/**
* Unit test -- tests basic parsing results of inserting a test string
* into an initial string.
*/
void testNodeDeletion3() {
String initialString = getTestString3();
// print out what we always can
System.out.println();
System.out.println("----------------");
System.out.println("Test Node Deletion");
String outString = StringUtils.escape(initialString);
System.out.println("Initial String: " + outString);
// always start with fresh model
IStructuredDocument f = null;
IModelManager mm = StructuredModelManager.getModelManager();
try {
f = mm.createStructuredDocumentFor("dummy.xml", (InputStream) null, null);
} catch (IOException e) {
// do nothing, since dummy
}
//
// we'll listen to structuredDocument events to print out diagnostics
f.addDocumentChangedListener(this);
//
IDOMModel tree = new DOMModelImpl();
f.addDocumentChangingListener((IStructuredDocumentListener) tree);
// set text to structuredDocument (which updates tree)
f.setText(null, initialString);
// dump initial structuredDocument
Debug.dump(f);
// dump initial dom
DebugDocument.dump(tree.getDocument());
//
//
// makeChange1(tree);
makeChange3(tree);
// display resulting text
System.out.println("resultString (from structuredDocument): ");
System.out.println(StringUtils.escape(f.getText()));
//
//
// dump post change structuredDocument
Debug.dump(f);
// dump post change DOM
DebugDocument.dump(tree.getDocument());
//
}
use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class TestPageDirective method testBasicChangedPDBack.
public void testBasicChangedPDBack() throws IOException {
// First make (empty) structuredDocument
IModelManager modelManager = StructuredModelManager.getModelManager();
IStructuredModel model = modelManager.createUnManagedStructuredModelFor(ContentTypeIdForJSP.ContentTypeID_JSP);
assertTrue("model could not be created!", model != null);
// Now, assigning use a page directive, but leaving embedded type the same as default
model.getStructuredDocument().setText(this, "<%@ page contentType=\"text/html\" language=\"java\" %>");
PageDirectiveAdapter pageDirectiveAdapter = (PageDirectiveAdapter) ((IDOMModel) model).getDocument().getAdapterFor(PageDirectiveAdapter.class);
String contentType = pageDirectiveAdapter.getContentType();
String language = pageDirectiveAdapter.getLanguage();
assertTrue("contentType should be html", "text/html".equals(contentType));
assertTrue("language should be java", "java".equals(language));
// change to javascript
model.getStructuredDocument().replaceText(this, 43, 4, "javascript");
contentType = pageDirectiveAdapter.getContentType();
language = pageDirectiveAdapter.getLanguage();
assertTrue("contentType should be html", "text/html".equals(contentType));
assertTrue("language should be javascript", "javascript".equals(language));
// change back to java
model.getStructuredDocument().replaceText(this, 43, 10, "java");
contentType = pageDirectiveAdapter.getContentType();
language = pageDirectiveAdapter.getLanguage();
assertTrue("contentType should be html", "text/html".equals(contentType));
assertEquals("java", language);
}
use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class TestPageDirective method testBasicChangedPD.
public void testBasicChangedPD() throws IOException {
// First make (empty) structuredDocument
IModelManager modelManager = StructuredModelManager.getModelManager();
IStructuredModel model = modelManager.createUnManagedStructuredModelFor(ContentTypeIdForJSP.ContentTypeID_JSP);
assertTrue("model could not be created!", model != null);
// Now, assigning use a page directive, but leaving embedded type the same as default
model.getStructuredDocument().setText(this, "<%@ page contentType=\"text/html\" language=\"java\" %>");
PageDirectiveAdapter pageDirectiveAdapter = (PageDirectiveAdapter) ((IDOMModel) model).getDocument().getAdapterFor(PageDirectiveAdapter.class);
String contentType = pageDirectiveAdapter.getContentType();
String language = pageDirectiveAdapter.getLanguage();
assertTrue("contentType should be html", "text/html".equals(contentType));
assertTrue("language should be java", "java".equals(language));
// change to javascript
model.getStructuredDocument().replaceText(this, 43, 4, "javascript");
contentType = pageDirectiveAdapter.getContentType();
language = pageDirectiveAdapter.getLanguage();
assertTrue("contentType should be html", "text/html".equals(contentType));
assertTrue("language should be javascript", "javascript".equals(language));
}
use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class TestPageDirective method createUnmanagedHTMLModel.
private IDOMModel createUnmanagedHTMLModel() {
// First make (empty) structuredDocument
IModelManager modelManager = StructuredModelManager.getModelManager();
IStructuredModel model = modelManager.createUnManagedStructuredModelFor(ContentTypeIdForJSP.ContentTypeID_JSP);
assertTrue("model could not be created!", model != null);
// Now, assigning use a page directive, but leaving embedded type the same as default
model.getStructuredDocument().setText(this, "<%@ page contentType=\"text/html\" language=\"java\" %>");
return (IDOMModel) model;
}
use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class TestModelEmbeddedContentType method testStructuredModelEmbeddedHTML.
public void testStructuredModelEmbeddedHTML() throws IOException {
// First make (empty) structuredDocument
IModelManager modelManager = StructuredModelManager.getModelManager();
IStructuredModel model = modelManager.createUnManagedStructuredModelFor(ContentTypeIdForHTML.ContentTypeID_HTML);
assertTrue("model could not be created!", model != null);
// should NOT have an embedded type
Document doc = ((IDOMModel) model).getDocument();
EmbeddedTypeHandler embeddedHandler = (EmbeddedTypeHandler) ((INodeNotifier) doc).getAdapterFor(EmbeddedTypeHandler.class);
assertTrue("embededHanlder should be null for HTML", embeddedHandler == null);
}
Aggregations