IFile device [message #289610] |
Mon, 08 August 2005 17:18  |
Eclipse User |
|
|
|
Originally posted by: no_email_please.hotmail.com
Is it possible to set the device of an IFile?
I'm converting a File to an IPath and the to an IFile but
when I do the last step, the device is set to null.
Here's what I do for this:
IFile myIFile =
ResourcesPlugin.getWorkspace().getRoot().getFileForLocation( myIPath);
This file is external to the workspace, maybe that's why???
Any ideas?
Thanks
Nic
|
|
|
|
|
|
|
|
|
Re: IFile device [message #289755 is a reply to message #289749] |
Wed, 10 August 2005 11:50   |
Eclipse User |
|
|
|
Originally posted by: no_email_please.hotmail.com
Ok, well let me try to explain this a little better. I'm a little vague on
how all of these objects or interfaces work together.
Basically what I need to do is to allow eclipse (or in my case Rational)
to open a file passed in as a parameter on the command line. The software
doesn't do it by itself so I have to code this.
So far I have created a class which implements IStartup. And in the
earlyStartup method I can parse the command line parameters. Now
what's left is to get it to open a file whose outside of the workspace
(outside of the "workspace" folder on your hardrive). I did get it to
work with eclipse with this code (or something like it, I'm modifying
it so it may not work), myFilePath could be anywhere on the harddrive:
File file = new File(myFilePath);
IPath path = new Path(file.getAbsolutePath());
IFile ifile = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
IWorkbenchWindow window = myWorkbench.getActiveWorkbenchWindow();
try{
if (window != null){
IWorkbenchPage iwp = window.getActivePage();
System.out.println(iwp.getPerspective().getId());
org.eclipse.ui.ide.IDE.openEditor(iwp, ifile,
"org.eclipse.ui.DefaultTextEditor");
}
}catch(Exception e){
System.out.println(e);
}
Now when I move this code to Rational and try to get it to open a file
with their HTML input editor, I get file not found. So I started looking
through the different objects in the debugger and noticed that my IFile
didn't have the device set. So I thought that was it. I need to get this
populated...
After doing some more research on this forum I heard about a linked file.
Funny, you just mentioned it too. I can't seem to find much about it though.
Would this help me???
Thanks, really appreciate it.
Nic
"John Arthorne" <john@eclipsefaq.org> wrote in message
news:ddd683$th2$1@news.eclipse.org...
> Rich Kulp wrote:
> > Well, that's part of the problem. It doesn't matter what you do, a file
> > external to the workspace cannot be made into an IFile. IFile's can only
> > be for files in the workspace.
> >
>
> I think I misunderstood the problem. It sounded like he already had an
> IFile object; by "external to the workspace" I thought he meant a linked
> file or a file in a project whose location is external to the workspace.
> The term "workspace" can mean the directory on disk
> (c:\eclipse\workspace), or it can mean the API IWorkspace. By
> definition every IFile belongs to the IWorkspace (IFile.getWorkspace()
> never returns null), but an IFile's location on disk need not
> necessarily be inside the c:\eclipse\workspace directory. The question
> was ambiguous...
> --
|
|
|
Re: IFile device [message #289789 is a reply to message #289755] |
Wed, 10 August 2005 14:53  |
Eclipse User |
|
|
|
Originally posted by: john.eclipsefaq.org
See IFile.createLink. This method will create a file whose contents are
at an arbitrary location on disk. This file must still belong to some
project though:
IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject("Test");
IFile file = p.getFile("TestFile.txt");
file.createLink("c:\\temp\\SomePlaceOnDisk.txt", 0, null);
--
Nicolas Legare wrote:
> Ok, well let me try to explain this a little better. I'm a little vague on
> how all of these objects or interfaces work together.
>
> Basically what I need to do is to allow eclipse (or in my case Rational)
> to open a file passed in as a parameter on the command line. The software
> doesn't do it by itself so I have to code this.
>
> So far I have created a class which implements IStartup. And in the
> earlyStartup method I can parse the command line parameters. Now
> what's left is to get it to open a file whose outside of the workspace
> (outside of the "workspace" folder on your hardrive). I did get it to
> work with eclipse with this code (or something like it, I'm modifying
> it so it may not work), myFilePath could be anywhere on the harddrive:
>
> File file = new File(myFilePath);
> IPath path = new Path(file.getAbsolutePath());
> IFile ifile = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
> IWorkbenchWindow window = myWorkbench.getActiveWorkbenchWindow();
>
> try{
> if (window != null){
> IWorkbenchPage iwp = window.getActivePage();
> System.out.println(iwp.getPerspective().getId());
> org.eclipse.ui.ide.IDE.openEditor(iwp, ifile,
> "org.eclipse.ui.DefaultTextEditor");
> }
> }catch(Exception e){
> System.out.println(e);
> }
>
> Now when I move this code to Rational and try to get it to open a file
> with their HTML input editor, I get file not found. So I started looking
> through the different objects in the debugger and noticed that my IFile
> didn't have the device set. So I thought that was it. I need to get this
> populated...
>
> After doing some more research on this forum I heard about a linked file.
> Funny, you just mentioned it too. I can't seem to find much about it though.
> Would this help me???
>
> Thanks, really appreciate it.
> Nic
>
> "John Arthorne" <john@eclipsefaq.org> wrote in message
> news:ddd683$th2$1@news.eclipse.org...
>
>>Rich Kulp wrote:
>>
>>>Well, that's part of the problem. It doesn't matter what you do, a file
>>>external to the workspace cannot be made into an IFile. IFile's can only
>>>be for files in the workspace.
>>>
>>
>>I think I misunderstood the problem. It sounded like he already had an
>>IFile object; by "external to the workspace" I thought he meant a linked
>>file or a file in a project whose location is external to the workspace.
>>The term "workspace" can mean the directory on disk
>>(c:\eclipse\workspace), or it can mean the API IWorkspace. By
>>definition every IFile belongs to the IWorkspace (IFile.getWorkspace()
>>never returns null), but an IFile's location on disk need not
>>necessarily be inside the c:\eclipse\workspace directory. The question
>>was ambiguous...
>>--
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.07756 seconds