Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » ResourceException: Problems encountered while deleting resources
ResourceException: Problems encountered while deleting resources [message #275141] Thu, 04 November 2004 03:46 Go to next message
Eclipse UserFriend
Originally posted by: gary.kindorf.honeywell.com

My Vitals:
WinXP, Version: 3.0.1
Build id: 200409161125

My Problem:

I have a custom nature that is installed when my custom project type is
created. My mission is to implement a policy whereby only certain types
of files can be added to the project (I am using DnD and the default
Import wizard to add files to the project).

My approach has been to install a resource change listener that listens
for PRE_BUILD (PRE_BUILD says the workspace is not locked). The delta
visitor then checks each file, and if it finds an "illegal" one, it tries
to delete it.

int mask = IResourceChangeEvent.PRE_BUILD;
workspace.addResourceChangeListener(new MYResourceChangeListener(),
mask);

...

public class MYResourceChangeListener implements IResourceChangeListener {
public MYResourceChangeListener() {
super();
}

public void resourceChanged(IResourceChangeEvent event) {
switch (event.getType()) {
case IResourceChangeEvent.PRE_BUILD:
...
event.getDelta().accept( new MYResourceDeltaVisitor() );
...


public class MYResourceDeltaVisitor implements IResourceDeltaVisitor {
public ITResourceDeltaVisitor() {
super();
}

public boolean visit(IResourceDelta delta) {
IResource res = delta.getResource();
IProject project = res.getProject();
if (project==null || !project.isAccessible()) {
System.out.println("WARN: project==null or !isAccessible");
return true;
}
try {
if (project.hasNature(MYNature.MY_NATURE_ID)) {
IProjectNature projectNature =
project.getNature(MYNature.MY_NATURE_ID);
...
}
else {
// dont care about changes to this project
return false;
}
} catch (CoreException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}

switch (delta.getKind()) {
case IResourceDelta.ADDED:
if (<this file is determined to be inappropriate>) {
try {
res.delete(false, null);
} catch (CoreException e2) {
// TODO Auto-generated catch block
System.out.println("e2 Delete blew");
e2.printStackTrace();
}

I have also tried doing the "delete" call inside a runnable to prevent
event recursion -- all to no avail.

The above snippet returns:

org.eclipse.core.internal.resources.ResourceException: Problems
encountered while deleting resources.
at org.eclipse.core.internal.resources.Resource.delete(Resource .java:683)
at org.eclipse.core.internal.resources.Resource.delete(Resource .java:643)
at
com.honeywell.deos.integrationTool.ITResourceDeltaVisitor.vi sit(ITResourceDeltaVisitor.java:111)
at
org.eclipse.core.internal.events.ResourceDelta.accept(Resour ceDelta.java:68)
at
org.eclipse.core.internal.events.ResourceDelta.accept(Resour ceDelta.java:77)
at
org.eclipse.core.internal.events.ResourceDelta.accept(Resour ceDelta.java:77)
at
org.eclipse.core.internal.events.ResourceDelta.accept(Resour ceDelta.java:49)
at
com.honeywell.deos.integrationTool.ITResourceChangeListener. resourceChanged(ITResourceChangeListener.java:74)
at
org.eclipse.core.internal.events.NotificationManager$2.run(N otificationManager.java:283)
at
org.eclipse.core.internal.runtime.InternalPlatform.run(Inter nalPlatform.java:616)
at org.eclipse.core.runtime.Platform.run(Platform.java:747)
at
org.eclipse.core.internal.events.NotificationManager.notify( NotificationManager.java:277)
at
org.eclipse.core.internal.events.NotificationManager.broadca stChanges(NotificationManager.java:151)
at
org.eclipse.core.internal.events.AutoBuildJob.broadcastChang es(AutoBuildJob.java:78)
at
org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBu ildJob.java:153)
at
org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJ ob.java:212)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:66)
Re: ResourceException: Problems encountered while deleting resources [message #275485 is a reply to message #275141] Mon, 08 November 2004 20:28 Go to previous message
Eclipse UserFriend
Originally posted by: john.eclipsefaq.org

The ResourceException object will contain a MultiStatus object. The
children of this status object should describe at least what file it
failed to delete (or some other cause of the failure). If you write the
entire MultiStatus to the log you should be able to see the details
better. Unfortunately, deletion failure is often hard to diagnose. It
is usually caused by some other thread or process that has an open file
handle on the file being deleted, or a command prompt open on a
directory being deleted.
--

gary kindorf wrote:
> My Vitals:
> WinXP, Version: 3.0.1
> Build id: 200409161125
>
> My Problem:
>
> I have a custom nature that is installed when my custom project type is
> created. My mission is to implement a policy whereby only certain types
> of files can be added to the project (I am using DnD and the default
> Import wizard to add files to the project).
>
> My approach has been to install a resource change listener that listens
> for PRE_BUILD (PRE_BUILD says the workspace is not locked). The delta
> visitor then checks each file, and if it finds an "illegal" one, it
> tries to delete it.
> int mask = IResourceChangeEvent.PRE_BUILD;
> workspace.addResourceChangeListener(new MYResourceChangeListener(), mask);
>
> ..
>
> public class MYResourceChangeListener implements IResourceChangeListener {
> public MYResourceChangeListener() {
> super();
> }
>
> public void resourceChanged(IResourceChangeEvent event) {
> switch (event.getType()) {
> case IResourceChangeEvent.PRE_BUILD:
> ...
> event.getDelta().accept( new MYResourceDeltaVisitor() ); ...
>
>
> public class MYResourceDeltaVisitor implements IResourceDeltaVisitor {
> public ITResourceDeltaVisitor() {
> super();
> }
>
> public boolean visit(IResourceDelta delta) {
> IResource res = delta.getResource();
> IProject project = res.getProject();
> if (project==null || !project.isAccessible()) {
> System.out.println("WARN: project==null or !isAccessible");
> return true;
> }
> try {
> if (project.hasNature(MYNature.MY_NATURE_ID)) {
> IProjectNature projectNature =
> project.getNature(MYNature.MY_NATURE_ID);
> ... }
> else {
> // dont care about changes to this project
> return false;
> }
> } catch (CoreException e1) {
> // TODO Auto-generated catch block
> e1.printStackTrace();
> }
> switch (delta.getKind()) {
> case IResourceDelta.ADDED:
> if (<this file is determined to be inappropriate>) {
> try {
> res.delete(false, null);
> } catch (CoreException e2) {
> // TODO Auto-generated catch block
> System.out.println("e2 Delete blew");
> e2.printStackTrace();
> }
>
> I have also tried doing the "delete" call inside a runnable to prevent
> event recursion -- all to no avail.
>
> The above snippet returns:
>
> org.eclipse.core.internal.resources.ResourceException: Problems
> encountered while deleting resources.
> at
> org.eclipse.core.internal.resources.Resource.delete(Resource .java:683)
> at
> org.eclipse.core.internal.resources.Resource.delete(Resource .java:643)
> at
> com.honeywell.deos.integrationTool.ITResourceDeltaVisitor.vi sit(ITResourceDeltaVisitor.java:111)
>
> at
> org.eclipse.core.internal.events.ResourceDelta.accept(Resour ceDelta.java:68)
>
> at
> org.eclipse.core.internal.events.ResourceDelta.accept(Resour ceDelta.java:77)
>
> at
> org.eclipse.core.internal.events.ResourceDelta.accept(Resour ceDelta.java:77)
>
> at
> org.eclipse.core.internal.events.ResourceDelta.accept(Resour ceDelta.java:49)
>
> at
> com.honeywell.deos.integrationTool.ITResourceChangeListener. resourceChanged(ITResourceChangeListener.java:74)
>
> at
> org.eclipse.core.internal.events.NotificationManager$2.run(N otificationManager.java:283)
>
> at
> org.eclipse.core.internal.runtime.InternalPlatform.run(Inter nalPlatform.java:616)
>
> at org.eclipse.core.runtime.Platform.run(Platform.java:747)
> at
> org.eclipse.core.internal.events.NotificationManager.notify( NotificationManager.java:277)
>
> at
> org.eclipse.core.internal.events.NotificationManager.broadca stChanges(NotificationManager.java:151)
>
> at
> org.eclipse.core.internal.events.AutoBuildJob.broadcastChang es(AutoBuildJob.java:78)
>
> at
> org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBu ildJob.java:153)
>
> at
> org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJ ob.java:212)
> at org.eclipse.core.internal.jobs.Worker.run(Worker.java:66)
>
Previous Topic:Fatal Error in PDE Launch after Eclipse 3.1M3 Upgrade
Next Topic:Update manager - feature patches?
Goto Forum:
  


Current Time: Tue Aug 21 04:04:02 GMT 2018

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

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

Back to the top