Search in sources :

Example 6 with ModelHandlerRegistry

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

the class TestModelHandlers method testHTMLExists.

public void testHTMLExists() {
    String id = ContentTypeIdForHTML.ContentTypeID_HTML;
    ModelHandlerRegistry registry = getModelHandlerRegistry();
    IModelHandler handler = registry.getHandlerForContentTypeId(id);
    assertTrue("model handler registry does not have HTML type ", handler != null && handler.getAssociatedContentTypeId().equals(id));
}
Also used : ModelHandlerRegistry(org.eclipse.wst.sse.core.internal.modelhandler.ModelHandlerRegistry) IModelHandler(org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler)

Example 7 with ModelHandlerRegistry

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

the class TestModelHandlers method testXMLExistsFromFilename.

public void testXMLExistsFromFilename() throws IOException {
    String filename = "test.xml";
    ModelHandlerRegistry registry = getModelHandlerRegistry();
    IModelHandler handler = registry.getHandlerFor(filename, null);
    assertEquals("model handler registry does not have XML type ", ContentTypeIdForXML.ContentTypeID_XML, handler.getAssociatedContentTypeId());
}
Also used : ModelHandlerRegistry(org.eclipse.wst.sse.core.internal.modelhandler.ModelHandlerRegistry) IModelHandler(org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler)

Example 8 with ModelHandlerRegistry

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

the class ModelManagerImpl method calculateType.

private IModelHandler calculateType(IFile iFile) throws CoreException {
    // IModelManager mm = ((ModelManagerPlugin)
    // Platform.getPlugin(ModelManagerPlugin.ID)).getModelManager();
    ModelHandlerRegistry cr = getModelHandlerRegistry();
    IModelHandler cd = cr.getHandlerFor(iFile);
    return cd;
}
Also used : ModelHandlerRegistry(org.eclipse.wst.sse.core.internal.modelhandler.ModelHandlerRegistry) IModelHandler(org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler)

Example 9 with ModelHandlerRegistry

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

the class ModelManagerImpl method createStructuredDocumentFor.

/**
 * Conveience method, since a proper IStructuredDocument must have a
 * proper parser assigned. It should only be used when an empty
 * structuredDocument is needed. Otherwise, use IFile form.
 *
 * @deprecated - TODO: to be removed by C4 do we really need this? I
 *             recommend to - use createStructuredDocumentFor(filename,
 *             null, null) - the filename does not need to represent a
 *             real - file, but can take for form of dummy.jsp, test.xml,
 *             etc. - That way we don't hard code the handler, but specify
 *             we - want the handler that "goes with" a certain type of -
 *             file.
 */
public IStructuredDocument createStructuredDocumentFor(String contentTypeId) {
    IDocumentLoader loader = null;
    ModelHandlerRegistry cr = getModelHandlerRegistry();
    IModelHandler handler = cr.getHandlerForContentTypeId(contentTypeId);
    if (handler == null)
        // $NON-NLS-1$
        Logger.log(Logger.ERROR, "Program error: no model handler found for " + contentTypeId);
    loader = handler.getDocumentLoader();
    IStructuredDocument result = (IStructuredDocument) loader.createNewStructuredDocument();
    return result;
}
Also used : ModelHandlerRegistry(org.eclipse.wst.sse.core.internal.modelhandler.ModelHandlerRegistry) IDocumentLoader(org.eclipse.wst.sse.core.internal.document.IDocumentLoader) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) IModelHandler(org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler)

Example 10 with ModelHandlerRegistry

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

the class TestModelHandlers method testXMLExists.

public void testXMLExists() {
    String id = ContentTypeIdForXML.ContentTypeID_XML;
    ModelHandlerRegistry registry = getModelHandlerRegistry();
    IModelHandler handler = registry.getHandlerForContentTypeId(id);
    assertEquals("model handler registry does not have XML type ", id, handler.getAssociatedContentTypeId());
}
Also used : ModelHandlerRegistry(org.eclipse.wst.sse.core.internal.modelhandler.ModelHandlerRegistry) IModelHandler(org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler)

Aggregations

ModelHandlerRegistry (org.eclipse.wst.sse.core.internal.modelhandler.ModelHandlerRegistry)15 IModelHandler (org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler)14 IDocumentLoader (org.eclipse.wst.sse.core.internal.document.IDocumentLoader)1 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)1 ResourceInUse (org.eclipse.wst.sse.core.internal.provisional.exceptions.ResourceInUse)1 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)1