Bug 502837 - org.eclipse.ui.editors ext point should allow binding without redefining an editor
Summary: org.eclipse.ui.editors ext point should allow binding without redefining an e...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.6   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 4.7 M3   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: noteworthy
Depends on:
Blocks:
 
Reported: 2016-09-30 05:33 EDT by Mickael Istria CLA
Modified: 2016-10-17 12:26 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mickael Istria CLA 2016-09-30 05:33:05 EDT
Currently, association between an editor and a file content-type can only happen when defining the editor. However, it's possible that some editors can support additional content-types thanks to some 3rd party extension, in which case the 3rd party extension provider would like to associate the editor with the content-type without redefining it.
The org.eclipse.ui.editors extension point (or another one if there is a better candidate, or a new one if it's better) could allow a root "contentTypeBinding" element which would just take as input a content-type and and editorId to store and use the association when resolving editor.
Comment 1 Mickael Istria CLA 2016-09-30 05:33:31 EDT
Tentative target 4.7.M3.
Comment 2 Eclipse Genie CLA 2016-09-30 10:25:22 EDT
New Gerrit change created: https://git.eclipse.org/r/82258
Comment 3 Mickael Istria CLA 2016-10-12 12:24:38 EDT
@Dani: If possible, I'd really like it to be in M3. Can you please have a look?
Comment 4 Mickael Istria CLA 2016-10-13 13:37:27 EDT
As it's adding an element to an existing extension point in an existing bundle, this doesn't require change in documentation, does it?
Comment 5 Eclipse Genie CLA 2016-10-13 14:03:06 EDT
New Gerrit change created: https://git.eclipse.org/r/83157
Comment 6 Mickael Istria CLA 2016-10-13 14:03:44 EDT
(In reply to Eclipse Genie from comment #5)
> New Gerrit change created: https://git.eclipse.org/r/83157

This shows how it can be used (here in the org.eclipse.ui.genericeditor.example)
Comment 9 Lars Vogel CLA 2016-10-14 04:39:56 EDT
Mickael, please update the N&N. Also use this opportunity to replace the screenshot of the code with the real code in the existing description.
Comment 10 Dani Megert CLA 2016-10-14 05:10:33 EDT
(In reply to Mickael Istria from comment #3)
> @Dani: If possible, I'd really like it to be in M3. Can you please have a
> look?

Giving me a bit more time than just 1.5 days would have been nice.
Comment 11 Mickael Istria CLA 2016-10-14 05:19:17 EDT
@Dani: Initial patch was submitted on Sept 30th and IIRC I added  you as reviewer from this day. Maybe it wasn't clear, but when I add someone as reviewer on a bug, it means that I'm asking them for a review, and I start counting time from there. I'm sorry if this is not how you understood it, so I'll try to ping you simultaneously with the review request next time to make sure we're in on the same schedule.
Comment 12 Eclipse Genie CLA 2016-10-14 05:35:30 EDT
New Gerrit change created: https://git.eclipse.org/r/83196
Comment 13 Mickael Istria CLA 2016-10-14 12:17:05 EDT
I'm marking it as resolved since all the necessary steps have been performed (extension, example, N&N). Feel free to reopen if there is something wrong enough there to requires a revert rather than a new bug report.
Comment 14 Dani Megert CLA 2016-10-15 10:37:52 EDT
> Advertises that an existing editor is suitable to editor resource of an existing content-type.

I'm not sure what language this is, but definitely not English.
Comment 15 Dani Megert CLA 2016-10-15 10:38:20 EDT
.
Comment 16 Dani Megert CLA 2016-10-15 10:40:47 EDT
I don't think a new element is required. It could be done with the existing attributes since most attributes are implies.

Currently the new behavior violates the description of the extension point:
"This extension point is used to add new editors "
Comment 17 Dani Megert CLA 2016-10-15 10:48:22 EDT
(In reply to Mickael Istria from comment #11)
> @Dani: Initial patch was submitted on Sept 30th and IIRC I added  you as
> reviewer from this day. Maybe it wasn't clear, but when I add someone as
> reviewer on a bug, it means that I'm asking them for a review, and I start
> counting time from there. I'm sorry if this is not how you understood it, so
> I'll try to ping you simultaneously with the review request next time to
> make sure we're in on the same schedule.

Mickael, you have added 4 (four!) people to review the change:
- Alexander Kurtakov
- Dani Megert
- Lars Vogel
- Sopot Cela

I am very busy, so, I usually wait for one of the others to add some review comments.


But at the end it looks like you do not care about reviews and merge things even if you do not get a +1 or +2.
Comment 19 Dani Megert CLA 2016-10-17 04:36:02 EDT
(In reply to Dani Megert from comment #16)
> I don't think a new element is required. It could be done with the existing
> attributes since most attributes are implies.

I take that back. It would be misleading. However, you probably also need the 'default' attribute.


The description must be updated. It is no longer only to add new editors.
Comment 20 Mickael Istria CLA 2016-10-17 04:51:16 EDT
(In reply to Dani Megert from comment #19)
> The description must be updated. It is no longer only to add new editors.

Current description is http://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/bundles/org.eclipse.ui/schema/editors.exsd#n9 and mentions the possibility to use it to define editor/content-type association.
Or maybe you're referencing some other file or part of this file?

> you probably also need the 'default' attribute.

At the moment, I didn't need it: either the content-type already has an editor and there is no clear reason for the contribution to be allowed to define itself as default, or it doesn't have an editor and the associated one is the only one so it becomes default (only) one.
However, I found a corner-case when a file has multiple content-types which is that the IDE.openEditor resolves against the deepest/most generic one, which is usually the opposite of what the user would expect IMO. However, that's something for another bugzilla that's not related to current one.
Comment 21 Dani Megert CLA 2016-10-17 05:07:00 EDT
(In reply to Mickael Istria from comment #20)
> (In reply to Dani Megert from comment #19)
> > The description must be updated. It is no longer only to add new editors.
> 
> Current description is
> http://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/bundles/org.eclipse.ui/schema/editors.exsd#n9
> and mentions the possibility to use it to define editor/content-type
> association.

I would mention the two different cases more explicitly, because one also associates the new editor. The description should mention that one can contribute a new editor or bind an existing editor to a content type.

See also comment 14.
Comment 22 Mickael Istria CLA 2016-10-17 05:19:51 EDT
(In reply to Dani Megert from comment #21)
> I would mention the two different cases more explicitly, because one also
> associates the new editor. The description should mention that one can
> contribute a new editor or bind an existing editor to a content type.

Ok, What about:
"""
This extension point is used to add new editors to the 
workbench or to associate already declared editors with resource content-types.
An editor is a visual component within ...
"""
?

> see also comment #14
(In reply to Dani Megert from comment #14)
>> Advertises that an existing editor is suitable to editor resource of an existing content-type.
> I'm not sure what language this is, but definitely not English.

Yeah, there is a grammatical issue there.
What about
""" Advertises that an existing editor is suitable to edit resources of an existing content-type """?
Comment 23 Dani Megert CLA 2016-10-17 09:57:26 EDT
(In reply to Mickael Istria from comment #22)
> (In reply to Dani Megert from comment #21)
> Ok, What about:
> """
> This extension point is used to add new editors to the 
> workbench or to associate already declared editors with resource
> content-types.

Content types are not related to resources, hence you should not use "resource" here.


> > see also comment #14
> (In reply to Dani Megert from comment #14)
> >> Advertises that an existing editor is suitable to editor resource of an existing content-type.
> > I'm not sure what language this is, but definitely not English.
> 
> Yeah, there is a grammatical issue there.
> What about
> """ Advertises that an existing editor is suitable to edit resources of an
> existing content-type """?

"Suitable" seems to weak. We really register the editor for that content type. Again, leave "resources" away.
Comment 24 Mickael Istria CLA 2016-10-17 10:14:23 EDT
Ok, here is another shot
""" This extension point is used to add new editors to the workbench or to associate already declared editors with content-types."""
and
""" Advertises that an existing editor is registered to edit some existing content-type."""
Comment 25 Dani Megert CLA 2016-10-17 10:28:34 EDT
(In reply to Mickael Istria from comment #24)
> Ok, here is another shot
> """ This extension point is used to add new editors to the workbench or to
> associate already declared editors with content-types."""
> and
This extension point is used to add new editors to the workbench or to
associate an already declared editor with a content-type.


> """ Advertises that an existing editor is registered to edit some existing
> content-type."""
Binds an existing editor to the given content-type.