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);
}
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);
}
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));
}
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);
}
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;
}
Aggregations