Bug 549665 - [generic editor] Package Explorer should support content-type specific icons for generic editor
Summary: [generic editor] Package Explorer should support content-type specific icons ...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.13   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 4.13 M3   Edit
Assignee: Lakshminarayana CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-30 11:31 EDT by Lakshminarayana CLA
Modified: 2019-08-07 02:12 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lakshminarayana CLA 2019-07-30 11:31:24 EDT
After fixing the Bug 513034, Using the "org.eclipse.ui.genericeditor.icons" extension point the generic editor will support content specific icons on editor tabs.

But, files on "Package Explorer" still shows the default icon. It should show the contributed icons based on content types.
Comment 1 Mickael Istria CLA 2019-07-30 11:43:45 EDT
Note that the Package Explorer is a JDT only view, so we should focus on Project Explorer which is generic.
I think what you basically want is more a way to associate an icon with a content-type in general more than a way to associate an icon for the generic editor. From there, it would be possible to tweak the default content provider so that it reuses the content type icon instead of the associated editor icon in some cases. Since the Project Explorer is not aware of the Generic Editor, there is no easy way to reuse the generic editor extension in Project Explorer to build the icon.
What seems requires is a way for an editor description to provide a getEditorIcon(IEditorInput) method (or a Function<IEditorInput, ImageDescriptor>) to dynamically resolve the icon. Such generic method should be defined in the editor APO, used inside the editor itself and could be used by the Project Explorer.
Comment 2 Eclipse Genie CLA 2019-08-02 12:20:16 EDT
New Gerrit change created: https://git.eclipse.org/r/146904
Comment 3 Lakshminarayana CLA 2019-08-02 12:27:09 EDT
(In reply to Eclipse Genie from comment #2)
> New Gerrit change created: https://git.eclipse.org/r/146904

Mickael, Can you check this patch?

These are the SS 
https://gyazo.com/9b96430051ea9386ba8e82c74efcb37c
Comment 4 Pierre-Yves Bigourdan CLA 2019-08-02 17:51:44 EDT
(In reply to Lakshminarayana from comment #3)
> (In reply to Eclipse Genie from comment #2)
> > New Gerrit change created: https://git.eclipse.org/r/146904
> 
> Mickael, Can you check this patch?
> 
> These are the SS 
> https://gyazo.com/9b96430051ea9386ba8e82c74efcb37c

Screenshots look promising, good job!
Comment 5 Mickael Istria CLA 2019-08-03 05:08:43 EDT
Wow, great "hack", I never would have thought of leveraging the override for that! I'll have a more focused review on Monday but both screenshots and patch seem really cool.
Comment 7 Mickael Istria CLA 2019-08-05 05:14:35 EDT
Thanks a lot Lakshminarayana, that's a very good patch!
Comment 8 Lakshminarayana CLA 2019-08-05 19:42:04 EDT
Thanks :)
Comment 9 Andrey Loskutov CLA 2019-08-06 02:34:50 EDT
This caused test fails on all platforms, see https://download.eclipse.org/eclipse/downloads/drops4/I20190805-1800/testresults/html/org.eclipse.ui.tests_ep413I-unit-cen64-gtk3-java11_linux.gtk.x86_64_11.html

java.lang.NullPointerException
at org.eclipse.ui.internal.genericeditor.GenericEditorAssociationOverride.overrideEditors(GenericEditorAssociationOverride.java:31)
at org.eclipse.ui.ide.IDE.overrideEditorAssociations(IDE.java:927)
at org.eclipse.ui.tests.ide.api.IDETest.testOverrideEditorAssociations(IDETest.java:42)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

Please also if you fix this, do following in addition:

- add javadocs to GenericEditorDescriptor / GenericEditorAssociationOverride describing its purpose
- search/replace defaultDescripter -> defaultDescriptor
- extract "org.eclipse.ui.genericeditor.GenericEditor" to a constant somewhere in the bundle (I see it is already used in generic editor code as plain String)
Comment 10 Mickael Istria CLA 2019-08-06 03:52:00 EDT
Strange that the failure were not captured by Gerrit build...
I'll investigate all that and appky the suggested imprvements later today.
Comment 11 Eclipse Genie CLA 2019-08-06 04:53:39 EDT
New Gerrit change created: https://git.eclipse.org/r/147092
Comment 13 Mickael Istria CLA 2019-08-06 12:57:14 EDT
Patch was merged to fix the issue. Let's keep the ticket open and look at test results tomorrow before marking it as fixed.
Comment 14 Mickael Istria CLA 2019-08-07 02:12:50 EDT
Thanks all. Test is now green.