Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Editor vs. View
Editor vs. View [message #297145] Mon, 09 January 2006 18:10 Go to next message
Eclipse UserFriend
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 #297146 is a reply to message #297145] Mon, 09 January 2006 18:34 Go to previous messageGo to next message
Eclipse UserFriend
The views and editors exist as two seperate parts.

You can have any number of either but all the editors will appear within
the rectangular editor area (I don't know what this are is actually
called), and all the views will appear around the editor area.

Every editor exists as an instance of an IEditorPart
and every view exists as an instance of an IViewPart

You cannot embed an editor within a view nor vise-versa.

You can find a simple explanation in eclipse help see:
http://help.eclipse.org/help31/index.jsp?topic=/org.eclipse. platform.doc.user/gettingStarted/qs-02b.htm

- Leo


Jon Bell wrote:
> 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 #297147 is a reply to message #297146] Mon, 09 January 2006 18:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jbell80.msn.com

That makes sense and is consistent with what I have read. However, why
when a view is created does it need to extend ViewPart? By extending
ViewPart I am unable to extend AbstractTextEditor.

Also is it possible to "layout" an editor. With views it is possible to
lay them out using IPageLayout (.TOP / .LEFT / etc...) but the EditorArea
is either Visible or Hidden.

Thanks,
Jon

Leo Bayer wrote:

> The views and editors exist as two seperate parts.

> You can have any number of either but all the editors will appear within
> the rectangular editor area (I don't know what this are is actually
> called), and all the views will appear around the editor area.

> Every editor exists as an instance of an IEditorPart
> and every view exists as an instance of an IViewPart

> You cannot embed an editor within a view nor vise-versa.

> You can find a simple explanation in eclipse help see:
>
http://help.eclipse.org/help31/index.jsp?topic=/org.eclipse. platform.doc.user/gettingStarted/qs-02b.htm

> - Leo


> Jon Bell wrote:
>> 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 #297148 is a reply to message #297147] Mon, 09 January 2006 18:46 Go to previous messageGo to next message
Eclipse UserFriend
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.

- Leo


Jon Bell wrote:
> That makes sense and is consistent with what I have read. However, why
> when a view is created does it need to extend ViewPart? By extending
> ViewPart I am unable to extend AbstractTextEditor.
>
> Also is it possible to "layout" an editor. With views it is possible to
> lay them out using IPageLayout (.TOP / .LEFT / etc...) but the
> EditorArea is either Visible or Hidden.
>
> Thanks,
> Jon
>
> Leo Bayer wrote:
>
>> The views and editors exist as two seperate parts.
>
>
>> You can have any number of either but all the editors will appear
>> within the rectangular editor area (I don't know what this are is
>> actually called), and all the views will appear around the editor area.
>
>
>> Every editor exists as an instance of an IEditorPart
>> and every view exists as an instance of an IViewPart
>
>
>> You cannot embed an editor within a view nor vise-versa.
>
>
>> You can find a simple explanation in eclipse help see:
>>
> http://help.eclipse.org/help31/index.jsp?topic=/org.eclipse. platform.doc.user/gettingStarted/qs-02b.htm
>
>
>> - Leo
>
>
>
>> Jon Bell wrote:
>>
>>> 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 #297151 is a reply to message #297148] Mon, 09 January 2006 21:25 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

That doesn't preclude putting a SourceViewer (for example) inside a View. There's also a TextViewer that might be suitable.

It's possible to split the editor area (correct name, by the way) into two seperate editor documents, but it's not possible to move them outside of the editor area (or mix and match with the views).

All an Editor is is something that extends EditorPart and embeds a SourceViewer (or similar). So you should be able to do something with a view and have rudimentary text presentation/editing facilities, but you'd have to provide hooks for things like saving, checking whether the document has been changed and so on.

Alex.
Re: Editor vs. View [message #297174 is a reply to message #297148] Tue, 10 January 2006 07:23 Go to previous messageGo to next message
Eclipse UserFriend
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 #297236 is a reply to message #297145] Tue, 10 January 2006 13:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sunil_kamath.nohotspammail.com

Jon Bell <jbell80@msn.com> wrote:
> 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")
>

Do you mean having two editors for the same file, or for different files, or
what?

> 2. I have been trying to extend AbstractTextEditor into a View but
> it is not possible to extend two classes at the same time.
>

Why on earth would you want to create a view out of an editor?

--
Sunil
Re: Editor vs. View [message #297310 is a reply to message #297236] Wed, 11 January 2006 11:38 Go to previous message
Eclipse UserFriend
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.
Previous Topic:Configuration Reset
Next Topic:Open files, projects at startup vs. network connections
Goto Forum:
  


Current Time: Wed Jun 04 21:45:59 EDT 2025

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

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

Back to the top