Editor vs. View [message #297145] |
Mon, 09 January 2006 18:10  |
Eclipse User |
|
|
|
Originally posted by: jbell80.msn.com
I am fairly new to using eclipse but what I have seen so far is very
impressive. I have built several small apps and I believe I understand
the basic principles but I have two questions I can't seem to find answers
to...
1. Is it possible to have more than one editor open in a perspective? If
it is how would it be possible? (i.e. a Text Editor and a Web Browser both
existing as "Editors")
2. I have been trying to extend AbstractTextEditor into a View but it is
not possible to extend two classes at the same time.
Thanks for any help.
Jon
|
|
|
|
|
|
|
Re: Editor vs. View [message #297174 is a reply to message #297148] |
Tue, 10 January 2006 07:23   |
Eclipse User |
|
|
|
Leo Bayer wrote:
> You are right, all editors must extend EditorPart, and all views must
> extend ViewPart. Because these two classes have some expectations about
> their state they are not designed to be embedded within each other.
>
> As for page layout, I have never seen it done with editors but it seems
> like it would be possible given that perspectives can be saved in a
> state where editors are arranged differently.
You guys have most of it. There's one Editor area, and all editors go
there. Editors implement IEditorPart (and can subclass EditorPart for
convenience). Same pattern with views.
You can split editors into multiple stacks within the editor area, but
you can't move them outside. Views can be split into multiple stacks
and placed around the workbench window.
It used to be that editors had a edit-dirty-save lifecycle, but now
views can participate in the save lifecycle as well. Editors have an
IEditorInput, and views don't have an input.
Like Alex said, you can use a JFace TextViewer or SourceViewer in your
view, and that can give you a lot of the syntax highlighting/context
completion, etc.
But if you want to try something funky, you could subclass
AbstractTextEditor and implement IViewPart ... as long as your view
initialization code "faked out" the initialization that
AbstractTextEditor needed, it might work ... although I have no idea
what the TextEditorViewPart would do with any toolbar items that were
generated by AbstractTextEditor.
Later,
PW
|
|
|
|
Re: Editor vs. View [message #297310 is a reply to message #297236] |
Wed, 11 January 2006 11:38  |
Eclipse User |
|
|
|
Originally posted by: automatic.javalobby.org
> Why on earth would you want to create a view out of an editor?
Because the EditorArea is ugly in an RCP application; once it turns up, there's no getting rid of it.
If you're editing a non-IDE RCP app, and yet you want to present a file in the form of an editor (e.g. editing the atom.xml summary of a news feed, for example) then it's nice to show it as a view (can be docked with other views, or independently closed) without restricting it to one location that leaves a large gaping hole when closed.
Alex.
|
|
|
Powered by
FUDForum. Page generated in 0.04446 seconds