|Best practice for avoiding/handling out of sync resource [message #498445]
||Mon, 16 November 2009 23:29
| Carlin Rogers
Registered: July 2009
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.
Powered by FUDForum
. Page generated in 0.03443 seconds