Editor model contained in EditorInput or EditorPart? [message #324029] |
Wed, 16 January 2008 14:36  |
Eclipse User |
|
|
|
Hi,
When developing a custom MPE for Eclipse (based on a file) I have an
underlying model for the content, and 2 tabs for the editing. The way I
see it I have two options for where to place the model:
1) Let the MultiPageEditorPart contain the model and have
load/save/convert functionality from/to an IFileEditorInput on
initialization and save inside the EditorPart.
2) Implement a CustomEditorInput that extends FileEditorInput and let
this class contain the model object and getter/setter/parser that
converts the file to/from this model.
Which one of the methods is preferred and what are the reasons for it?
If I choose 2), how do I make my MPE use the CustomEditorInput? Do I
just cast it from the IFileEditorInput in the init(..) of the MPE or
should I register it in some way in plugin.xml? Do I need a custom
DocumentProvider in this case?
Thanks,
.../Ola
|
|
|
|
Re: Editor model contained in EditorInput or EditorPart? [message #324116 is a reply to message #324087] |
Thu, 17 January 2008 11:55  |
Eclipse User |
|
|
|
Paul Webster wrote:
> Think of your IEditorInput as an abstract, like java.io.File. It
> should allow you to "open" your model, the way File allows you to get
> an InputStream or Reader. There is, I believe, a note on the
> IEditorInput javadoc that cautions *against* storing your model in it.
Right. It is important to not keep the model in the editor input as this
object is widely referenced (e.g. in navigation history) even after you
close your editor.
Dani
>
> Text follows that pattern, they use the IEditorInput + an
> IDocumentProvider to get the IDocument (model) that they use.
>
> PW
>
|
|
|
Powered by
FUDForum. Page generated in 0.48968 seconds