Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Where do I put code for opening files? Editor or Action?
Where do I put code for opening files? Editor or Action? [message #464968] Wed, 21 March 2007 10:41 Go to next message
Paul Illingworth is currently offline Paul IllingworthFriend
Messages: 4
Registered: July 2009
Junior Member
Hello,

I am having problems working out where I should be putting some code.

I am opening a file which I then process before opening my editor. This
can take quite some time so I have an open file action that does this in
the background and when complete opens the editor. If for some reason it
fails I can inform the user and not open the editor.

When I use the recently opened files menu or when the user opens the
application and the editor state is restored then the editor is created
and I now have to load the file and process it in the editor init()
method. If anything goes wrong I am left with an editor that has an
error message in it - not what I want.

Any help would be appreciated.

Paul I.
Re: Where do I put code for opening files? Editor or Action? [message #464977 is a reply to message #464968] Wed, 21 March 2007 11:48 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: lamont_gilbert.rigidsoftware.com

On Wed, 21 Mar 2007 10:41:52 +0000, Paul Illingworth wrote:

> Hello,
>
> I am having problems working out where I should be putting some code.
>
> I am opening a file which I then process before opening my editor. This
> can take quite some time so I have an open file action that does this in
> the background and when complete opens the editor. If for some reason it
> fails I can inform the user and not open the editor.
>
> When I use the recently opened files menu or when the user opens the
> application and the editor state is restored then the editor is created
> and I now have to load the file and process it in the editor init()
> method. If anything goes wrong I am left with an editor that has an
> error message in it - not what I want.
>
> Any help would be appreciated.
>
> Paul I.

I think the architecture wants you to open the file in the action. Then
feed it to the editor as an IEDitorInput. That way you are not already
opening the editor when you decide you can't open it because the file is
corrupt.

At the same time, IEditorInputs are supposed to be light weight.
IEditorInputs can be held by the architecture to support the recently
opened file menu I think. So I am not sure the preferred or proper way.


I open the file within my editor, and if it fails, I have a background job
that will close my editor after it opens. I get a stupid window flash,
but its the best I can do...
Re: Where do I put code for opening files? Editor or Action? [message #464991 is a reply to message #464977] Wed, 21 March 2007 14:10 Go to previous message
Paul Illingworth is currently offline Paul IllingworthFriend
Messages: 4
Registered: July 2009
Junior Member
CL 'dnoyeB' Gilbert wrote:
> On Wed, 21 Mar 2007 10:41:52 +0000, Paul Illingworth wrote:
>
>> Hello,
>>
>> I am having problems working out where I should be putting some code.
>>
>> I am opening a file which I then process before opening my editor. This
>> can take quite some time so I have an open file action that does this in
>> the background and when complete opens the editor. If for some reason it
>> fails I can inform the user and not open the editor.
>>
>> When I use the recently opened files menu or when the user opens the
>> application and the editor state is restored then the editor is created
>> and I now have to load the file and process it in the editor init()
>> method. If anything goes wrong I am left with an editor that has an
>> error message in it - not what I want.
>>
>> Any help would be appreciated.
>>
>> Paul I.
>
> I think the architecture wants you to open the file in the action. Then
> feed it to the editor as an IEDitorInput. That way you are not already
> opening the editor when you decide you can't open it because the file is
> corrupt.
>
> At the same time, IEditorInputs are supposed to be light weight.
> IEditorInputs can be held by the architecture to support the recently
> opened file menu I think. So I am not sure the preferred or proper way.
>
>
> I open the file within my editor, and if it fails, I have a background job
> that will close my editor after it opens. I get a stupid window flash,
> but its the best I can do...

I agree with all of that.

Following your lead I have created a PartListener that listens to parts
becoming active and when the ErrorEditorPart appears it immediately
closes it. I get the stupid window flash too.

My feeling is that the creation of the ErrorEditorPart (in
EditorReference) should be optional for RCP applications. A bug
report/enhancement request I guess.

Paul I.
Previous Topic:React to closing of an editor
Next Topic:Activating editor
Goto Forum:
  


Current Time: Thu Sep 12 12:05:32 GMT 2024

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

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

Back to the top