Search in sources :

Example 16 with EmbeddedTypeHandler

use of org.eclipse.wst.sse.core.internal.ltk.modelhandler.EmbeddedTypeHandler 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 17 with EmbeddedTypeHandler

use of org.eclipse.wst.sse.core.internal.ltk.modelhandler.EmbeddedTypeHandler 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);
}
Also used : EmbeddedTypeHandler(org.eclipse.wst.sse.core.internal.ltk.modelhandler.EmbeddedTypeHandler) IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) IModelManager(org.eclipse.wst.sse.core.internal.provisional.IModelManager) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) Document(org.w3c.dom.Document)

Example 18 with EmbeddedTypeHandler

use of org.eclipse.wst.sse.core.internal.ltk.modelhandler.EmbeddedTypeHandler in project webtools.sourceediting by eclipse.

the class TestModelEmbeddedContentType method checkEmbeddedType.

protected void checkEmbeddedType(IStructuredModel clonedModel, Object expectedType) {
    Document doc = ((IDOMModel) clonedModel).getDocument();
    PageDirectiveAdapter embeddedTypeAdapter = (PageDirectiveAdapter) ((INodeNotifier) doc).getAdapterFor(PageDirectiveAdapter.class);
    assertNotNull("cloned model did not have embedded adapter", embeddedTypeAdapter);
    EmbeddedTypeHandler embeddedHandler = embeddedTypeAdapter.getEmbeddedType();
    assertNotNull("cloned model did not have embedded handler", embeddedHandler);
    assertTrue("cloned model embeddedHandler is wrong type", embeddedHandler.equals(expectedType));
}
Also used : EmbeddedTypeHandler(org.eclipse.wst.sse.core.internal.ltk.modelhandler.EmbeddedTypeHandler) IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) PageDirectiveAdapter(org.eclipse.jst.jsp.core.internal.document.PageDirectiveAdapter) Document(org.w3c.dom.Document)

Example 19 with EmbeddedTypeHandler

use of org.eclipse.wst.sse.core.internal.ltk.modelhandler.EmbeddedTypeHandler in project webtools.sourceediting by eclipse.

the class TestModelClone method testCloneStructuredModelJSP.

public void testCloneStructuredModelJSP() 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);
    IStructuredModel clonedModel = model.newInstance();
    assertTrue("cloned model could not be created!", clonedModel != null);
    // make sure the embedded type is correct
    boolean passed = true;
    Document doc = ((IDOMModel) clonedModel).getDocument();
    PageDirectiveAdapter pageDirectiveAdapter = (PageDirectiveAdapter) ((INodeNotifier) doc).getExistingAdapter(PageDirectiveAdapter.class);
    assertNotNull("cloned model did not have embedded adapter", pageDirectiveAdapter);
    EmbeddedTypeHandler embeddedHandler = pageDirectiveAdapter.getEmbeddedType();
    assertNotNull("cloned model did not have embedded handler", embeddedHandler);
    // if (clonedModel.getEncodingMemento() == model.getEncodingMemento()) passed = false;
    // if (clonedModel.getParser() == model.getParser()) passed = false;
    // if (clonedModel.getReParser() == model.getReParser()) passed = false;
    assertTrue("newInstance of structured model is not correct", passed);
}
Also used : EmbeddedTypeHandler(org.eclipse.wst.sse.core.internal.ltk.modelhandler.EmbeddedTypeHandler) 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) Document(org.w3c.dom.Document)

Example 20 with EmbeddedTypeHandler

use of org.eclipse.wst.sse.core.internal.ltk.modelhandler.EmbeddedTypeHandler in project webtools.sourceediting by eclipse.

the class EmbeddedTypeRegistryReader method readElement.

protected EmbeddedTypeHandler readElement(IConfigurationElement element) {
    EmbeddedTypeHandler contentTypeDescription = null;
    if (element.getName().equals(TAG_NAME)) {
        try {
            contentTypeDescription = (EmbeddedTypeHandler) element.createExecutableExtension(ATT_CLASS);
        } catch (Exception e) {
            Logger.logException(e);
        }
    }
    // $NON-NLS-1$
    Assert.isNotNull(contentTypeDescription, "Error reading content type description");
    return contentTypeDescription;
}
Also used : EmbeddedTypeHandler(org.eclipse.wst.sse.core.internal.ltk.modelhandler.EmbeddedTypeHandler)

Aggregations

EmbeddedTypeHandler (org.eclipse.wst.sse.core.internal.ltk.modelhandler.EmbeddedTypeHandler)24 IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)11 PageDirectiveAdapter (org.eclipse.jst.jsp.core.internal.document.PageDirectiveAdapter)9 Document (org.w3c.dom.Document)9 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)6 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)5 IModelManager (org.eclipse.wst.sse.core.internal.provisional.IModelManager)3 BasicStructuredDocument (org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 IFile (org.eclipse.core.resources.IFile)2 IProject (org.eclipse.core.resources.IProject)2 IContentDescription (org.eclipse.core.runtime.content.IContentDescription)2 JSPReParser (org.eclipse.jst.jsp.core.internal.parser.JSPReParser)2 EmbeddedTypeRegistry (org.eclipse.wst.sse.core.internal.modelhandler.EmbeddedTypeRegistry)2 IDOMDocument (org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)2 Reader (java.io.Reader)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CoreException (org.eclipse.core.runtime.CoreException)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1