Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Delaying resource modifications to prevent "resource tree is locked" exception
Delaying resource modifications to prevent "resource tree is locked" exception [message #332195] Thu, 09 October 2008 11:27 Go to next message
Mikhail Kadan is currently offline Mikhail KadanFriend
Messages: 61
Registered: July 2009
Member
Hi.

I have my own implementation of IResourceChangeListener, which recognizes
when file was moved and then makes some modifications to i's content. But
when I try to save this modified content to file using IFile.setContent(),
i get the following exception:

org.eclipse.core.internal.resources.ResourceException: The resource tree
is locked for modifications.
at
org.eclipse.core.internal.resources.WorkManager.checkIn(Work Manager.java:115)
at
org.eclipse.core.internal.resources.Workspace.prepareOperati on(Workspace.java:1747)
at org.eclipse.core.internal.resources.File.setContents(File.ja va:364)
at org.eclipse.core.internal.resources.File.setContents(File.ja va:469)

I understand that I cannot modify file's content while processing resource
delta. So I need someway to delay this modifaction. Is there a standart
way to do this (maybe some queue, which accepts runnables, and then exutes
them in batch after processing whole resource delta and unlocking resource
tree) or I have to write my own implementation for this operation?

Thanks.
Re: Delaying resource modifications to prevent "resource tree is locked" exception [message #332197 is a reply to message #332195] Thu, 09 October 2008 12:49 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

You can either spawn a org.eclipse.core.resources.WorkspaceJob or use
LTK Refactoring and provide a MoveParticipant -
http://www.eclipse.org/articles/

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm


Previous Topic:Problem with BasicNewProjectResourceWizard
Next Topic:Mysteries in the Software Updates UI
Goto Forum:
  


Current Time: Mon Jul 22 05:02:32 GMT 2024

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

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

Back to the top