use of org.eclipse.wst.sse.core.internal.provisional.exceptions.ResourceInUse in project webtools.sourceediting by eclipse.
the class TestModelManager method testCopyJSPModelForEdit.
public void testCopyJSPModelForEdit() throws IOException {
IStructuredModel model = null;
try {
IModelManager modelManager = StructuredModelManager.getModelManager();
model = modelManager.getModelForEdit("test.jsp", new NullInputStream(), null);
IStructuredModel modelCopy = modelManager.copyModelForEdit(model.getId(), getName() + ".newId");
assertNotNull("copied JSP model was null", modelCopy);
assertEquals("ModelHandlers differ", model.getModelHandler(), modelCopy.getModelHandler());
assertEquals("StructuredDocument RegionParsers differ", model.getStructuredDocument().getParser().getClass(), modelCopy.getStructuredDocument().getParser().getClass());
assertEquals("Text document contents differ", model.getStructuredDocument().get(), modelCopy.getStructuredDocument().get());
} catch (ResourceInUse e) {
fail("Resource in use reported for " + model.getId());
} finally {
if (model != null)
model.releaseFromEdit();
}
}
use of org.eclipse.wst.sse.core.internal.provisional.exceptions.ResourceInUse in project webtools.sourceediting by eclipse.
the class URLModelProviderCSS method getNewModelForRead.
public IStructuredModel getNewModelForRead(IFile iFile) {
if (iFile == null)
return null;
IModelManager manager = getModelManager();
if (manager == null)
return null;
IStructuredModel model = null;
try {
model = manager.getNewModelForEdit(iFile, false);
} catch (IOException ex) {
} catch (ResourceInUse riu) {
} catch (ResourceAlreadyExists rae) {
} catch (CoreException ce) {
}
return model;
}
use of org.eclipse.wst.sse.core.internal.provisional.exceptions.ResourceInUse in project webtools.sourceediting by eclipse.
the class URLModelProviderCSS method getNewModelForEdit.
public IStructuredModel getNewModelForEdit(IFile iFile) {
if (iFile == null)
return null;
IModelManager manager = getModelManager();
if (manager == null)
return null;
IStructuredModel model = null;
try {
model = manager.getNewModelForEdit(iFile, false);
} catch (IOException ex) {
} catch (ResourceInUse riu) {
} catch (ResourceAlreadyExists rae) {
} catch (CoreException ce) {
}
return model;
}
use of org.eclipse.wst.sse.core.internal.provisional.exceptions.ResourceInUse 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.provisional.exceptions.ResourceInUse 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