org.eclipse.emf.ecore.resource.Resource.Factory Java Examples

The following examples show how to use org.eclipse.emf.ecore.resource.Resource.Factory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ResourceUtil.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
public static Resource loadResource(String filename) {
	URI uri = URI.createPlatformResourceURI(filename, true);
	Factory factory = ResourceFactoryRegistryImpl.INSTANCE.getFactory(uri);
	Resource resource = factory.createResource(uri);
	ResourceSet resourceSet = new ResourceSetImpl();
	resourceSet.getResources().add(resource);
	try {
		resource.load(Collections.EMPTY_MAP);
		return resource;
	} catch (IOException e) {
		throw new IllegalStateException("Error loading resource", e);
	}
}
 
Example #2
Source File: SimulationImageRenderer.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
private Resource reload(IFile file) {
	final URI uri = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
	Factory factory = ResourceFactoryRegistryImpl.INSTANCE.getFactory(uri);
	Resource resource = factory.createResource(uri);
	ResourceSet resourceSet = new ResourceSetImpl();
	TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain(resourceSet);
	resourceSet.getResources().add(resource);
	try {
		resource.load(Collections.EMPTY_MAP);
	} catch (IOException e) {
		throw new IllegalStateException("Error loading resource", e);
	}
	return resource;
}
 
Example #3
Source File: EncodingTest.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
protected XtextResource createXtextResource() {
	URI resourceURI = URI.createURI("test.encodingtestlanguage");
	Factory factory = Resource.Factory.Registry.INSTANCE.getFactory(resourceURI);
	XtextResource resource = (XtextResource) factory.createResource(resourceURI);
	return resource;
}
 
Example #4
Source File: Bug306325Test.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
protected XtextResource createXtextResource() {
	URI resourceURI = URI.createURI("test.encodingtestlanguage");
	Factory factory = Resource.Factory.Registry.INSTANCE.getFactory(resourceURI);
	XtextResource resource = (XtextResource) factory.createResource(resourceURI);
	return resource;
}