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; }
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); } }