RCP - IResourceChangeListener equivalent for non-file based editor input ? [message #255089] |
Wed, 23 June 2004 15:34  |
Eclipse User |
|
|
|
Originally posted by: itheg._spam_no_hotmail.com
hello -
i have an RCP app that has a view similar to the IDE's package explorer,
showing a treeviwer that shows all the editable models available as items in
the tree. These models are NOT file based. They are objects created
in-memory at runtime. I can select an item in the tree and open an editor
for it.
The question I have is, if I delete an item(model) in the tree, how will an
open editor for that item (model) get notified so that it can close itself ?
I see that Eclipse has the IResourceChangeListener that editors implement to
get resource events such as IResourceChangeEvent.POST_CHANGE etc thru the
ResourcesPlugin - BUT these seem to be implemented only for file-based
models.
of course, I can have my own interface defined that editors can implement,
and my view can send a 'delete' event to all listeners (editors)...but that
means other plugins, that want to extend my RCP have to know about that
interface etc...seems to defeat the purpose of using the Eclipse editor
framework.
has anyone done anything like this ? is there anyother Eclipse interface for
this ?
or am i missing something ? maybe the IResourceChangeListener is what i need
but i am not using it right ?
thanks in advance!
-sri
|
|
|
Re: RCP - IResourceChangeListener equivalent for non-file based editor input ? [message #255096 is a reply to message #255089] |
Wed, 23 June 2004 16:11   |
Eclipse User |
|
|
|
> I see that Eclipse has the IResourceChangeListener that editors implement
to
> get resource events such as IResourceChangeEvent.POST_CHANGE etc thru the
> ResourcesPlugin - BUT these seem to be implemented only for file-based
> models.
>
> of course, I can have my own interface defined that editors can implement,
> and my view can send a 'delete' event to all listeners (editors)...but
that
> means other plugins, that want to extend my RCP have to know about that
> interface etc...seems to defeat the purpose of using the Eclipse editor
> framework.
>
> has anyone done anything like this ? is there anyother Eclipse interface
for
> this ?
> or am i missing something ? maybe the IResourceChangeListener is what i
need
> but i am not using it right ?
If you are making a new editor for a memory based model, you will more than
likely have to implement a new IDocumentProvider for that editor to produce
the document. The IDocumentProvider has a method called
addElementStateListener(). You can make your document provider periodically
check to see if the in-memory model still exists (maybe when the document is
reset, the input is changed, and/or the document is requested), then notify
the listeners (one of which could be the editor).
If you want things to be more automatic, you could cause your IEditorInput
(you will probably have to implement one of these for your model as well) to
notify the IDocumentProvider when it is deleted (the IDocumentProvider could
hook-into the IEditorInput when it is connected to the document provider via
connect(Object)), which would, in turn, notify the editor that a delete
occurred.
Del.
|
|
|
Re: RCP - IResourceChangeListener equivalent for non-file based editor input ? [message #255139 is a reply to message #255096] |
Wed, 23 June 2004 17:05   |
Eclipse User |
|
|
|
Originally posted by: itheg._spam_no_hotmail.com
hi del -
thanks for the reply!
i forgot to mention that my editor is not text-based...it has some JFace
controls in it to edit the given model, extends EditorPart.
I see that the IDocumentProvider is in "org.eclipse.ui.texteditor"...
will it still work with a non-texteditor based editor ?
i browsed thru the methods in the various interfaces (IDocument,
IDocumentProvider, IElementStateListener etc)...they seem to be generic
enough and not really looking for a text-based editor/input....however their
javadocs only talk about it being used in texteditor...and these intefaces
are defined in the "org.eclipse.ui.texteditor" package....
do you think it will still work for me ?
thanks
-sri
"Del" <delmyers@cs.uvic.ca> wrote in message
news:cbco5b$js0$1@eclipse.org...
> If you are making a new editor for a memory based model, you will more
than
> likely have to implement a new IDocumentProvider for that editor to
produce
> the document. The IDocumentProvider has a method called
> addElementStateListener(). You can make your document provider
periodically
> check to see if the in-memory model still exists (maybe when the document
is
> reset, the input is changed, and/or the document is requested), then
notify
> the listeners (one of which could be the editor).
>
> If you want things to be more automatic, you could cause your IEditorInput
> (you will probably have to implement one of these for your model as well)
to
> notify the IDocumentProvider when it is deleted (the IDocumentProvider
could
> hook-into the IEditorInput when it is connected to the document provider
via
> connect(Object)), which would, in turn, notify the editor that a delete
> occurred.
>
> Del.
>
>
|
|
|
Re: RCP - IResourceChangeListener equivalent for non-file based editor input ? [message #255438 is a reply to message #255139] |
Thu, 24 June 2004 16:54   |
Eclipse User |
|
|
|
> hi del -
> thanks for the reply!
>
> i forgot to mention that my editor is not text-based...it has some JFace
> controls in it to edit the given model, extends EditorPart.
>
> I see that the IDocumentProvider is in "org.eclipse.ui.texteditor"...
> will it still work with a non-texteditor based editor ?
No, IDocumentProviders are meant for text only as far as I know. They supply
IDocuments, which are text representations of your data.
Nevertheless, you will still need to implement an IEditorInput if you want
Eclipse to function properly with your new editor. Then, in your
IEditorPart's init(IEditorSite, IEditorInput), you can hook into the
IEditorInput (using a custom listener interface). The IEditorInput would,
itself, listen to the model. Or, you could do as you suggest and skip "the
middle man" by making the editor hook into the model directly, which could
be retrieved by your IEditorInput. I assume that your model has some method
of notifying listeners when it is changed. It's really up to you.
Del.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06096 seconds