Search in sources :

Example 11 with IModelHandler

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

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

the class PositionUpdatingCornerCasesTest method createDocument.

private IDocument createDocument(String contents) {
    IModelHandler handler = ModelHandlerRegistry.getInstance().getHandlerForContentTypeId("org.eclipse.jst.jsp.jspsource");
    BasicStructuredDocument document = (BasicStructuredDocument) handler.getDocumentLoader().createNewStructuredDocument();
    document.set(contents);
    return document;
}
Also used : BasicStructuredDocument(org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument) IModelHandler(org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler)

Example 13 with IModelHandler

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

the class DocumentImpl method isJSPType.

/**
 */
public boolean isJSPType() {
    if (this.model == null)
        return false;
    IModelHandler handler = this.model.getModelHandler();
    if (handler == null)
        return false;
    String id = handler.getAssociatedContentTypeId();
    if (id == null)
        return false;
    // $NON-NLS-1$
    return id.equals("org.eclipse.jst.jsp.core.jspsource");
}
Also used : IModelHandler(org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler)

Example 14 with IModelHandler

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

the class ModelHandlerRegistryTest method testGetHandlerWithDefault.

public void testGetHandlerWithDefault() throws Exception {
    IProject project = setUp(getName());
    IFile file = project.getFile(FILE);
    IModelHandler handler;
    try {
        handler = ModelHandlerRegistry.getInstance().getHandlerFor(file, true);
        assertNotNull("Model handler default should not be null.", handler);
        assertEquals("Proper default model handler was not returned.", handler.getId(), "org.eclipse.wst.xml.core.modelhandler");
    } catch (CoreException e) {
        fail("Caught exception: " + e);
    }
    tearDown(getName());
}
Also used : IFile(org.eclipse.core.resources.IFile) CoreException(org.eclipse.core.runtime.CoreException) IModelHandler(org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler) IProject(org.eclipse.core.resources.IProject)

Example 15 with IModelHandler

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

the class ModelHandlerRegistryTest method testGetHandlerWithoutDefault.

public void testGetHandlerWithoutDefault() throws Exception {
    IProject project = setUp(getName());
    IFile file = project.getFile(FILE);
    IModelHandler handler;
    try {
        handler = ModelHandlerRegistry.getInstance().getHandlerFor(file, false);
        assertNull("Model handler should not have returned a handler.", handler);
    } catch (CoreException e) {
        fail("Caught exception: " + e);
    }
    tearDown(getName());
}
Also used : IFile(org.eclipse.core.resources.IFile) CoreException(org.eclipse.core.runtime.CoreException) IModelHandler(org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler) IProject(org.eclipse.core.resources.IProject)

Aggregations

IModelHandler (org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler)41 ModelHandlerRegistry (org.eclipse.wst.sse.core.internal.modelhandler.ModelHandlerRegistry)14 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)9 CoreException (org.eclipse.core.runtime.CoreException)6 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)6 IContentType (org.eclipse.core.runtime.content.IContentType)5 IModelLoader (org.eclipse.wst.sse.core.internal.provisional.IModelLoader)5 InputStream (java.io.InputStream)4 IFile (org.eclipse.core.resources.IFile)4 IDocumentLoader (org.eclipse.wst.sse.core.internal.document.IDocumentLoader)4 ResourceInUse (org.eclipse.wst.sse.core.internal.provisional.exceptions.ResourceInUse)4 IOException (java.io.IOException)3 IProject (org.eclipse.core.resources.IProject)3 BasicStructuredDocument (org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument)3 URIResolver (org.eclipse.wst.sse.core.internal.util.URIResolver)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)2 IDocument (org.eclipse.jface.text.IDocument)2 IStructuredDocumentRegion (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)2