Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » IFile
IFile [message #465580] Mon, 02 April 2007 11:45 Go to next message
Eclipse UserFriend
Hi,


Can any one give me a hint ,about getting IFile from the editor.

I have snippet which uses iFileEditorInput to get IFile,but the fact is i
couldnt find IFileEditorInput itself.

BR,
Mark
Re: IFile [message #465608 is a reply to message #465580] Tue, 03 April 2007 02:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: starkom.ngs.ru

IWorkspaceRoot root =3D ResourcesPlugin.getWorkspace().getRoot();
IProject project =3D root.getProject("project");
IFile file =3D project.getFile(new Path("file.java"));

On Mon, 02 Apr 2007 22:45:01 +0700, Mark <mark@urs.com> wrote:

>
> Hi,
>
>
> Can any one give me a hint ,about getting IFile from the editor.
>
> I have snippet which uses iFileEditorInput to get IFile,but the fact i=
s =

> i couldnt find IFileEditorInput itself.
>
> BR,
> Mark
>



-- =

Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Re: IFile [message #465628 is a reply to message #465608] Tue, 03 April 2007 10:43 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for the reply!

Wat if i dont have any works[ace created.!If i am opening the file from a
desktop

Thanks&Regards
Mark
Re: IFile [message #465728 is a reply to message #465580] Wed, 04 April 2007 01:44 Go to previous messageGo to next message
Eclipse UserFriend
Not sure about the snippet you have. Does this helps?

IFile theFile = null;
IEditorInput editorInput = getEditorInput();
if(editorInput instanceof IFileEditorInput) {
&nbsp;&nbsp;&nbsp;&nbsp;theFile = ((IFileEditorInput)editorInput).getFile();
}

- Prakash

&gt;
&gt; Hi,
&gt;
&gt;
&gt; Can any one give me a hint ,about getting IFile
&gt; from the editor.
&gt; I have snippet which uses iFileEditorInput to get
&gt; IFile,but the fact is i
&gt; couldnt find IFileEditorInput itself.
&gt;
&gt; BR,
&gt; Mark
&gt;
Re: IFile [message #465734 is a reply to message #465628] Wed, 04 April 2007 04:08 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: starkom.ngs.ru

I think that you can't get IFile instance for any non-workspace resource.
If you want get IFile from current opened EditorInput see prakash's answer.

On Tue, 03 Apr 2007 21:43:10 +0700, Mark <mark@urs.com> wrote:

>
> Thanks for the reply!
>
> Wat if i dont have any works[ace created.!If i am opening the file from
> a desktop
>
> Thanks&Regards
> Mark
>



--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Re: IFile [message #465761 is a reply to message #465734] Wed, 04 April 2007 14:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hansm.science.uva.nlDELETE

In article <op.tp818m2d4rt05h@azargaev.bcs-it.loc>,
"Azargaev Evgeniy" <starkom@ngs.ru> wrote:

> I think that you can't get IFile instance for any non-workspace resource.
> If you want get IFile from current opened EditorInput see prakash's answer.
>
> On Tue, 03 Apr 2007 21:43:10 +0700, Mark <mark@urs.com> wrote:
>
> >
> > Thanks for the reply!
> >
> > Wat if i dont have any works[ace created.!If i am opening the file from
> > a desktop
> >
> > Thanks&Regards
> > Mark
> >

Or if you want to put a java.io.File file external to the workspace into an
editor, you might use:

// Safeguard against empty and nonexistent files or directories
if (file == null || !file.exists() || file.isDirectory()) return;
try {
// Get input for editor.
final IFileStore filestore = EFS.getStore(file.toURI());
final FileStoreEditorInput input = new FileStoreEditorInput(filestore);
// Open editor on it.
window.getActivePage().openEditor(input, YourEditor.ID);
}
catch (final PartInitException xcp) {logger.error("opening editor failed for
{}", file);}
catch (final CoreException xcp) {logger.error("getting filestore failed for
{}",file);}
Missing IFile and other classes (blocking issue)! [message #466579 is a reply to message #465728] Sat, 21 April 2007 13:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jweeks.neuraldk.org

This is exactly what I'm currently doing, but my Eclipse setup is unable to
find various classes which I need, such as:

org.eclipse.ui.IFileEditorInput
org.eclipse.core.resources.IFile

Any idea why this is, and/or how I can fix it? This project was setup via
the plugin development new project wizard.

The error I was receiving was:
The project was not built since its build path is incomplete. Cannot find
the class file for org.eclipse.ui.IFileEditorInput. Fix the build path
then try building this project.

I manually added the following libraries:
/usr/share/eclipse/plugins/org.eclipse.core.resources_3.2.1. R32x_v20060914.jar
/usr/share/eclipse/plugins/org.eclipse.ui_3.2.1.M20060915-10 30.jar

And now I can at least run the project, but every time I try to use one of
these classes, I appear to get a class loading exception.

Have I added these classes incorrectly? How can I ensure that all classes
are properly associated and loaded with my project? I expected all of the
eclipse plugin jars to be listed under "Plug-in Dependencies", but this
doesn't appear to be the case.

Please help!

Thanks,
Jeff

> Not sure about the snippet you have. Does this helps?
>
> IFile theFile = null;
> IEditorInput editorInput = getEditorInput();
> if(editorInput instanceof IFileEditorInput) {
> &nbsp;&nbsp;&nbsp;&nbsp;theFile =
> ((IFileEditorInput)editorInput).getFile(); }
>
> - Prakash
>
> &gt;
> &gt; Hi,
> &gt;
> &gt;
> &gt; Can any one give me a hint ,about getting IFile
> &gt; from the editor.
> &gt; I have snippet which uses iFileEditorInput to get
> &gt; IFile,but the fact is i
> &gt; couldnt find IFileEditorInput itself.
> &gt;
> &gt; BR,
> &gt; Mark
> &gt;
Re: Missing IFile and other classes (blocking issue)! [message #466584 is a reply to message #466579] Sat, 21 April 2007 13:56 Go to previous message
Eclipse UserFriend
Originally posted by: jweeks.neuraldk.org

Bah! I found my answer... I needed to edit the manifest.mf file instead of
adding jars and/or editing the plugin.xml. I also needed to add
org.eclipse.ui.ide in order to get the IFileEditorInput instance (even
though its a part of the org.eclipse.ui namespace).

One other note on this topic, though... I noticed my default EditorInput is
*not* an instance of IFileEditorInput
(org.eclipse.ui.internal.editors.text.JavaFileEditorInput is not). It is,
however, an instance of IPathEditorInput, so the following code will work
to get the filename of an editor:

IEditorInput input = getEditorInput();
if( input instanceof IPathEditorInput )
{
IPath path = ((IPathEditorInput)input).getPath();
filename = path.toOSString();
}

--Jeff

Jeff Weeks [ neuraldk ] wrote:

> This is exactly what I'm currently doing, but my Eclipse setup is unable
> to find various classes which I need, such as:
>
> org.eclipse.ui.IFileEditorInput
> org.eclipse.core.resources.IFile
>
> Any idea why this is, and/or how I can fix it? This project was setup via
> the plugin development new project wizard.
>
> The error I was receiving was:
> The project was not built since its build path is incomplete. Cannot find
> the class file for org.eclipse.ui.IFileEditorInput. Fix the build path
> then try building this project.
>
> I manually added the following libraries:
> /usr/share/eclipse/plugins/org.eclipse.core.resources_3.2.1. R32x_v20060914.jar
> /usr/share/eclipse/plugins/org.eclipse.ui_3.2.1.M20060915-10 30.jar
>
> And now I can at least run the project, but every time I try to use one of
> these classes, I appear to get a class loading exception.
>
> Have I added these classes incorrectly? How can I ensure that all classes
> are properly associated and loaded with my project? I expected all of the
> eclipse plugin jars to be listed under "Plug-in Dependencies", but this
> doesn't appear to be the case.
>
> Please help!
>
> Thanks,
> Jeff
>
>> Not sure about the snippet you have. Does this helps?
>>
>> IFile theFile = null;
>> IEditorInput editorInput = getEditorInput();
>> if(editorInput instanceof IFileEditorInput) {
>> &nbsp;&nbsp;&nbsp;&nbsp;theFile =
>> ((IFileEditorInput)editorInput).getFile(); }
>>
>> - Prakash
>>
>> &gt;
>> &gt; Hi,
>> &gt;
>> &gt;
>> &gt; Can any one give me a hint ,about getting IFile
>> &gt; from the editor.
>> &gt; I have snippet which uses iFileEditorInput to get
>> &gt; IFile,but the fact is i
>> &gt; couldnt find IFileEditorInput itself.
>> &gt;
>> &gt; BR,
>> &gt; Mark
>> &gt;
Previous Topic:plugin already installed problem
Next Topic:access other plugins (without dependeny)
Goto Forum:
  


Current Time: Tue May 13 00:48:00 EDT 2025

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

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

Back to the top