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

Bug 97946

Summary: [EditorMgmt] old getDefaultEditor API is not backwards compatible (in spirit)
Product: [Eclipse Project] Platform Reporter: Billy Biggs <billy.biggs>
Component: UIAssignee: Kim Horne <eclipse>
Status: VERIFIED FIXED QA Contact:
Severity: critical    
Priority: P3 CC: eclipse, Michael.Valenta, michaelvanmeekeren
Version: 3.1   
Target Milestone: 3.1 RC2   
Hardware: PC   
OS: Linux-GTK   
Whiteboard:
Attachments:
Description Flags
Patch against org.eclipse.ui.workbench
none
Patch against org.eclipse.ui.tests none

Description Billy Biggs CLA 2005-06-01 14:33:49 EDT
3.1RC1, Linux-GTK

Whenever I use "Team > Show Annotation", the editor it opens has no syntax
colouring for my Java code.   I always thought this was just "the way it is",
but I recently discovered that on Windows XP, I get the syntax colouring.

What is going on?
Comment 1 Michael Valenta CLA 2005-06-01 14:58:54 EDT
This is indeed very odd. I see the same problem on GTK. Also, I can get 
highlighting in my XP development environment but not in my runtime which 
makes it hard to figure out why it works on windows and not on GTK. I will 
continue to investigate.
Comment 2 Michael Valenta CLA 2005-06-01 15:16:04 EDT
I have found the problem (or at least a workaround which shoiuld point to the 
problem). The *.java entry is missing from the General/Editors/File 
Associations page. If you manually add it and make the Java editor the 
default, it will work. In my old workspace it was there but in newer 
workspaces, it is not. Rafael tells me that the UI should find the right 
editor even without the file association so I'm moving this to UI and marking 
as critical as it is a regression from the 3.0 behavior.
Comment 3 Kim Horne CLA 2005-06-01 15:36:10 EDT
How are you looking for the editor?
Comment 4 Michael Valenta CLA 2005-06-01 15:42:34 EDT
It's in the OpenRemotgeFileAction of the CVS UI plugin. Bascially, we call 
IEditorRegistry#getDefaultEditor(String filename).
Comment 5 Kim Horne CLA 2005-06-01 15:51:29 EDT
In order for this to work you'll need to start using getDefaultEditor(filename, content type) - the new 
editor bindings can only be resolved when the content type is known.  You'll need to pass the contents of 
the file to IContentTypeManager.findContentTypeFor(inputstream, filename) to determine this.
Comment 6 Rafael Chaves CLA 2005-06-01 16:07:11 EDT
I assumed getDefaultEditor(filename) would do a
IContentTypeManager#findContentTypeFor(filename) for free if one could not be
found. Couldn't that be done? That allow old clients to work together with new
editors.
Comment 7 Kim Horne CLA 2005-06-01 16:33:12 EDT
After a powwow with Michael V, MvM and Nick we've decided that's what we'll do.  We'll ask the content 
manager to "best guess" based on the filename and an empty input stream and use that in the old API to 
get the default editor.
Comment 8 Michael Valenta CLA 2005-06-01 16:37:00 EDT
I have logged bug 97990 for comment 5. I'm not sure if I want to put this in 
3.1 though.
Comment 9 Rafael Chaves CLA 2005-06-01 17:33:40 EDT
Re: comment 7. Kim, you don't need to provide an empty stream. There is API that
will take the file name only.

Also, just to make sure, you will do that only if there is no legacy editor
associated to that file name, correct?
Comment 10 Kim Horne CLA 2005-06-02 08:06:57 EDT
Rafael: no, I would do this in the event people were using the old (non-content type qualified) API.  If there 
were any legacy editors associated with the file they'd take priority anyway so it wouldn't be an issue.
Comment 11 Kim Horne CLA 2005-06-02 08:28:03 EDT
Created attachment 22220 [details]
Patch against org.eclipse.ui.workbench

Patch to address the issue
Comment 12 Kim Horne CLA 2005-06-02 09:22:59 EDT
Created attachment 22222 [details]
Patch against org.eclipse.ui.tests

Updated testcases to confirm behaviour.
Comment 13 Kim Horne CLA 2005-06-02 17:31:55 EDT
Patches applied.
Comment 14 Kim Horne CLA 2005-06-10 08:55:43 EDT
Verified in I20050610-0010