use of org.eclipse.wst.sse.core.internal.document.IDocumentLoader in project webtools.sourceediting by eclipse.
the class ModelManagerImpl method createStructuredDocumentFor.
/**
* Factory method, since a proper IStructuredDocument must have a proper
* parser assigned. Note: clients should verify IFile exists before using
* this method. If this IFile does not exist, then
* createNewStructuredDocument is the correct API to use.
*
* @throws ResourceInUse
*/
public IStructuredDocument createStructuredDocumentFor(IFile iFile) throws IOException, CoreException {
if (!iFile.exists()) {
throw new FileNotFoundException(iFile.getFullPath().toOSString());
}
// Will reconsider in future version
// String id = calculateId(iFile);
// if (isResourceInUse(id)) {
// throw new ResourceInUse(iFile.getFullPath().toOSString());
// }
IDocumentLoader loader = null;
IModelHandler handler = calculateType(iFile);
loader = handler.getDocumentLoader();
IStructuredDocument result = (IStructuredDocument) loader.createNewStructuredDocument(iFile);
return result;
}
use of org.eclipse.wst.sse.core.internal.document.IDocumentLoader in project webtools.sourceediting by eclipse.
the class ModelManagerImpl method createStructuredDocumentFor.
/**
* Convenience method. This method can be used when the resource does not
* really exist (e.g. when content is being created, but hasn't been
* written to disk yet). Note that since the content is being provided as
* a String, it is assumed to already be decoded correctly so no
* transformation is done.
*/
public IStructuredDocument createStructuredDocumentFor(String filename, String content, URIResolver resolver) throws IOException {
IDocumentLoader loader = null;
IModelHandler handler = calculateType(filename, null);
loader = handler.getDocumentLoader();
IStructuredDocument result = (IStructuredDocument) loader.createNewStructuredDocument();
result.setEncodingMemento(new NullMemento());
result.setText(this, content);
return result;
}
use of org.eclipse.wst.sse.core.internal.document.IDocumentLoader 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;
}
Aggregations