Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Editing an obscure file format
Editing an obscure file format [message #328836] Wed, 04 June 2008 18:22 Go to next message
john is currently offline johnFriend
Messages: 10
Registered: July 2009
Junior Member
Hello,

I'm working on a plug-in that will use a ordinary editor on files of
like extension which may or may not be zipped. Lets call them ".foo"
files. It will be necessary to test .foo files to see if they are valid
zip files and then extract them, or have them be interpreted as text files
if they are not zips.

If a .foo is zipped, the only thing the zip will contain is a flat .foo
text file

The problem I'm having is discerning how to hook the EclipseFileSystem's
attempt to open these .foo files. I wrote a lightweight FileSystem and
FileStore to handle .foo files, but I can't figure out how to get eclipse
to only use this fooFileSystem for .foo files. If I set my FileSystem's
scheme to "foo", nothing happens because no "foo" URI scheme exists. If I
set the scheme to "file", eclipse sends every file operation through my
light filesystem, and the fooFileSystem isn't prepared to deal with that.

How can I get eclipse to use my FooFileStore implementation?

Alternatively, I've been looking into content-types and whatnot.
Apparently you can associate them with editors, but I am unsure how. But
I'm interested in alternative approaches for viewing and editing these
distinct content types that have the same file extensions, while
preserving their content types.

thank you!
Re: Editing an obscure file format [message #328929 is a reply to message #328836] Fri, 06 June 2008 19:40 Go to previous messageGo to next message
john is currently offline johnFriend
Messages: 10
Registered: July 2009
Junior Member
Anybody? I'm just looking for a place where I can hook the IO and have an
editor reference a temp doc rather than the actual one.
Re: Editing an obscure file format [message #328931 is a reply to message #328929] Fri, 06 June 2008 20:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse-news.rizzoweb.com

John wrote:
> Anybody? I'm just looking for a place where I can hook the IO and have
> an editor reference a temp doc rather than the actual one.
>

Since you didn't quote the original message I can't be sure of the
context, but...
Can you not do what you need in
org.eclipse.ui.part.EditorPart.init(IEditorSite, IEditorInput) ?

That is where the editor is told what its input object is (usually a
FileEditorInput).

Hope this helps,
Eric
Re: Editing an obscure file format [message #328970 is a reply to message #328931] Mon, 09 June 2008 16:18 Go to previous messageGo to next message
john is currently offline johnFriend
Messages: 10
Registered: July 2009
Junior Member
Thank you for your help Eric, and sorry about not quoting. I did not
realize it inconvenienced readers.

I'm working on the tactic you've discussed.

To reiterate what I failed to quote earlier, I'm attempting to have an
bind an editor to a file type of a particular extension. I'm familiar
with the editors extension point, so specifying an editor to be associated
with a file is not my concern.

The concern is that when the editor is initialized, it may need to unzip
the file before opening the input stream. For these files (lets call them
foo files), they are either a flat text file, or a single flat text file
that's been zippped up. So what I'd like to do is, upon editor
initialization, to test the editor input. If it is a zip file, I'd like
to unzip the file and tie the editor input to the unzippped stream. If
it's not a zip file, I'd like to input stream to be opened as is. I know
what logic I need to test if it's a zip file, and get a stream for it in
either case.

Based on your help, eric, I'm looking into implementing that editors
extension, an specifying an editor for the document. Now I'm trying to
figure how implement init such that the editor is working from the
appropriate stream. I've tried grabbing the filestore and altering that,
but while I see plenty of getters, I don't see many setters. Should I try
and implement a custom FooFileStore class, and register it with the
workspace (and un-register the old one)?

Thank you for your help Eric (and anyone else who might contribute in the
future). I am not resolved to taking this approach, but this seems to be
the most hopeful one I've seen so far. Clarification and suggestion is
very much welcome.

Eric Rizzo wrote:

> John wrote:
>> Anybody? I'm just looking for a place where I can hook the IO and have
>> an editor reference a temp doc rather than the actual one.
>>

> Since you didn't quote the original message I can't be sure of the
> context, but...
> Can you not do what you need in
> org.eclipse.ui.part.EditorPart.init(IEditorSite, IEditorInput) ?

> That is where the editor is told what its input object is (usually a
> FileEditorInput).

> Hope this helps,
> Eric
Re: Editing an obscure file format [message #328982 is a reply to message #328970] Mon, 09 June 2008 20:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse-news.rizzoweb.com

John wrote:
> Thank you for your help Eric, and sorry about not quoting. I did not
> realize it inconvenienced readers.
>
> I'm working on the tactic you've discussed.
>
> To reiterate what I failed to quote earlier, I'm attempting to have an
> bind an editor to a file type of a particular extension. I'm familiar
> with the editors extension point, so specifying an editor to be
> associated with a file is not my concern.
>
> The concern is that when the editor is initialized, it may need to unzip
> the file before opening the input stream. For these files (lets call
> them foo files), they are either a flat text file, or a single flat text
> file that's been zippped up. So what I'd like to do is, upon editor
> initialization, to test the editor input. If it is a zip file, I'd like
> to unzip the file and tie the editor input to the unzippped stream. If
> it's not a zip file, I'd like to input stream to be opened as is. I
> know what logic I need to test if it's a zip file, and get a stream for
> it in either case.
>
> Based on your help, eric, I'm looking into implementing that editors
> extension, an specifying an editor for the document. Now I'm trying to
> figure how implement init such that the editor is working from the
> appropriate stream. I've tried grabbing the filestore and altering
> that, but while I see plenty of getters, I don't see many setters.
> Should I try and implement a custom FooFileStore class, and register it
> with the workspace (and un-register the old one)?

I don't know much about the EFS and file store stuff, but I don't think
you need to go there. If you can assume that the IEditorInput is a
FileEditorInput, then you can get the IFile from it and then do various
things with that (for example, get an InputStream with
IFile.getContents()). I would think that would be enough for you to make
the text vs. ZIP decision. No?

Eric
Re: Editing an obscure file format [message #329057 is a reply to message #328836] Wed, 11 June 2008 14:09 Go to previous message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
John wrote:
> Hello,
>
> I'm working on a plug-in that will use a ordinary editor on files of
> like extension which may or may not be zipped. Lets call them ".foo"
> files. It will be necessary to test .foo files to see if they are
> valid zip files and then extract them, or have them be interpreted as
> text files if they are not zips.
>
> If a .foo is zipped, the only thing the zip will contain is a flat
> .foo text file
>
> The problem I'm having is discerning how to hook the
> EclipseFileSystem's attempt to open these .foo files. I wrote a
> lightweight FileSystem and FileStore to handle .foo files, but I can't
> figure out how to get eclipse to only use this fooFileSystem for .foo
> files. If I set my FileSystem's scheme to "foo", nothing happens
> because no "foo" URI scheme exists. If I set the scheme to "file",
> eclipse sends every file operation through my light filesystem, and
> the fooFileSystem isn't prepared to deal with that.
>
> How can I get eclipse to use my FooFileStore implementation?
I assume your ".foo" file is on the local file system, right? In that
case EFS won't help you much. Also, are you writing your own editor or
do you want to (re-)use the existing text editor?

Dani
>
> Alternatively, I've been looking into content-types and whatnot.
> Apparently you can associate them with editors, but I am unsure how.
> But I'm interested in alternative approaches for viewing and editing
> these distinct content types that have the same file extensions, while
> preserving their content types.
>
> thank you!
>
Previous Topic:Problems with keeping editors opened
Next Topic:How to programmatically find a list of source plug-ins?
Goto Forum:
  


Current Time: Wed Jul 17 21:22:13 GMT 2024

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

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

Back to the top