Refresh resource after external alteration to file [message #328487] |
Mon, 26 May 2008 14:11 ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Hi,
I have code that has to save via a path (String). So, I create my own
FileOutputStream that writes the file to the workspace (not via IFile),
and close the stream. The workspace is obviously not aware of this, and
I need to hit refresh before using the file (I use a CommonNavigator).
Is there some way I can locate the file in the workspace by name or
external (non-workspace) path, so I can get a handle to the IFile and
call "refresh" programmatically? Or could someone recommend another
strategy so that the resource is refreshed automatically on external
modification?
Cheers,
.../Ola
|
|
|
|
|
Re: Refresh resource after external alteration to file [message #328642 is a reply to message #328498] |
Thu, 29 May 2008 14:03 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: kosta.bea.com
Here is a conversion routine that I had to write a while back for
getting IFile given File:
public static IFile getWorkspaceFile( final File f )
{
final IWorkspace ws = ResourcesPlugin.getWorkspace();
final IWorkspaceRoot wsroot = ws.getRoot();
final IPath path = new Path( f.getAbsolutePath() );
final IFile[] wsFiles = wsroot.findFilesForLocation( path );
if( wsFiles.length > 0 )
{
return wsFiles[ 0 ];
}
return null;
}
- Konstantin
|
|
|
Powered by
FUDForum. Page generated in 0.03209 seconds