Generic Editor and form tabs

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Generic Editor and form tabs

Sopot Cela
Hello,

The Target Definition file generic editor is an example of many cases for which I plan to provide a textual editor with syntax highlighting and autocomplete. The .target generic editor is already available and provides the two above mentioned features. To open it, now you have to 'Open with...' -> Generic Editor. So it's basically an editor in its own right.

I would like to add this alternative editor as a form tab to the main target definition editor (the UI one). So basically the TP editor would have 4 tabs: 'Definition', 'Content', 'Environment' and a new, say, 'Text editor' which would basically be equivalent to opening this file with the generic editor mentioned above. Just that this would be in the form tab rather than opening it as a separate editor.

Is there any (recommended) way to make this transition from a separate editor to a tab in a form editor? My initial investigation shows this would have to be added as a separate FormPage through the FormEditor#addPage but I'd like to check here first if there is a recommended way when you already have a working separate editor in place.

Thanks for the time,
Sopot
_______________________________________________
pde-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/pde-dev
Reply | Threaded
Open this post in threaded view
|

Re: Generic Editor and form tabs

Jonah Graham
Hi Sopot,

I have recently done a similar thing integrating an Xtext editor into
a multi-page editor for CDT (see [1] for a slightly dated WIP). You
can generally integrate the editor as a page and it will behave pretty
much as if it was opened as a separate editor. There are a few caveats
I outline below.

The default MultiPageEditorPart (parent of FormEditor) will forward
getAdapter calls to the current page in the multi-page editor (mpe).
This leads to some things not working as expected, for example outline
view. So for those items you may want to delegate to the generic
editor part instance all the time, not just when your tab is active.
Have a look at PDEFormEditor.getAdapter(Class<T>) for some examples
that may need to adapt at the form editor level.

The other consideration is synchronisation of changes between tabs. As
the current PDE target platform editor is unlikely to use the
ITextFileBuffer, but the generic text editor probably does (via the
TextFileDocumentProvider) there will be some considerations there on
how to handle users changing tabs. The other PDE editors
(Manifest/plugin/feature/build.properties) all handle this
synchronization quite well and you can move between the tabs with
little effort, seeing unsaved changes reflected in different tabs.
However for some non-platform editors, for example, Xtext editors,
only synchronize on save. So you can have two editors open on the same
file, but only one will be "dirty". Xtext minimize this problem with
o.e.xtext.ui.editorDirtyStateEditorSupport by giving a pop-up to the
user to warn them before the user has two dirty editors on the same
file.

HTH
Jonah

[1] https://git.eclipse.org/r/#/c/85853/

~~~
Jonah Graham
Kichwa Coders Ltd.
www.kichwacoders.com


On 6 March 2017 at 10:13, Sopot Cela <[hidden email]> wrote:

> Hello,
>
> The Target Definition file generic editor is an example of many cases for which I plan to provide a textual editor with syntax highlighting and autocomplete. The .target generic editor is already available and provides the two above mentioned features. To open it, now you have to 'Open with...' -> Generic Editor. So it's basically an editor in its own right.
>
> I would like to add this alternative editor as a form tab to the main target definition editor (the UI one). So basically the TP editor would have 4 tabs: 'Definition', 'Content', 'Environment' and a new, say, 'Text editor' which would basically be equivalent to opening this file with the generic editor mentioned above. Just that this would be in the form tab rather than opening it as a separate editor.
>
> Is there any (recommended) way to make this transition from a separate editor to a tab in a form editor? My initial investigation shows this would have to be added as a separate FormPage through the FormEditor#addPage but I'd like to check here first if there is a recommended way when you already have a working separate editor in place.
>
> Thanks for the time,
> Sopot
> _______________________________________________
> pde-dev mailing list
> [hidden email]
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://dev.eclipse.org/mailman/listinfo/pde-dev
_______________________________________________
pde-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/pde-dev
Reply | Threaded
Open this post in threaded view
|

Re: Generic Editor and form tabs

Curtis Windatt
In reply to this post by Sopot Cela
Jonah has given some excellent suggestions on potential problem areas.  Most of the editors in PDE already have text editors in a tab and you should aim for similar look and feel.  We did not create a text editor at the time because there was no formal specification for a target definition's contents.  Its shape was therefore not API and we continued to make edits to it.  However, there have not been any changes to the file contents in quite some time and I expect it to remain stable going forward.  I look forward to seeing this contribution added to PDE.

Curtis Windatt



