Search in sources :

Example 6 with EmbeddedTypeHandler

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

the class TestModelEmbeddedContentType method testStructuredModelEmbeddedXML.

public void testStructuredModelEmbeddedXML() 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);
    // XML 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 XML", 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 7 with EmbeddedTypeHandler

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

the class EmbeddedTypeRegistryReader method readRegistry.

/**
 * We simply require an 'add' method, of what ever it is we are to read
 * into
 */
void readRegistry(Set set) {
    IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
    IExtensionPoint point = extensionRegistry.getExtensionPoint(PLUGIN_ID, EXTENSION_POINT_ID);
    if (point != null) {
        IConfigurationElement[] elements = point.getConfigurationElements();
        for (int i = 0; i < elements.length; i++) {
            EmbeddedTypeHandler embeddedContentType = readElement(elements[i]);
            // element
            if (embeddedContentType != null) {
                set.add(embeddedContentType);
            }
        }
    }
}
Also used : EmbeddedTypeHandler(org.eclipse.wst.sse.core.internal.ltk.modelhandler.EmbeddedTypeHandler) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 8 with EmbeddedTypeHandler

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

the class ModelHandlerUtility method getEmbeddedContentTypeFor.

public static EmbeddedTypeHandler getEmbeddedContentTypeFor(String string) {
    EmbeddedTypeHandler instance = null;
    instance = EmbeddedTypeRegistryImpl.getInstance().getTypeFor(string);
    return instance;
}
Also used : EmbeddedTypeHandler(org.eclipse.wst.sse.core.internal.ltk.modelhandler.EmbeddedTypeHandler)

Example 9 with EmbeddedTypeHandler

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

the class JSPModelLoader method reinitialize.

public IStructuredModel reinitialize(IStructuredModel model) {
    EmbeddedTypeHandler oldHandler = null;
    EmbeddedTypeHandler newHandler = null;
    Object reinitStateData = model.getReinitializeStateData();
    if (reinitStateData instanceof EmbeddedTypeStateData) {
        EmbeddedTypeStateData oldStateData = (EmbeddedTypeStateData) reinitStateData;
        oldHandler = oldStateData.getOldHandler();
        newHandler = oldStateData.getNewHandler();
        // note. We should already have the new handler in the model's
        // (documents) adapters,
        // so need need to use the old one to undo the old state data
        reInitializeEmbeddedType(model, oldHandler, newHandler);
    } else {
    // for language ... we someday MIGHT have to do something
    // here, but for now, we don't have any model-side language
    // sensitive adapters.
    }
    return super.reinitialize(model);
}
Also used : EmbeddedTypeHandler(org.eclipse.wst.sse.core.internal.ltk.modelhandler.EmbeddedTypeHandler)

Example 10 with EmbeddedTypeHandler

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

the class JSPModelLoader method initEmbeddedType.

/**
 * As part of the model cloning process, ensure that the new model has the
 * same embedded content type handler as the old model, and that it is
 * properly initialized
 */
protected void initEmbeddedType(IStructuredModel oldModel, IStructuredModel newModel) {
    EmbeddedTypeHandler existingEmbeddedType = getEmbeddedType(oldModel);
    if (existingEmbeddedType == null) {
        initEmbeddedTypePre(newModel, newModel.getStructuredDocument());
        initEmbeddedTypePost(newModel);
    } else {
        EmbeddedTypeHandler newEmbeddedContentType = existingEmbeddedType.newInstance();
        // initEmbeddedType(newModel);
        initCloneOfEmbeddedType(newModel, existingEmbeddedType, newEmbeddedContentType);
        setLanguageInPageDirective(newModel);
    }
}
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