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

Bug 429327

Summary: Image/Icon information returned by EditorReference implementation is inconsistent with the IEditorPart implementation
Product: [Eclipse Project] Platform Reporter: Paul Webster <pwebster>
Component: UIAssignee: Paul Webster <pwebster>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: alokmanjrekar, daniel.rolka, daniel_megert, martin.axelsson, pwebster, sudol.wojciech
Version: 4.2.2   
Target Milestone: 4.2.2+   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Bug Depends on: 409332    
Bug Blocks:    

Description Paul Webster CLA 2014-02-28 11:00:51 EST
backport to 4.2.2+

+++ This bug was initially created as a clone of Bug #409332 +++

Image/Icon information returned by EditorReference implementation is inconsistent with the IEditorPart implementation.

Please see the detailed explanation at the following link
http://www.eclipse.org/forums/index.php/t/487787/

It seems that the EditorReference implementation is returning the Image information for the editor using the "Icon" attribute in the org.eclipse.ui.editor extension of an editor.
But the Image that is displayed for the editor in the workbench area does not reply on this and instead relies on the getTitleImage() implementation of IEditorPart.

Anyone who relies on the EditorReference of the editor to get the image could potentially get a different image than the one displayed for the editor in the workbench area. One such consumer is the CTRL + F6 (or next editor dialog).

I verified this by looking at the code of the handler class "CycleEditorHandler" which is invoked on "CTRL + F6". 
The method that adds the items in the dialog is as follows.

I have highlighted the code that sets the image for the editor in the dialog.

protected void addItems(Table table, WorkbenchPage page) {
List<EditorReference> refs = page.getSortedEditorReferences();
for (EditorReference ref : refs) {
TableItem item = null;
item = new TableItem(table, SWT.NONE);
if (ref.isDirty()) {
item.setText("*" + ref.getTitle()); //$NON-NLS-1$
} else {
item.setText(ref.getTitle());
}
item.setImage(ref.getTitleImage());
item.setData(ref);
}
}
Comment 1 Paul Webster CLA 2014-02-28 11:04:55 EST
Looking at https://git.eclipse.org/r/#/c/19072/

PW
Comment 3 Dani Megert CLA 2014-12-15 10:45:29 EST
Ctrl+Shift+E is fine but Ctrl+E is still not fixed.

1. create a Java project
2. create a new file A.java in the project root folder
==> file opens. The icon in the editor tab and the 'Package Explorer' is a blue J with white inside the J. This differs from the normal Java editor icon which is a J with blue inside the J.
3. Ctrl+E ==> wrong icon is shown.
Comment 4 Dani Megert CLA 2014-12-17 04:03:57 EST
(In reply to Dani Megert from comment #3)
> Ctrl+Shift+E is fine but Ctrl+E is still not fixed.
> 
> 1. create a Java project
> 2. create a new file A.java in the project root folder
> ==> file opens. The icon in the editor tab and the 'Package Explorer' is a
> blue J with white inside the J. This differs from the normal Java editor
> icon which is a J with blue inside the J.
> 3. Ctrl+E ==> wrong icon is shown.

This is captured with bug 418908.