Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » open an editor
open an editor [message #221311] Fri, 13 July 2007 08:00 Go to next message
Eclipse UserFriend
Originally posted by: karl.lindsten.com

Trying to open an editor on a textfile. I got an IFile that seems to work
but when create a new FileEditorInput with the ifile the program crash.


IWorkspace ws = ResourcesPlugin.getWorkspace();
IProject project = ws.getRoot().getProject("project");
String name = "/Users/usr/workspace/project/file.txt";
IPath location = new Path(name);
IFile file = project.getFile(location.lastSegment());
System.out.println("IFile: " + file.getname()) // ok

IEditorInput editorInput = new FileEditorInput(file);
// crash!!!

IWorkbenchPage page = window.getActivePage();
if (page != null)
page.openEditor(editorInput, "org.eclipse.ui.DefaultTextEditor");
Re: open an editor [message #221321 is a reply to message #221311] Fri, 13 July 2007 09:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: karl.lindsten.com

Exception Stack Trace:

java.lang.NoClassDefFoundError: org/eclipse/ui/part/FileEditorInput
...
Re: open an editor [message #221343 is a reply to message #221321] Fri, 13 July 2007 10:12 Go to previous messageGo to next message
Remy Suen is currently offline Remy SuenFriend
Messages: 462
Registered: July 2009
Senior Member
aracruz wrote:
>
> Exception Stack Trace:
>
> java.lang.NoClassDefFoundError: org/eclipse/ui/part/FileEditorInput
> ..
>
You need to add org.eclipse.ui.ide as a required bundle in the
'Dependencies' tab of your MANIFEST.MF file in your META-INF folder and
not configuring your Java Build Path through your project's properties.

Regards,
Rem
Re: open an editor [message #221374 is a reply to message #221343] Fri, 13 July 2007 11:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: karl.lindsten.com

Now it almost work. my IPath is workspace/project/file.txt but when I made
my IFile it got the location runtime-EclipseApplication/project/file.txt.
Should I copy the file to that directory to?
Re: open an editor [message #221382 is a reply to message #221374] Fri, 13 July 2007 11:53 Go to previous messageGo to next message
Remy Suen is currently offline Remy SuenFriend
Messages: 462
Registered: July 2009
Senior Member
aracruz wrote:
> Now it almost work. my IPath is workspace/project/file.txt but when I
> made my IFile it got the location
> runtime-EclipseApplication/project/file.txt. Should I copy the file to
> that directory to?

You need to give us more information to work with here.

What exactly are you trying to do?
What file are you trying to open?
What do you see?
What did you expect to see?
What is not working?

Regards,
Rem
Re: open an editor [message #221390 is a reply to message #221382] Fri, 13 July 2007 12:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: karl.lindsten.com

I'm trying to open a file outside the workspace. When I do that I get an
IPath with the right path to the file. Then when I make the IFile (IFile
file = project.getFile(path.lastSegment());) with the path the IFiles
location isn't the same as the path. So when the the program tries to
open the file it look at the wrong location. It moves the location from
the workspace directory to the runtime-EclipseApplicication directory so
then it cant find the file.

When i run the program it opens a texteditor that says it can't find the
file.
Re: open an editor [message #221396 is a reply to message #221390] Fri, 13 July 2007 12:50 Go to previous messageGo to next message
Remy Suen is currently offline Remy SuenFriend
Messages: 462
Registered: July 2009
Senior Member
aracruz wrote:
> I'm trying to open a file outside the workspace.

They added API in 3.3 for this. You want to use FileStoreEditorInput
instead for files that aren't in the workspace. Google around for
information about EFS (Eclipse File System) to figure out how to get an
IFileStore for your FileStoreEditorInput constructor.

Regards,
Rem
Re: open an editor [message #221649 is a reply to message #221396] Mon, 16 July 2007 07:18 Go to previous message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Remy Chi Jian Suen wrote:

> aracruz wrote:
>
>> I'm trying to open a file outside the workspace.
>
>
> They added API in 3.3 for this. You want to use FileStoreEditorInput
> instead for files that aren't in the workspace. Google around for
> information about EFS (Eclipse File System) to figure out how to get
> an IFileStore for your FileStoreEditorInput constructor.

You don't even need to create the editor input. Simply do this:
IFileStore fileStore = EFS.getLocalFileSystem().getStore(uri);
IDE.openEditorOnFileStore(page, fileStore);

HTH
Dani

>
> Regards,
> Rem
Previous Topic:Hide a particular file type
Next Topic:Ca't Use Software Updates
Goto Forum:
  


Current Time: Sun Sep 22 06:44:00 GMT 2024

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

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

Back to the top