Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[pde-dev] Creating IFile object for IEditorInput

Hi
I am developing an Eclipse plugin where a user can browse the folder structure of a remote system through FTP and can edit files which are placed in the remote file system.
The process we are following is getting the file to the local file system and then opening the editor with the file as the input to the editor. But for opening the editor we have to pass an object of IEditorInput for which IFile is required.
Is there a way that I can get an IFile object for a file which is not residing in the workspace but in some other folder, like the temporary folder of the user.
I am using the following code snippet for getting the IFile object where localFilePath is passed as parameter to the method:
            IFile file[] = ResourcesPlugin. getWorkspace().getRoot().findFilesForLocation(new Path(localFilePath));
            if (file != null ) {
                  int fLen = file. length;
                  System. out.println( "fLen: " + fLen);
                  for ( int j = 0; j < fLen; j++) {
                        IFile tif = file[j];
                        System.out.println( "tif.getName()" + tif.getName());
                        System.out.println( "tif.getFullPath(): " + tif.getFullPath());
                        if (tif != null) {
                              return tif; 
                        }
                  } 
                  System. out.println( "returning null");
                  return null;
            } else { 
                  System. out.println( "file[] == null");
                  return null;
            }
But it always returns a null. And if the IFile object is not null then it definitely fails the exists test, i.e., IFile.exists ().
Even if the file is stored in the workspace then also the IFile.exists() method fails and therefore the IEditorInput object is not created.
Please help.
Thanks and Regards
Prashant

Back to the top