Re: not getting IFile [message #314024] |
Sun, 01 April 2007 04:10 |
Eclipse User |
|
|
|
Originally posted by: hansm.science.uva.nlDELETE
After my suggestion to implement IFileEditorInput directly Ed Merks
<merks@ca.ibm.com> wrote on this subject:
> Your solutions sounds good, but I think you should just implement
> IStorageEditorInput directly, but not IFileEditorInput since your input
> will not generally be an IFile. When a given file system path doesn't
> correspond to something that's in the workspace, you should expect
> getFileForLocation to return null.
However, after some more digging into the Eclipse documentation I encountered
the FileStore. Easier perhaps than implementing IFileEditorInput is something
along the following lines. Of course one cannot profit from
ResourceChangeEvents, but as I understand that is restricted to things in the
Eclipse workspace, outside of which to code below is moving.
FileStoreEditorInput input = null;
try {
final IFileStore filestore = EFS.getStore(new URI(
"file:/Users/me/myfile"));
input = new FileStoreEditorInput(filestore); }
catch (final CoreException xcp) {
xcp.printStackTrace();
}
catch (final URISyntaxException xcp) {
xcp.printStackTrace();
}
final IWorkbenchPage page = getSite().getPage();
try {
page.openEditor(input, MyEditor.ID);
}
catch (final PartInitException xcp) {
xcp.printStackTrace();
}
One caveat. The example code for the multipage editor as generated by the
eclipse ide template checks for FileEditorInput which is now not applicable.
I hope others may find this information useful.
Hans van der Meer
|
|
|
Powered by
FUDForum. Page generated in 0.04729 seconds