Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Best practice for avoiding/handling out of sync resource(guidance for avoiding or handling ResourceException)
Best practice for avoiding/handling out of sync resource [message #498445] Mon, 16 November 2009 23:29
Carlin Rogers is currently offline Carlin RogersFriend
Messages: 11
Registered: July 2009
Junior Member
I'm trying to find a recommended approach or best practice for handling an out of sync resource. In our plug-ins we make calls to a File resource to getContentDescription(). The calss are made both directly from our code and indirectly through other Eclipse APIs. However, if the resource in the workspace is not in sync with the file system, we get a ResourceException...

"org.eclipse.core.internal.resources.ResourceException: Resource is out of sync with the file system:..."

I've searched and found a few references suggesting to use the IResource isSynchronized() and then possibly call refreshLocal(). The isSynchronized() comments state that "...this operation may be time-consuming." because the operation interrogates files. Does it make sense to call this method if the underlying routine like FIle.getContentDescription() already checks to see if the resource is synchronized? Is there a way to avoid duplicating the cost of making the call but still avoid getting the ResourceException thrown from an underlying routine of getContentDescription()?

It seems that there is other code in the framework that pops a dialog to the user to report that a resource is out of sync and ask if they would like to refresh it. So as a plug-in developer does one just catch the ResourceException and handle it gracefully, letting the framework manage the user interactions to refresh the resource or is there a recommended approach for checking the status of the resource?

Any guidance here would be appreciated.

Previous Topic:Delay Eclipse RCP Window
Next Topic:On latest updates
Goto Forum:

Current Time: Wed Mar 03 07:24:10 GMT 2021

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

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

Back to the top