Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Editor model contained in EditorInput or EditorPart?
Editor model contained in EditorInput or EditorPart? [message #324029] Wed, 16 January 2008 14:36 Go to next message
Eclipse UserFriend
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 #324087 is a reply to message #324029] Thu, 17 January 2008 10:21 Go to previous messageGo to next message
Eclipse UserFriend
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.

Text follows that pattern, they use the IEditorInput + an
IDocumentProvider to get the IDocument (model) that they use.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm
Re: Editor model contained in EditorInput or EditorPart? [message #324116 is a reply to message #324087] Thu, 17 January 2008 11:55 Go to previous message
Eclipse UserFriend
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
>
Previous Topic:Re: manage menu contribution
Next Topic:TableViewer blank lines, VIRTUAL and ILazyContentProvider
Goto Forum:
  


Current Time: Fri Jul 18 00:31:49 EDT 2025

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

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

Back to the top