Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to completely remove a Resource from a ResourceSet?
How to completely remove a Resource from a ResourceSet? [message #1755254] Wed, 01 March 2017 16:58 Go to next message
Philipp Heisig is currently offline Philipp HeisigFriend
Messages: 26
Registered: November 2014
Junior Member

I (programmatically) added some models to a wrong ResourceSet, which I want now to remove. As I couldn't find out where this information are stored or how to remove them via the Eclipse GUI, I tried to solve that programmatically by this code snippet:

ResourceSet resourceSet = pc.eResource().getResourceSet();
	     for (Resource res : resourceSet.getResources()) {
			if(!(resff instanceof XMIResourceImpl)){
			try {
				resff.delete(((XMLResource) resff).getDefaultLoadOptions());
			} catch (IOException e) {
				// TODO Auto-generated catch block

However, it seems that something happened, but now I always the error "Problems encountered in file..... - Resource .. does not exist" when some action on the ResourceSet (e.g. open a (not deleted) model from the ResourceSet) occurs.


I'm wondering how I completely remove the resources from the ResourceSet?

[Updated on: Wed, 01 March 2017 17:04]

Report message to a moderator

Re: How to completely remove a Resource from a ResourceSet? [message #1755262 is a reply to message #1755254] Wed, 01 March 2017 18:07 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 31955
Registered: July 2009
Senior Member
You're question is quite free of of any relevant context... In any case, resourceSet.getResources().remove(resource) will remove a resource from a resource set. The code you're showing would delete the underlying resource's contents from the file system, if it exists, but would not remove the resource from the resource set. The third URI looks very bogus, so probably nothing really exists at this URI.

Ed Merks
Professional Support:
Previous Topic:Xtext validation fails on travis-ci
Next Topic:genmodel ->.editor-> run as
Goto Forum:

Current Time: Fri Jul 23 20:26:48 GMT 2021

Powered by FUDForum. Page generated in 0.01584 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top