use of org.eclipse.wst.sse.core.internal.util.URIResolverExtension 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;
}
Aggregations