Restoring editors [message #151458] |
Wed, 10 May 2006 15:07 |
Eclipse User |
|
|
|
Originally posted by: apill.dolby.co.uk
How do I get an editor not to open with it's restored state if the state
cannot be loaded.
For example,
1. if I close my RCP application with an editor open for a resource.
2. Then i delete the resource
3. Reopen the RCP app.
Currently the editor opens and contains a stack trace. I don't know what
my IElementFactory should do if it cannot create a valid input.
Returning null in the IElementFactory.createElement() method causes a
PartInit exception.
Can anyone tell me what i need to do? I must need to return or set some
status somewhere so eclipse does not re-create my editor.
Thanks
Adrian
|
|
|
Re: Restoring editors [message #151608 is a reply to message #151458] |
Thu, 11 May 2006 11:50 |
|
Adrian wrote:
> How do I get an editor not to open with it's restored state if the state
> cannot be loaded.
I don't think there's a way to avoid that right now. Say you have 8
editors open, and you restart eclipse. It has all 8 editor references,
but only instantiates them as they become visible to the user.
The way to avoid it for now is to not delete files outside of your RCP
.... do it from within your RCP. Or maybe you can schedule the workspace
to do a refresh on startup ... it'll slow down your startup time
(depending on how big your workspace is), but maybe the refresh will
cause the resource delta to close editors it no longer needs.
Hacky, and while I haven't tried this, what about adding an
IPartListener2 and trying to close the ErrorPart as soon as it's active.
You'd have to use some chicanery and it would flicker, but then be gone.
Later,
PW
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
|
|
|
Re: Restoring editors [message #151636 is a reply to message #151608] |
Thu, 11 May 2006 14:32 |
Eclipse User |
|
|
|
Originally posted by: apill.dolby.co.uk
Paul Webster wrote:
> Adrian wrote:
>
>> How do I get an editor not to open with it's restored state if the
>> state cannot be loaded.
>
>
> I don't think there's a way to avoid that right now. Say you have 8
> editors open, and you restart eclipse. It has all 8 editor references,
> but only instantiates them as they become visible to the user.
>
> The way to avoid it for now is to not delete files outside of your RCP
> ... do it from within your RCP. Or maybe you can schedule the workspace
> to do a refresh on startup ... it'll slow down your startup time
> (depending on how big your workspace is), but maybe the refresh will
> cause the resource delta to close editors it no longer needs.
>
> Hacky, and while I haven't tried this, what about adding an
> IPartListener2 and trying to close the ErrorPart as soon as it's active.
> You'd have to use some chicanery and it would flicker, but then be gone.
>
> Later,
> PW
Thanks for the help, but actually the resource i am editing is in a
database. We are using RCP as a front end to our J2EE EJB3 tier. So, the
resources are quite likely to be deteled by other users of the system.
I'll look into your other suggestions. Otherwise, I might get the editor
to handle a specific error and tell the user the resource no longer exits.
Ta.
A
|
|
|
Re: Restoring editors [message #151692 is a reply to message #151636] |
Thu, 11 May 2006 16:36 |
|
Adrian wrote:
>
>
> Thanks for the help, but actually the resource i am editing is in a
> database. We are using RCP as a front end to our J2EE EJB3 tier. So, the
> resources are quite likely to be deteled by other users of the system.
>
> I'll look into your other suggestions. Otherwise, I might get the editor
> to handle a specific error and tell the user the resource no longer exits.
Something else to consider is the model that text editors use.
an IEditorInput is an abstract, like a filename. A text editor gets an
IDocumentProvider, and asks it for an IDocument.
The IDocument is your model.
The editor then registers an IElementStateListener with the
IDocumentProvider, and when the IDocumentProvider calls the editor with
elementDeleted(*), the editor can call the closeEditor(*) method to
close itself.
Check out how AbstractTextEditor#updateDocumentProvider(*) works with
the IDocumentProvider and ElementStateListener.
Your IEditorInput would be some kind of object reference, your
IDocumentProvider would hold the connection information, InitialContext,
etc, and your IDocument would provide access into your model.
On startup based on re-connection, your IDocumentProvider could fire the
elementDeleted(*) for the IEditorInputs that no longer exist.
Later,
PW
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
|
|
|
|
Re: Restoring editors [message #153581 is a reply to message #151458] |
Sat, 20 May 2006 12:27 |
Eclipse User |
|
|
|
Originally posted by: Lamont_Gilbert.rigidsoftware.com
Adrian wrote:
> How do I get an editor not to open with it's restored state if the state
> cannot be loaded.
>
> For example,
>
> 1. if I close my RCP application with an editor open for a resource.
>
> 2. Then i delete the resource
>
> 3. Reopen the RCP app.
>
> Currently the editor opens and contains a stack trace. I don't know what
> my IElementFactory should do if it cannot create a valid input.
> Returning null in the IElementFactory.createElement() method causes a
> PartInit exception.
>
> Can anyone tell me what i need to do? I must need to return or set some
> status somewhere so eclipse does not re-create my editor.
>
> Thanks
>
> Adrian
Why are you automatically opening editors if you can not be sure they
can open?
I have a part listener registered on my Editor. In part activated I
check to see if the model is null. If it is i create a job that closes
the editor and make it a system job and schedule it...
My program is also a database program using JDO &/|| jdbc. Its a nasty
technique but I started it years ago and I have not reviewed if a better
technique is available or not.
CL
|
|
|
|
|
|
Re: Restoring editors [message #153831 is a reply to message #153577] |
Tue, 23 May 2006 19:26 |
Eclipse User |
|
|
|
Originally posted by: Lamont_Gilbert.rigidsoftware.com
Alexander Karnstedt wrote:
> I'm trying to do something similar to the AbstractTextEditor for
> database objects.
>
> Another problem I've encountered: How can the IEditorInput provide the
> name and tooltip information if it just holds some kind of database ID?
>
The IEditorInput needs to be given a name. It needs to hold more than a
simple database ID. Surely the human editing the 'thing' calls it by
something other than an ID?
I do have editors that do not use names as well.
Of course getting Names to go with your ID can be quite tricky as people
that deal with/develop ORM sometimes go off the deep end and try to act
like a program should not know any info or even ID of an object. They
try to make the persistance so transparent it becomes problematic.
> These information are only available after reading the model objects
> from the database.
>
how did you get the ID? Thats how you get the name. This may involve
significant change to your app but thats the way it is.
CL
|
|
|
|
Powered by
FUDForum. Page generated in 0.08332 seconds