From:        Sopot Cela <[hidden email]>
To:        [hidden email]
Date:        03/06/2017 04:13 AM
Subject:        [pde-dev] Generic Editor and form tabs
Sent by:        [hidden email]




Hello,

The Target Definition file generic editor is an example of many cases for which I plan to provide a textual editor with syntax highlighting and autocomplete. The .target generic editor is already available and provides the two above mentioned features. To open it, now you have to 'Open with...' -> Generic Editor. So it's basically an editor in its own right.

I would like to add this alternative editor as a form tab to the main target definition editor (the UI one). So basically the TP editor would have 4 tabs: 'Definition', 'Content', 'Environment' and a new, say, 'Text editor' which would basically be equivalent to opening this file with the generic editor mentioned above. Just that this would be in the form tab rather than opening it as a separate editor.

Is there any (recommended) way to make this transition from a separate editor to a tab in a form editor? My initial investigation shows this would have to be added as a separate FormPage through the FormEditor#addPage but I'd like to check here first if there is a recommended way when you already have a working separate editor in place.

Thanks for the time,
Sopot
_______________________________________________
pde-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/pde-dev





_______________________________________________
pde-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/pde-dev
Reply | Threaded
Open this post in threaded view
|

Re: Generic Editor and form tabs

Sopot Cela
Thank you for the hints.

I ran into a roadblock in trying to create an instance of IEditorPart from an editor id, which is ultimately the only thing I have to start with. This IEditorPart instance is what I need to then use the addPage(IEditorPart,IEditorInput), which would allow me to reuse the editor that is already there rather than re-implementing a separate page.

If I turn a bad boy and use internals (cast IEditorDescriptor into EditorDescriptor and then use the createEditor method) I see the editor as in this screenshot: https://imgur.com/a/wFG53 (note the extra editor tab). So ultimately this takes me to bug 99568 . As of now I haven't found a non-internal way of going from an editor id to an instance of IEditorPart.

Sopot

----- Oorspronkelijk bericht -----

> Van: "Curtis Windatt" <[hidden email]>
> Aan: "Eclipse PDE general developers list." <[hidden email]>
> Verzonden: Dinsdag 7 maart 2017 15:36:24
> Onderwerp: Re: [pde-dev] Generic Editor and form tabs
>
> Jonah has given some excellent suggestions on potential problem areas. Most
> of the editors in PDE already have text editors in a tab and you should aim
> for similar look and feel. We did not create a text editor at the time
> because there was no formal specification for a target definition's
> contents. Its shape was therefore not API and we continued to make edits to
> it. However, there have not been any changes to the file contents in quite
> some time and I expect it to remain stable going forward. I look forward to
> seeing this contribution added to PDE.
>
> Curtis Windatt
>
>
>
> From: Sopot Cela <[hidden email]>
> To: [hidden email]
> Date: 03/06/2017 04:13 AM
> Subject: [pde-dev] Generic Editor and form tabs
> Sent by: [hidden email]
>
>
>
>
> Hello,
>
> The Target Definition file generic editor is an example of many cases for
> which I plan to provide a textual editor with syntax highlighting and
> autocomplete. The .target generic editor is already available and provides
> the two above mentioned features. To open it, now you have to 'Open with...'
> -> Generic Editor. So it's basically an editor in its own right.
>
> I would like to add this alternative editor as a form tab to the main target
> definition editor (the UI one). So basically the TP editor would have 4
> tabs: 'Definition', 'Content', 'Environment' and a new, say, 'Text editor'
> which would basically be equivalent to opening this file with the generic
> editor mentioned above. Just that this would be in the form tab rather than
> opening it as a separate editor.
>
> Is there any (recommended) way to make this transition from a separate editor
> to a tab in a form editor? My initial investigation shows this would have to
> be added as a separate FormPage through the FormEditor#addPage but I'd like
> to check here first if there is a recommended way when you already have a
> working separate editor in place.
>
> Thanks for the time,
> Sopot
> _______________________________________________
> pde-dev mailing list
> [hidden email]
> To change your delivery options, retrieve your password, or unsubscribe from
> this list, visit
> https://dev.eclipse.org/mailman/listinfo/pde-dev
>
>
>
>
>
> _______________________________________________
> pde-dev mailing list
> [hidden email]
> To change your delivery options, retrieve your password, or unsubscribe from
> this list, visit
> https://dev.eclipse.org/mailman/listinfo/pde-dev
_______________________________________________
pde-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/pde-dev