Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [pde-dev] Generic Editor and form tabs

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 <scela@xxxxxxxxxx> 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
> pde-dev@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://dev.eclipse.org/mailman/listinfo/pde-dev


Back to the top