Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Best way to delete an IResource programmatically
Best way to delete an IResource programmatically [message #1693664] Mon, 27 April 2015 10:36 Go to next message
Alexander R is currently offline Alexander RFriend
Messages: 211
Registered: July 2013
Senior Member
Hi,

I'm developin a plugin which needs to genereate some temporary .xmi-files. After processing these files I would like to delete them from the eclipse project.

I tried the following, but without any success:

WorkspaceModifyOperation deleteOperaton = new WorkspaceModifyOperation() {
			@Override
			protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
			
IProject project =  getProject();
String serializedModelPath = performSerialization(project);	 
cleanTempModels(project, serializedModelPath);
monitor.done();

}
};
deleteOperaton .run(new NullProgressMonitor());

//here the delete
private void cleanTempModels(IProject project, String alfModelPath) {

IFile file = project.getFile(alfModelPath);
boolean isFile = file instanceof IFile;
boolean isAccessable = file.isAccessible();
if (isFile && isAccessable) {
file.delete(true, new NullProgressMonitor());
}
}


The problem is, that my generated tmp-file is not accessable.

What am I doing wrong?

Any ideas are welcome!

~Alex
Re: Best way to delete an IResource programmatically [SOLVED] [message #1693681 is a reply to message #1693664] Mon, 27 April 2015 13:31 Go to previous message
Alexander R is currently offline Alexander RFriend
Messages: 211
Registered: July 2013
Senior Member
Hi,

a resource-set + emf-resource will do the job

ResourceSet set = new ResourceSetImpl();
Resource res = set.getResource(URI.createURI(modelPath), true);
res.delete(null);
Previous Topic:Crash on opening a new plugin editor window
Next Topic:Is it Possible add Editor in MultiPageEditorPart?
Goto Forum:
  


Current Time: Wed Apr 24 20:20:52 GMT 2024

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

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

Back to the top