use of org.eclipse.jst.jsp.core.internal.document.PageDirectiveAdapter in project webtools.sourceediting by eclipse.
the class TestPageDirective method testRelease.
public void testRelease() {
IDOMModel model = createUnmanagedHTMLModel();
PageDirectiveAdapter pageDirectiveAdapter = (PageDirectiveAdapter) model.getDocument().getAdapterFor(PageDirectiveAdapter.class);
pageDirectiveAdapter.release();
// considered "success" if doesn't through exception
assertTrue(true);
}
use of org.eclipse.jst.jsp.core.internal.document.PageDirectiveAdapter in project webtools.sourceediting by eclipse.
the class TestPageDirective method testSetEmbeddedType.
public void testSetEmbeddedType() {
IStructuredModel model = createUnmanagedHTMLModel();
PageDirectiveAdapter pageDirectiveAdapter = (PageDirectiveAdapter) ((IDOMModel) model).getDocument().getAdapterFor(PageDirectiveAdapter.class);
EmbeddedTypeHandler embeddedXMLHandler = new EmbeddedXML();
pageDirectiveAdapter.setEmbeddedType(embeddedXMLHandler);
EmbeddedTypeHandler handler = pageDirectiveAdapter.getEmbeddedType();
assertTrue("incorrect embedded handler", handler == embeddedXMLHandler);
}
use of org.eclipse.jst.jsp.core.internal.document.PageDirectiveAdapter in project webtools.sourceediting by eclipse.
the class TestPageDirective method testAdapt.
public void testAdapt() {
IDOMModel model = createUnmanagedHTMLModel();
PageDirectiveAdapter pageDirectiveAdapter = (PageDirectiveAdapter) model.getDocument().getAdapterFor(PageDirectiveAdapter.class);
Node ownerNode = model.getDocument();
ModelQueryAdapter embeddedAdapter = (ModelQueryAdapter) pageDirectiveAdapter.adapt((INodeNotifier) ownerNode, ModelQueryAdapter.class);
assertNotNull("could not adapt embedded adapter", embeddedAdapter);
}
use of org.eclipse.jst.jsp.core.internal.document.PageDirectiveAdapter 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.jst.jsp.core.internal.document.PageDirectiveAdapter 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));
}
Aggregations