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?
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.
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 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.