Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » resource tree is locked
resource tree is locked [message #113185] Wed, 20 August 2003 13:04 Go to next message
Eclipse UserFriend
Originally posted by: bob.donovan.eds.com

Hi,

In my plugins, I have written a method that listens for delete events
being sent from IResourceDeltaVisitor. When I detect a delete event for a
file, I check to see if the file name is included in another file which
lists the includes (def file). If so, then I edit the definition file and
remove the include statement. When I do this, I get a traceback (see
bottom) complaining about the resource tree being locked??

My method that hanldes the delete is called handleFileDeleted() and it
uses a syncExec message to run on a thread. I though this would solve the
problem with the resource tree being locked but it doesn't.

Any ideas?

Bob


public void handleFileDeleted(final IFile file) {
ServerPlugin.getDisplay().syncExec(new Runnable() {
...

(traceback)

java.lang.RuntimeException: The resource tree is locked for modifications.
at
org.eclipse.ui.internal.UIWorkspaceLock.acquire(UIWorkspaceL ock.java:38)
at
org.eclipse.core.internal.resources.WorkManager.checkIn(Work Manager.java:79)
at
org.eclipse.core.internal.resources.Workspace.prepareOperati on(Workspace.java:1558)
at org.eclipse.core.internal.resources.File.setContents(File.ja va:264)
at org.eclipse.core.internal.resources.File.setContents(File.ja va:305)
at
com.edsplm.tc.ide.base.util.BasicResourceUtil.setContents(Ba sicResourceUtil.java:381)
at
com.edsplm.tc.ide.base.util.BasicResourceUtil.setConents(Bas icResourceUtil.java:446)
at
com.edsplm.tc.ide.base.util.BasicResourceUtil.replaceSection FromFile(BasicResourceUtil.java:499)
at
com.edsplm.tc.ent.ide.server.util.ServerResourceUtil.removeM odelFileToCustomDefinitionFile(ServerResourceUtil.java:999)
at
com.edsplm.tc.ent.ide.server.resourcemodel.ServerResourceMod el$3.run(ServerResourceModel.java:351)
Re: resource tree is locked [message #113349 is a reply to message #113185] Wed, 20 August 2003 19:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: John_Arthorne.oti.com_

As the trace says, you're not allowed to modify the tree during resource
change notifications. It doesn't matter what thread you're in. See
also the thread safety section in:

http://www.eclipse.org/articles/Article-Resource-deltas/reso urce-deltas.html
--


Bob Donovan wrote:
> Hi,
>
> In my plugins, I have written a method that listens for delete events
> being sent from IResourceDeltaVisitor. When I detect a delete event for a
> file, I check to see if the file name is included in another file which
> lists the includes (def file). If so, then I edit the definition file and
> remove the include statement. When I do this, I get a traceback (see
> bottom) complaining about the resource tree being locked??
>
> My method that hanldes the delete is called handleFileDeleted() and it
> uses a syncExec message to run on a thread. I though this would solve the
> problem with the resource tree being locked but it doesn't.
>
> Any ideas?
>
> Bob
>
>
> public void handleFileDeleted(final IFile file) {
> ServerPlugin.getDisplay().syncExec(new Runnable() {
> ..
>
> (traceback)
>
> java.lang.RuntimeException: The resource tree is locked for modifications.
> at
> org.eclipse.ui.internal.UIWorkspaceLock.acquire(UIWorkspaceL ock.java:38)
> at
> org.eclipse.core.internal.resources.WorkManager.checkIn(Work Manager.java:79)
> at
> org.eclipse.core.internal.resources.Workspace.prepareOperati on(Workspace.java:1558)
> at org.eclipse.core.internal.resources.File.setContents(File.ja va:264)
> at org.eclipse.core.internal.resources.File.setContents(File.ja va:305)
> at
> com.edsplm.tc.ide.base.util.BasicResourceUtil.setContents(Ba sicResourceUtil.java:381)
> at
> com.edsplm.tc.ide.base.util.BasicResourceUtil.setConents(Bas icResourceUtil.java:446)
> at
> com.edsplm.tc.ide.base.util.BasicResourceUtil.replaceSection FromFile(BasicResourceUtil.java:499)
> at
> com.edsplm.tc.ent.ide.server.util.ServerResourceUtil.removeM odelFileToCustomDefinitionFile(ServerResourceUtil.java:999)
> at
> com.edsplm.tc.ent.ide.server.resourcemodel.ServerResourceMod el$3.run(ServerResourceModel.java:351)
>
Re: resource tree is locked [message #113939 is a reply to message #113349] Thu, 21 August 2003 11:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bob.donovan.eds.com

John

Thanks for the reply. I read the article and it answered alot of my
questions. It also sparked some thoughts and doubts about the way I am
currently making changes to resources.

1) Should I "always" be wrapping any programmatic changes to resources
inside of a IWorkspaceRunnable? Currently most of my changes to resources
look like they are not inside of any runnable.

2) I have a wizard, that upon performFinish(), I want to run a lengthy
resource operation that writes files, etc. When I use the
IWorkspaceRunnable in performFinish(), a separate IProgressMonitor pops
up. I want to use the wizard's "built in" monitor like other wizards do. I
think that part of the answer is to override needsProgressMonitor() to
return true to get the wizard to use its own monitor.

public boolean needsProgressMonitor() {
return true;
}

I also dug through source code to find that some wizards are using a
WorkspaceModifyOperation operation. When I tried this, I get an "Invalid
thread access" traceback because I am trying to get information from the
SWT widgets on the wizard pages while I am running the
WorkspaceModifyOperation.

Am I heading in the correct direction? Or is there a better way?


Bob



John Arthorne wrote:

> As the trace says, you're not allowed to modify the tree during resource
> change notifications. It doesn't matter what thread you're in. See
> also the thread safety section in:

> http://www.eclipse.org/articles/Article-Resource-deltas/reso urce-deltas.html
> --


> Bob Donovan wrote:
> > Hi,
> >
> > In my plugins, I have written a method that listens for delete events
> > being sent from IResourceDeltaVisitor. When I detect a delete event for a
> > file, I check to see if the file name is included in another file which
> > lists the includes (def file). If so, then I edit the definition file and
> > remove the include statement. When I do this, I get a traceback (see
> > bottom) complaining about the resource tree being locked??
> >
> > My method that hanldes the delete is called handleFileDeleted() and it
> > uses a syncExec message to run on a thread. I though this would solve the
> > problem with the resource tree being locked but it doesn't.
> >
> > Any ideas?
> >
> > Bob
> >
> >
> > public void handleFileDeleted(final IFile file) {
> > ServerPlugin.getDisplay().syncExec(new Runnable() {
> > ..
> >
> > (traceback)
> >
> > java.lang.RuntimeException: The resource tree is locked for modifications.
> > at
> > org.eclipse.ui.internal.UIWorkspaceLock.acquire(UIWorkspaceL ock.java:38)
> > at
> >
org.eclipse.core.internal.resources.WorkManager.checkIn(Work Manager.java:79)
> > at
> >
org.eclipse.core.internal.resources.Workspace.prepareOperati on(Workspace.java:1558)
> > at org.eclipse.core.internal.resources.File.setContents(File.ja va:264)
> > at org.eclipse.core.internal.resources.File.setContents(File.ja va:305)
> > at
> >
com.edsplm.tc.ide.base.util.BasicResourceUtil.setContents(Ba sicResourceUtil.java:381)
> > at
> >
com.edsplm.tc.ide.base.util.BasicResourceUtil.setConents(Bas icResourceUtil.java:446)
> > at
> >
com.edsplm.tc.ide.base.util.BasicResourceUtil.replaceSection FromFile(BasicResourceUtil.java:499)
> > at
> >
com.edsplm.tc.ent.ide.server.util.ServerResourceUtil.removeM odelFileToCustomDefinitionFile(ServerResourceUtil.java:999)
> > at
> >
com.edsplm.tc.ent.ide.server.resourcemodel.ServerResourceMod el$3.run(ServerResourceModel.java:351)
> >
Re: resource tree is locked [message #114203 is a reply to message #113939] Thu, 21 August 2003 17:00 Go to previous message
Eclipse UserFriend
Originally posted by: John_Arthorne.oti.com_

Bob Donovan wrote:
> 1) Should I "always" be wrapping any programmatic changes to resources
> inside of a IWorkspaceRunnable? Currently most of my changes to resources
> look like they are not inside of any runnable.

If you make more than one change, the answer is yes. Otherwise, you're
triggering a notification/autobuild for every change you make.

>
> 2) I have a wizard, that upon performFinish(), I want to run a lengthy
> resource operation that writes files, etc. When I use the
> IWorkspaceRunnable in performFinish(), a separate IProgressMonitor pops
> up. I want to use the wizard's "built in" monitor like other wizards do. I
> think that part of the answer is to override needsProgressMonitor() to
> return true to get the wizard to use its own monitor.
>
> public boolean needsProgressMonitor() {
> return true;
> }
>
Yes, you should override this method to return true.

> I also dug through source code to find that some wizards are using a
> WorkspaceModifyOperation operation. When I tried this, I get an "Invalid
> thread access" traceback because I am trying to get information from the
> SWT widgets on the wizard pages while I am running the
> WorkspaceModifyOperation.

If you want to use the built in progress monitor, use

IWizard.getContainer().run(true, true, IRunnableWithProgress)

Now the problem is that this takes an IRunnableWithProgress, but you
also need an IWorkspaceRunnable to do the resource batching.
WorkspaceModifyOperation is an adapter object that conforms to
IRunnableWithProgress, but internally it runs an IWorkspaceRunnable. The
short answer: you should subclass WorkspaceModifyOperation, and put all
of your resource changing code in your implementation of the execute
method. Finally, pass this subclass of WorkspaceModifyOperation to the
IWizardContainer.run method. Hope that clears things up...
--
Previous Topic:Running JUnit plug-in tests gives "Could not resolve classpath container: org.eclipse.pde.core.
Next Topic:ANNOUNCE: eclipse visualization tool
Goto Forum:
  


Current Time: Sat Oct 04 04:04:41 EDT 2025

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

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

Back to the top