Skip to main content

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


Talk about luck.  I was actually trying to do this yesterday and put a question into a editor guru.  If you are using 3.3, you need to get the latest Platform UI plugins out of head.  Then you can use the following two lines of code to open an editor on a file outside the workspace.

EFS.getLocalFileSystem().getStore(yourPath);
IDE.openEditorOnFileStore(page, fileStore);

If you are using 3.2 or previous, try http://wiki.eclipse.org/index.php/FAQ_How_do_I_open_an_editor_on_a_file_outside_the_workspace%3F

Brian Bauman
    IBM Software Group - Austin, TX
    Eclipse Committer
    baumanbr@xxxxxxxxxx
    (512) 838 -2938 (T/L 678-2938)



"Eclipse Questions" <eclipse.questions@xxxxxxxxx>
Sent by: pde-dev-bounces@xxxxxxxxxxx

02/21/2007 11:47 PM

Please respond to
"Eclipse PDE general developers list." <pde-dev@xxxxxxxxxxx>

To
pde-dev@xxxxxxxxxxx
cc
Subject
[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_______________________________________________
pde-dev mailing list
pde-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/pde-dev


Back to the top