Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » How to construct IFile of external file for FileEditorInput?
How to construct IFile of external file for FileEditorInput? [message #210070] Tue, 19 July 2005 02:58 Go to next message
Eclipse UserFriend
Originally posted by: cxz.ufsoft.com.cn

My java code is following:

IPath path = new Path(" E:/插件开发/module3. xml ");
IFile iFile = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
String editorId = "mutiPageEditor.editors.MultiPageEditor";
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().openEditor(new
FileEditorInput(iFile), editorId);

After running, a error of " not file find " appears.
I think problem comes from
"ResourcesPlugin.getWorkspace().getRoot().getFile(path);".because file of
" E:/插件开发/module3. xml " is a external file
outside workspace. How can I generate a IFile Object using external file?
Re: How to construct IFile of external file for FileEditorInput? [message #210123 is a reply to message #210070] Tue, 19 July 2005 07:43 Go to previous messageGo to next message
Eclipse UserFriend
As I remember, you cannot access the file which outside the workspace
unless you implement your own subclass of IFile.

Chai XiaoZong wrote:
> My java code is following:
>
> IPath path = new Path(" E:/插件开发/module3. xml ");
> IFile iFile = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
> String editorId = "mutiPageEditor.editors.MultiPageEditor";
> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().openEditor(new
> FileEditorInput(iFile), editorId);
>
> After running, a error of " not file find " appears.
> I think problem comes from
> "ResourcesPlugin.getWorkspace().getRoot().getFile(path);".because file
> of " E:/插件开发/module3. xml " is a external file
> outside workspace. How can I generate a IFile Object using external file?
>
Re: How to construct IFile of external file for FileEditorInput? [message #210131 is a reply to message #210070] Tue, 19 July 2005 07:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: daniel.megert.gmx.net

Chai XiaoZong wrote:

> My java code is following:
>
> IPath path = new Path(" E:/插件开发/module3. xml ");
> IFile iFile = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
> String editorId = "mutiPageEditor.editors.MultiPageEditor";
> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().openEditor(new
> FileEditorInput(iFile), editorId);
>
> After running, a error of " not file find " appears.
> I think problem comes from
> "ResourcesPlugin.getWorkspace().getRoot().getFile(path);".because file
> of " E:/插件开发/module3. xml " is a external
> file outside workspace. How can I generate a IFile Object using
> external file?
>
You can't. We use JavaFileEditorInput for this, see
OpenExternalFileAction for more details about how to open an editor on
an external file. Keep in mind that those classes are internal.

Dani
Re: How to construct IFile of external file for FileEditorInput? [message #210229 is a reply to message #210131] Tue, 19 July 2005 22:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cxz.ufsoft.com.cn

Now, I place xml file in runtime-workspace directory(I am developing a
plugin).
I want to access the xml file and wrap it to a IFile which is used in
FileEditorInput(iFile), how can I do?
My code is following:

IPath path = new Path("E:/runtime-workspace/module3.xml");
IFile iFile = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
path = iFile.getFullPath();
System.out.println("fullPath = "+path);

//print result: /runtime-workspace/module3.xml

When running program, and opening the plugin, a error of not file find
appears.
Re: How to construct IFile of external file for FileEditorInput? [message #210304 is a reply to message #210229] Wed, 20 July 2005 10:20 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

A file needs to be in a project. module3.xml is not in a project. The
only valid things directly below a workspace is the .metadata directory
and project folders, not files.

Also, you don't use fully-qualified pathnames for getFile(). It has to
be relative to the workspace. For example if you have a file called
"module3.xml" in the "abc" project then you would use:

IFile iFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new
Path("/abc/module3.xml"));


Chai XiaoZong wrote:
> Now, I place xml file in runtime-workspace directory(I am developing a
> plugin).
> I want to access the xml file and wrap it to a IFile which is used in
> FileEditorInput(iFile), how can I do?
> My code is following:
>
> IPath path = new Path("E:/runtime-workspace/module3.xml");
> IFile iFile = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
> path = iFile.getFullPath();
> System.out.println("fullPath = "+path);
>
> //print result: /runtime-workspace/module3.xml
>
> When running program, and opening the plugin, a error of not file find
> appears.
>

--
Thanks,
Rich Kulp
Previous Topic:possible to selectively export source files for dependent projects?
Next Topic:listening for resource proerty changes
Goto Forum:
  


Current Time: Fri May 09 11:59:19 EDT 2025

Powered by FUDForum. Page generated in 0.13035 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top