Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How can I refresh a file during a IResourceChangeEvent
How can I refresh a file during a IResourceChangeEvent [message #663645] Wed, 06 April 2011 02:44 Go to next message
Felix L J Mayer is currently offline Felix L J MayerFriend
Messages: 202
Registered: July 2009
Senior Member
I have a org.eclipse.core.resources.IResourceChangeListener which is trying
to refresh file with org.eclipse.core.resources.IResource.refreshLocal(int,
IProgressMonitor) when handling a IResourceChangeEvent. This fails because
the workspace is locked:

Caused by: 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:1914)
at
org.eclipse.core.internal.resources.Resource.refreshLocal(Re source.java:1655)
at org.eclipse.core.internal.resources.File.refreshLocal(File.j ava:337)
at
com.objectaid.uml.model.DiagramHandle.refreshFile(DiagramHan dle.java:202)
... 23 more

This happens when I revert some files is the workspace with Subclipse.

Why can I not refresh a file in reaction to its change? How else am I
supposed to go about this? Those files really need to be refreshed,
otherwise I get an exception that they are out of sync when I try to read
them.

Thanks, Felix
Re: How can I refresh a file during a IResourceChangeEvent [message #663764 is a reply to message #663645] Wed, 06 April 2011 12:46 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 04/05/2011 10:44 PM, Felix LJ Mayer wrote:
> I have a org.eclipse.core.resources.IResourceChangeListener which is
> trying to refresh file with
> org.eclipse.core.resources.IResource.refreshLocal(int, IProgressMonitor)
> when handling a IResourceChangeEvent. This fails because the workspace
> is locked:

Have a look at the javadoc for IResourceChangeEvent ... depending on
what event you're seeing, it will tell you if the workspace is closed
for changes.

If that's the case, try putting your changes in a Job. Add a rule from
org.eclipse.core.resources.IWorkspace.getRuleFactory() and then schedule it.

PW

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


Re: How can I refresh a file during a IResourceChangeEvent [message #663807 is a reply to message #663764] Wed, 06 April 2011 14:34 Go to previous message
Felix L J Mayer is currently offline Felix L J MayerFriend
Messages: 202
Registered: July 2009
Senior Member
Thanks for the response, that's what I was afraid of.

I guess it just doesn't make sense to me that refreshing a file is
considered a workspace space.

Felix
Previous Topic:Editing item from Eclipse text viewer context menu
Next Topic:switch working set triggers a script/command
Goto Forum:
  


Current Time: Thu Mar 28 16:40:53 GMT 2024

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

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

Back to the top