Recently I had a problem in converting java.io.File to IFile for
external files. The external files sind the files which are not located
in the eclipse workspace. So they are not eclipse "resources" and can
not be converted into IFile instances. With the following code you can
solve this problem:
IEditorInput input= createEditorInput(selectedFile);
String editorId= getEditorId(selectedFile);
IWorkbenchPage page= fWindow.getActivePage();
try {
page.openEditor(input, editorId);
} catch (PartInitException e) {
//EditorsPlugin.log(e.getStatus());
}
This idea comes from
org.eclipse.ui.internal.editors.text.OpenExternalFileAction. In this
class you can also find the implementation for the methods
"createEditorInput" and "getEditorId".