Listening to file changes outside the workspace [message #463088] |
Tue, 06 February 2007 14:05 |
Eclipse User |
|
|
|
Originally posted by: georg.moleque.com.br
Hi all,
I want to listen to changes in files in a folder outside the Eclipse
Workspace, so that eacht time a IResourceChangeListener would be notified.
I read the trick should be somehow to create a link to the Folder with
IFolder, but how can I do it? Something like:
IFolder folder = ...?
Or is there a better way to listen to changes in the file system?
Thanks for any help in advance,
Georg
|
|
|
|
Re: Listening to file changes outside the workspace [message #463286 is a reply to message #463146] |
Wed, 07 February 2007 19:22 |
Eclipse User |
|
|
|
Originally posted by: georg.moleque.com.br
Thank you Alex,
that helped me to go on, but I´m still struggling. Following some
snippets from the doc on "Linked Resources", I tried the following:
<...>
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IPathVariableManager pathMan = workspace.getPathVariableManager();
String name = "TEMP";
IPath value = new Path( "I:/Temp" );
pathMan.setValue( name, value );
IProject project =
workspace.getRoot().getProject("sianit-rich-client-library");
IFolder link = project.getFolder( "Link" );
IPath location = new Path( "TEMP/SianitUpdateFolder/" );
link.createLink( location, IResource.ALLOW_MISSING_LOCAL, null );
<...>
which throws an exception in the last line (createlink()):
org.eclipse.core.internal.resources.ResourceException:
Cannot create linked resource /sianit-rich-client-library/Link.
probably because the parent of the resource (=the project) is not
accessible (!?).
I´m not sure what that should tell me and how to proceed.
Any hint would be greatly apreciated,
Georg
Alex Blewitt escreveu:
> The IFolder.createLink() should do what you want:
>
> http://help.eclipse.org/help32/topic/org.eclipse.platform.do c.isv/reference/api/org/eclipse/core/resources/IFolder.html# createLink (org.eclipse.core.runtime.IPath,%20int,%20org.eclipse.core.r untime.IProgressMonitor)
>
> Note that you will only get this if the folder is refreshed. Normally, eclipse will auto-refresh files when they're accessed e.g. switching to an editor with a file's contents) but you may want to perform manual refreshes (IFolder.refresh(DEPTH_ZERO) or some such -- or DEPTH_ONE or DEPTH_INFINITE to recurse) periodically if they're going to be changed outside of your control.
>
> There's some info on auto refresh providers via the extension point:
>
> http://help.eclipse.org/help32/topic/org.eclipse.platform.do c.isv/reference/extension-points/org_eclipse_core_resources_ refreshProviders.html
>
> Alex.
|
|
|
Powered by
FUDForum. Page generated in 0.04602 seconds