Search in sources :

Example 11 with PageDirectiveAdapter

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);
}
Also used : IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) PageDirectiveAdapter(org.eclipse.jst.jsp.core.internal.document.PageDirectiveAdapter)

Example 12 with PageDirectiveAdapter

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);
}
Also used : EmbeddedTypeHandler(org.eclipse.wst.sse.core.internal.ltk.modelhandler.EmbeddedTypeHandler) IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) EmbeddedXML(org.eclipse.wst.xml.core.internal.modelhandler.EmbeddedXML) PageDirectiveAdapter(org.eclipse.jst.jsp.core.internal.document.PageDirectiveAdapter) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)

Example 13 with PageDirectiveAdapter

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);
}
Also used : ModelQueryAdapter(org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapter) IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) Node(org.w3c.dom.Node) PageDirectiveAdapter(org.eclipse.jst.jsp.core.internal.document.PageDirectiveAdapter) INodeNotifier(org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)

Example 14 with PageDirectiveAdapter

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);
}
Also used : IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) IModelManager(org.eclipse.wst.sse.core.internal.provisional.IModelManager) PageDirectiveAdapter(org.eclipse.jst.jsp.core.internal.document.PageDirectiveAdapter) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)

Example 15 with PageDirectiveAdapter

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));
}
Also used : IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) IModelManager(org.eclipse.wst.sse.core.internal.provisional.IModelManager) PageDirectiveAdapter(org.eclipse.jst.jsp.core.internal.document.PageDirectiveAdapter) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)

Aggregations

PageDirectiveAdapter (org.eclipse.jst.jsp.core.internal.document.PageDirectiveAdapter)26 IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)23 Document (org.w3c.dom.Document)10 EmbeddedTypeHandler (org.eclipse.wst.sse.core.internal.ltk.modelhandler.EmbeddedTypeHandler)9 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)9 IModelManager (org.eclipse.wst.sse.core.internal.provisional.IModelManager)6 IDOMDocument (org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)6 INodeNotifier (org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)5 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)4 ModelQuery (org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery)3 ModelQueryAdapter (org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapter)3 Node (org.w3c.dom.Node)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 IFile (org.eclipse.core.resources.IFile)2 IProject (org.eclipse.core.resources.IProject)2 IDocument (org.eclipse.jface.text.IDocument)2 PageDirectiveAdapterFactory (org.eclipse.jst.jsp.core.internal.document.PageDirectiveAdapterFactory)2 NodeList (org.w3c.dom.NodeList)2 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1