This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 409332 - Image/Icon information returned by EditorReference implementation is inconsistent with the IEditorPart implementation
Summary: Image/Icon information returned by EditorReference implementation is inconsis...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.2.2   Edit
Hardware: PC Windows 7
: P3 normal with 1 vote (vote)
Target Milestone: 4.4 M3   Edit
Assignee: Wojciech Sudol CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 421946 (view as bug list)
Depends on:
Blocks: 429327
  Show dependency tree
 
Reported: 2013-05-28 15:06 EDT by ALOK MANJREKAR CLA
Modified: 2014-12-15 10:59 EST (History)
5 users (show)

See Also:


Attachments
Screenshot to show the difference between the icon displayed in the editor part versus the icon retrieved via the IEditorReference implementation (96.15 KB, image/png)
2013-05-28 15:06 EDT, ALOK MANJREKAR CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description ALOK MANJREKAR CLA 2013-05-28 15:06:13 EDT
Created attachment 231654 [details]
Screenshot to show the difference between the icon displayed in the editor part versus the icon retrieved via the IEditorReference implementation

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 Wojciech Sudol CLA 2013-09-18 05:24:12 EDT
Could you attach an example plug-in that shows the bug?
Comment 2 Paul Webster CLA 2013-09-18 08:47:17 EDT

*** This bug has been marked as a duplicate of bug 207443 ***
Comment 3 Paul Webster CLA 2013-09-18 08:50:08 EDT
Sorry, this is not quite the same.  In 3.x the EditorReference would use the part title image if the part was instantiated, or the plugin.xml one if it was not.  We only use the plugin.xml one, should check the part image if the part has been instantiated.

PW
Comment 4 Wojciech Sudol CLA 2013-09-24 07:11:07 EDT
Review URL: https://git.eclipse.org/r/#/c/16719/
Comment 6 Wojciech Sudol CLA 2013-10-29 10:38:43 EDT
Verified in I20131028-2000.
Comment 7 Dani Megert CLA 2013-11-18 07:19:51 EST
*** Bug 421946 has been marked as a duplicate of this bug. ***
Comment 8 Dani Megert CLA 2014-12-15 10:45:39 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 9 Wojciech Sudol CLA 2014-12-15 10:56:47 EST
(In reply to Dani Megert from comment #8)
> Ctrl+Shift+E is fine but Ctrl+E is still not fixed.

It is already reported - bug 418908. It is a different part of code.