Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 356116

Summary: [EditorMgmt] IEditorRegistry.getDefaultEditor fails to find an editor even though one exists
Product: [Eclipse Project] Platform Reporter: Ed Merks <Ed.Merks>
Component: UIAssignee: Remy Suen <remy.suen>
Status: RESOLVED FIXED QA Contact: Remy Suen <remy.suen>
Severity: normal    
Priority: P3 CC: daniel_megert, remy.suen, sbouchet
Version: 3.7   
Target Milestone: 3.8 M4   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 349552    
Attachments:
Description Flags
EditorRegistry patch v1 none

Description Ed Merks CLA 2011-08-29 15:58:20 EDT
The implement in EditorRegistry of getDefaultEditor guesses a content type and then tries to find the editor based on that one content type.  The problem is that if there is no editor registered for the guessed content type, null is returned even when there are other content types for which there are registered editors. This causes problems for EMF:

  https://bugs.eclipse.org/bugs/show_bug.cgi?id=349552

It would be much better (i.e., more correct with regard to the documented behavior) if the method implementation considered each possible content type and returned an editor descriptor if there is any content type with a registered editor.
Comment 1 Dani Megert CLA 2011-08-30 04:52:45 EDT
It should use IContentTypeMatcher.findContentTypesFor(String) and try all content types.
Comment 2 Remy Suen CLA 2011-08-30 14:46:15 EDT
Created attachment 202451 [details]
EditorRegistry patch v1

Ed, if I understand your request correctly, I think this is what you want?
Comment 3 Ed Merks CLA 2011-08-30 15:02:32 EDT
Yes, that would be much better!!
Comment 4 Remy Suen CLA 2011-08-30 15:04:54 EDT
(In reply to comment #3)
> Yes, that would be much better!!

Thanks. I'll try to get this.
Comment 5 Ed Merks CLA 2011-10-27 13:07:41 EDT
*** Bug 349552 has been marked as a duplicate of this bug. ***
Comment 6 Remy Suen CLA 2011-11-02 11:51:22 EDT
(In reply to comment #2)
> Created attachment 202451 [details]
> EditorRegistry patch v1

This first test introduced test failures. I rewrote the code to minimize introducing casualties and regressions. Thanks for the bug report, Ed!

I've released the fix to master and R3_development. I also screwed up in my commit so I had to do a second commit to fix the problem.

http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=2d5698e57a0c5913b5c4292806d23fd1d5569e1f
http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=a78e46c87f7145ecc3a8e61bd7cbab7a601db039

http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?h=R3_development&id=b6996e7115c163052c3ee14f3a35b6c5766baa38
http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?h=R3_development&id=e495d4c520e380d5c2626041cfd1f259f70565ba