Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How to know if an editor is disposed?
How to know if an editor is disposed? [message #504193] Thu, 17 December 2009 11:02 Go to next message
Adam Neal is currently offline Adam NealFriend
Messages: 40
Registered: July 2009
Member
Hi,

What is the best way to tell if an editor has been disposed? there is no
isDisposed() API. Currently I'm checking if getDocumentProvider() == null.
Is that acceptable?

Thanks in advance,
Adam
Re: How to know if an editor is disposed? [message #504233 is a reply to message #504193] Thu, 17 December 2009 18:58 Go to previous messageGo to next message
Adam Neal is currently offline Adam NealFriend
Messages: 40
Registered: July 2009
Member
Perhaps the better way is to check against the control?

Control c = (Control) editor.getAdapter(Control.class);
boolean isDisposed = c == null || c.isDisposed();

Is this perhaps the best way?
Re: How to know if an editor is disposed? [message #504236 is a reply to message #504233] Thu, 17 December 2009 14:48 Go to previous messageGo to next message
Alex Le is currently offline Alex LeFriend
Messages: 649
Registered: July 2009
Senior Member
Adam wrote:
> Perhaps the better way is to check against the control?
>
> Control c = (Control) editor.getAdapter(Control.class);
> boolean isDisposed = c == null || c.isDisposed();
>
> Is this perhaps the best way?
>
>

How about using IPartListener/IPartListener2 which will tell you when an
IPart, the IEditorPart is closed, completely gone?

You would have to check what kind of IEditorPart it is, though. If it's
your editor that you implement, you can have your editor implement a
marker interface like IMyEditor, thus able to detect if the IEditorPart
is an instance of IMyEditor. Otherwise, you would have to know the
target editor to begin with.
Re: How to know if an editor is disposed? [message #504349 is a reply to message #504236] Fri, 18 December 2009 13:10 Go to previous messageGo to next message
Adam Neal is currently offline Adam NealFriend
Messages: 40
Registered: July 2009
Member
Thanks Al.

Problem is that this code is part of a generic framework. Part of the
framework is listing for part closings and using these notifications to
maintain its internal cache. However, clients can also pass in objects
which may have stale references to editors if they have not been aware of
part closings. Therefore, I need a way to test the editor I recieve to see
if its been disposed or not...

--Adam
Re: How to know if an editor is disposed? [message #504650 is a reply to message #504349] Mon, 21 December 2009 21:33 Go to previous message
Alex Le is currently offline Alex LeFriend
Messages: 649
Registered: July 2009
Senior Member
Adam wrote:
> Thanks Al.
>
> Problem is that this code is part of a generic framework. Part of the
> framework is listing for part closings and using these notifications to
> maintain its internal cache. However, clients can also pass in objects
> which may have stale references to editors if they have not been aware of
> part closings. Therefore, I need a way to test the editor I recieve to see
> if its been disposed or not...
>
> --Adam
>
>

Sounds like the framework, if works correctly, should also be able to
receive notifications on the parts being closed by Eclipse itself, even
with the IEditorParts passed to the framework by the the clients. The
framework would update/consolidate the cache for all closed IEditorPart
events received.
Previous Topic:FC12 sqlite version error
Next Topic:Displaying HTML content with HREFs to documentation plug-in???
Goto Forum:
  


Current Time: Wed Apr 24 23:33:28 GMT 2024

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

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

Back to the top