use of org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler in project webtools.sourceediting by eclipse.
the class ModelManagerImpl method createUnManagedEmptyModelFor.
/**
* @param iFile
* @param result
* @return
* @throws CoreException
*/
private IStructuredModel createUnManagedEmptyModelFor(IFile iFile) throws CoreException {
IStructuredModel result = null;
IModelHandler handler = calculateType(iFile);
String id = calculateId(iFile);
URIResolver resolver = calculateURIResolver(iFile);
try {
result = _commonCreateModel(id, handler, resolver);
} catch (ResourceInUse e) {
// this may need to be re-examined.
if (Logger.DEBUG_MODELMANAGER)
// $NON-NLS-1$ //$NON-NLS-2$
Logger.log(Logger.INFO, "ModelMangerImpl::createUnManagedStructuredModelFor. Model unexpectedly in use.");
}
return result;
}
use of org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler in project webtools.sourceediting by eclipse.
the class ModelManagerImpl method _commonGetModel.
private IStructuredModel _commonGetModel(IFile iFile, ReadEditType rwType, EncodingRule encodingRule) throws UnsupportedEncodingException, IOException, CoreException {
IStructuredModel model = null;
if (iFile != null && iFile.exists()) {
String id = calculateId(iFile);
IModelHandler handler = calculateType(iFile);
URIResolver resolver = calculateURIResolver(iFile);
model = _commonCreateModel(iFile, id, handler, resolver, rwType, encodingRule);
}
return model;
}
use of org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler in project webtools.sourceediting by eclipse.
the class ModelManagerImpl method getModelForRead.
public IStructuredModel getModelForRead(String id, InputStream inputStream, URIResolver resolver) throws IOException {
InputStream istream = Utilities.getMarkSupportedStream(inputStream);
IModelHandler handler = calculateType(id, istream);
IStructuredModel result = null;
result = _commonCreateModel(istream, id, handler, resolver, READ, null, null);
return result;
}
use of org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler in project webtools.sourceediting by eclipse.
the class ModelManagerImpl method createNewInstance.
/**
* Similar to clone, except the new instance has no content. Note: this
* produces an unmanaged model, for temporary use. If a true shared model
* is desired, use "copy".
*/
public IStructuredModel createNewInstance(IStructuredModel oldModel) throws IOException {
IModelHandler handler = oldModel.getModelHandler();
IModelLoader loader = handler.getModelLoader();
IStructuredModel newModel = loader.createModel(oldModel);
newModel.setModelHandler(handler);
if (newModel instanceof AbstractStructuredModel) {
((AbstractStructuredModel) newModel).setContentTypeIdentifier(oldModel.getContentTypeIdentifier());
}
URIResolver oldResolver = oldModel.getResolver();
if (oldResolver instanceof URIResolverExtension) {
oldResolver = ((URIResolverExtension) oldResolver).newInstance();
}
newModel.setResolver(oldResolver);
try {
newModel.setId(DUPLICATED_MODEL);
} catch (ResourceInUse e) {
// impossible, since this is an unmanaged model
}
// base location should be null, but we'll set to
// null to be sure.
newModel.setBaseLocation(null);
return newModel;
}
use of org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler 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;
}
Aggregations