Search in sources :

Example 1 with JobSafeStructuredDocument

use of org.eclipse.wst.sse.core.internal.text.JobSafeStructuredDocument in project liferay-ide by liferay.

the class AlloyJSPDocumentFactory method createDocument.

@Override
public IDocument createDocument() {
    IModelHandler handler = null;
    IContentType contentType = Platform.getContentTypeManager().getContentType("com.liferay.ide.alloy.core.alloyjspsource");
    while ((handler == null) && !IContentTypeManager.CT_TEXT.equals(contentType.getId())) {
        handler = ModelHandlerRegistry.getInstance().getHandlerForContentTypeId(contentType.getId());
        contentType = contentType.getBaseType();
    }
    if (handler != null) {
        return handler.getDocumentLoader().createNewStructuredDocument();
    } else {
        return new JobSafeStructuredDocument();
    }
}
Also used : IContentType(org.eclipse.core.runtime.content.IContentType) JobSafeStructuredDocument(org.eclipse.wst.sse.core.internal.text.JobSafeStructuredDocument) IModelHandler(org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler)

Example 2 with JobSafeStructuredDocument

use of org.eclipse.wst.sse.core.internal.text.JobSafeStructuredDocument in project webtools.sourceediting by eclipse.

the class BasicStructuredDocumentFactory method createDocument.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.core.filebuffers.IDocumentFactory#createDocument()
	 */
public IDocument createDocument() {
    IDocument document = null;
    IContentType contentType = Platform.getContentTypeManager().getContentType(getContentTypeIdentifier());
    IModelHandler handler = null;
    while (handler == null && !IContentTypeManager.CT_TEXT.equals(contentType.getId())) {
        handler = ModelHandlerRegistry.getInstance().getHandlerForContentTypeId(contentType.getId());
        contentType = contentType.getBaseType();
    }
    if (handler != null) {
        document = handler.getDocumentLoader().createNewStructuredDocument();
    } else {
        document = new JobSafeStructuredDocument();
    }
    return document;
}
Also used : IContentType(org.eclipse.core.runtime.content.IContentType) JobSafeStructuredDocument(org.eclipse.wst.sse.core.internal.text.JobSafeStructuredDocument) IModelHandler(org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler) IDocument(org.eclipse.jface.text.IDocument)

Aggregations

IContentType (org.eclipse.core.runtime.content.IContentType)2 IModelHandler (org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler)2 JobSafeStructuredDocument (org.eclipse.wst.sse.core.internal.text.JobSafeStructuredDocument)2 IDocument (org.eclipse.jface.text.IDocument)1