use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class TestModelClone method testCloneStructuredModelJSPXML.
public void testCloneStructuredModelJSPXML() 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);
// note, we initialy expect HTML, since there is not content
checkEmbeddedType(model, EmbeddedHTML.class);
String testContent = "<%@ page contentType=\"text/xml\" %>";
model.getStructuredDocument().setText(this, testContent);
// modified for design change, where re-init should be handled before
// set returns.
assertTrue("model should not need reinit", !model.isReinitializationNeeded());
// but if it did need re-init, here's the right calling sequence
// if (model.isReinitializationNeeded()) {
// model.aboutToChangeModel();
// model = model.reinit();
// model.changedModel();
// }
checkEmbeddedType(model, EmbeddedXML.class);
IStructuredModel clonedModel = model.newInstance();
assertTrue("cloned model could not be created!", clonedModel != null);
checkEmbeddedType(clonedModel, EmbeddedXML.class);
}
use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class TestModelClone method testCreateStructuredModelJSP.
public void testCreateStructuredModelJSP() 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);
ArrayList factories = (ArrayList) model.getFactoryRegistry().getFactories();
factories = (ArrayList) factories.clone();
IStructuredModel clonedModel = model.newInstance();
if (model.getModelHandler() == null) {
System.out.println();
assertTrue(false);
}
assertTrue("cloned model could not be created!", clonedModel != null);
// make sure the critical variables are correct.
ArrayList newFactories = (ArrayList) clonedModel.getFactoryRegistry().getFactories();
newFactories = (ArrayList) newFactories.clone();
boolean passed = checkFactoriesListForIdentity(factories, newFactories);
assertTrue("newInstance of structured model is not correct", passed);
passed = checkForSameEmbeddedFactories(model, clonedModel);
assertTrue("newInstance of structured model is not correct", passed);
// Now, assigning some content shouldn't change the factories
clonedModel.getStructuredDocument().replaceText(this, 0, 0, "<sample> text");
ArrayList twoFactories = (ArrayList) clonedModel.getFactoryRegistry().getFactories();
twoFactories = (ArrayList) twoFactories.clone();
passed = checkFactoriesListForIdentity(factories, twoFactories);
assertTrue("newInstance of structured model is not correct", passed);
passed = checkForSameEmbeddedFactories(model, clonedModel);
assertTrue("newInstance of structured model is not correct", passed);
// Now, assigning use a page directive, but leaving embedded type the same as default
clonedModel.getStructuredDocument().setText(this, "<%@ page contentType=\"text/html\"");
ArrayList threeFactories = (ArrayList) clonedModel.getFactoryRegistry().getFactories();
threeFactories = (ArrayList) threeFactories.clone();
passed = checkFactoriesListForIdentity(factories, threeFactories);
assertTrue("newInstance of structured model is not correct", passed);
passed = checkForSameEmbeddedFactories(model, clonedModel);
assertTrue("newInstance of structured model is not correct", passed);
}
use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class TestModelClone method testCloneStructuredModelXML.
public void testCloneStructuredModelXML() throws IOException {
// First make (empty) structuredDocument
IModelManager modelManager = StructuredModelManager.getModelManager();
IStructuredModel model = modelManager.createUnManagedStructuredModelFor(ContentTypeIdForXML.ContentTypeID_XML);
assertTrue("model could not be created!", model != null);
IStructuredModel clonedModel = model.newInstance();
assertTrue("cloned model could not be created!", clonedModel != null);
// make sure the critical variables are NOT identical, but that new instances
// have been made
boolean passed = true;
// 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.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class TestModelClone method testCreateStructuredModelHTML.
public void testCreateStructuredModelHTML() 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);
ArrayList factories = (ArrayList) model.getFactoryRegistry().getFactories();
factories = (ArrayList) factories.clone();
IStructuredModel clonedModel = model.newInstance();
assertTrue("cloned model could not be created!", clonedModel != null);
// make sure the critical variables are correct.
ArrayList newFactories = (ArrayList) clonedModel.getFactoryRegistry().getFactories();
newFactories = (ArrayList) newFactories.clone();
boolean passed = checkFactoriesListForIdentity(factories, newFactories);
assertTrue("newInstance of structured model is not correct", passed);
// Now, assigning some content shouldn't change the factories
clonedModel.getStructuredDocument().setText(this, "<sample> text");
ArrayList twoFactories = (ArrayList) clonedModel.getFactoryRegistry().getFactories();
twoFactories = (ArrayList) twoFactories.clone();
passed = checkFactoriesListForIdentity(factories, newFactories);
assertTrue("newInstance of structured model is not correct", passed);
}
use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class TestModelClone method testCreateStructuredModelJSPXML.
public void testCreateStructuredModelJSPXML() 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, "<%-- keep JSP page compiler from generating code that accesses the session --%>\n" + "<%@ page session=\"false\" contentType=\"text/xml; charset=ISO-8859-1\" %>\n" + "\n" + "<!-- load WPS portlet tag library and initialize objects -->\n" + "<%@ taglib uri=\"/WEB-INF/tld/portlet.tld\" prefix=\"portletAPI\" %>\n" + "<portletAPI:init /> \n" + "\n" + "<%-- Replace the name of the layout specified by the layoutName attribute of the canvas element below with the layout name for your portlet. --%>\n" + "<canvas xmlns =\"http://www.volantis.com/xmlns/marlin-cdm\" \n" + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \n" + " layoutName=\"/sample_layout.mlyt\" \n" + " type=\"portlet\" >\n" + "\n" + "\n" + "<%-- Specify the pane name from your layout policy as the value for the name attribute of the pane element below --%>\n" + "<pane name=\"sample_pane\">\n" + " <p>Hello!</p>\n" + " <p>This is an XDIME <b>view mode</b> page . You have to edit this page to customize it for your own use.<br/><br/>\n" + " The source file for this page is \"/Web Content/testportlet_legacy/jsp/xdime/TemplateLegacyPortletView.jsp\".\n" + "</p>\n" + "\n" + "<br/>\n" + "This is image 1 \n" + "<img src=\"/paw.mimg\" alt=\"noimg\" />\n" + "\n" + "<br/>\n" + "This is image 2 \n" + "<img src=\"paw.mimg\" alt=\"noimg\" />\n" + "\n" + "</pane>\n" + "</canvas>");
checkEmbeddedType(model, EmbeddedXML.class);
checkModelQuery(model, JSPModelQueryImpl.class);
checkEmbeddedModelQuery(model, JSPModelQueryAdapterImpl.class, JSPModelQueryImpl.class, XMLModelQueryImpl.class);
}
Aggregations