How to construct IFile of external file for FileEditorInput? [message #210070] |
Tue, 19 July 2005 02:58  |
Eclipse User |
|
|
|
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 #210304 is a reply to message #210229] |
Wed, 20 July 2005 10:20  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.13035 seconds