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

Bug 465271

Summary: Icon enhancement in the application model editor
Product: [Eclipse Project] Platform Reporter: Olivier Prouvost <olivier.prouvost>
Component: UIAssignee: Olivier Prouvost <olivier.prouvost>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, dirk.fauth, Lars.Vogel, olivier.prouvost, simon.scholz, yxiaobo
Version: 4.5Flags: daniel_megert: pmc_approved+
Target Milestone: 4.5.1   
Hardware: PC   
OS: Mac OS X   
See Also: https://git.eclipse.org/r/46354
https://git.eclipse.org/c/platform/eclipse.platform.ui.tools.git/commit/?id=0772fbb9bd0838f083e04a095bf3362136dd5278
https://git.eclipse.org/r/53919
https://git.eclipse.org/c/platform/eclipse.platform.ui.tools.git/commit/?id=e59968c4739b901833550e1f4fe71b33b64fa29f
Whiteboard:
Bug Depends on:    
Bug Blocks: 475203    
Attachments:
Description Flags
Icons in the editor none

Description Olivier Prouvost CLA 2015-04-23 04:55:04 EDT
With the bug #403583 images are displayed in the application model editor when a Icon URI is set (platform:/plugin/....../icons/myIcon.png).

The icon is not displayed if the image is in the workspace and not still in the target platform. We should search for it with the platform:/resource/..../icons/myIcon.png if it has not been found.  This is quite easy to fix. 

But more generally the algorithm to get Image in model editor should be enhanced  :


The previous behavior was to get an image depending on the object type and on the 'isRendered' boolean value. It means that 2 images where defined for each object.

The new algorithm I proposed is the following : 

1. search for Icon URI image if it is set (in target or in workspace)
2. or if no image found take the default one corresponding to the type of object
3. compute a 'grey' image from the image found at step 1 or 2. 

This new approach would simplify the getImage code in all the org.eclipse.e4.tools.emf.ui.internal.common.component.*Editor classes and could be defined once in the AbstractComponentEditor.  The 'toBeRendered' could be check also once to compute the 'grey' image from the default one. 

Another point it would optimize the image management which seems to create a new Image for each call using an internal ResourcePool instead of ImageRegistry.
Comment 1 Eclipse Genie CLA 2015-04-23 11:35:22 EDT
New Gerrit change created: https://git.eclipse.org/r/46354

WARNING: this patchset contains 1279 new lines of code and may require a Contribution Questionnaire (CQ) if the author is not a committer on the project. Please see:https://wiki.eclipse.org/Project_Management_Infrastructure/Creating_A_Contribution_Questionnaire
Comment 2 Lars Vogel CLA 2015-05-07 19:11:18 EDT
I get frequently crashes with this change and 4.5.0.I20150506-2000. This might not the due to this change, but to some PDE issues which should be solved with 4.5.0.I20150507-2000. I try it again tomorrow or next week.
Comment 3 Lars Vogel CLA 2015-05-07 19:12:56 EDT
Can you also attach a screenshot how it should look like? The icons for the parts do for example not show the select icon in the tree. From a email you send me, I expected that.
Comment 4 Lars Vogel CLA 2015-05-08 03:08:54 EDT
Created attachment 253325 [details]
Icons in the editor

Even with this change, the icons are not displayed correct, see screenshot. The example is based on the Eclipse 4 template and the window has an icon assigned, via platform:/plugin/test/icons/sample.png
Comment 5 Olivier Prouvost CLA 2015-05-11 06:41:09 EDT
This bug has been fixed with a the review https://git.eclipse.org/r/#/c/46354/ which has not been merged.. 

I will recheck it again but it should not be a big issue...
Comment 6 Lars Vogel CLA 2015-05-11 09:39:15 EDT
Thanks Olivier, works fine with 4.5.0.I20150510-2000. The errors I was seeing were most likely related to the icon replacement work in PDE. THanks.
Comment 7 Lars Vogel CLA 2015-05-26 10:39:15 EDT
Looks I like forgot to merge this one, sorry Olivier. We need another committer reviewer for RC3, I asked Simon.
Comment 8 Olivier Prouvost CLA 2015-05-26 10:41:02 EDT
Yes :)  No problem... there are so many bugs to follow :) !
Comment 9 Lars Vogel CLA 2015-05-27 05:23:53 EDT
Forgot to merge the change.
Comment 10 Lars Vogel CLA 2015-05-28 06:58:35 EDT
How critical is this change for Mars? I fear that we are introducing new bugs in the editor with this change?
Comment 11 Olivier Prouvost CLA 2015-05-28 08:03:05 EDT
The part descriptors are displayed with their icons. Views, windows too...
The gray icon is computed depending on the dynamic icon you set...
Your fear comes from the number of lines changed due to a code reformat... 
Open the model spy on your current IDE and compare with the previous version... and make your opinion...
Comment 12 Lars Vogel CLA 2015-05-28 08:26:07 EDT
(In reply to Olivier Prouvost from comment #11)
> The part descriptors are displayed with their icons. Views, windows too...
> The gray icon is computed depending on the dynamic icon you set...
> Your fear comes from the number of lines changed due to a code reformat... 
> Open the model spy on your current IDE and compare with the previous
> version... and make your opinion...

The fear also comes from Dirks testing of the last patch and the reported exceptions by him. ;-) I test this again and let you know.
Comment 13 Olivier Prouvost CLA 2015-05-28 08:33:46 EDT
Yes I understand ! As it has not been merged early it could not be tested a lot... But we have still RC3 and RC4 if there is any problem.

The refresh in the tree (if you change the Icon URI in the editor) must be done manually by double clicking on visible checkbox or by changing the label for instance ... I could not find it for the moment... This is a data binding EMF issue on this particular field...
Comment 14 Olivier Prouvost CLA 2015-06-02 11:13:59 EDT
Really in 4.6 ??
Comment 15 Dani Megert CLA 2015-06-02 11:17:57 EDT
(In reply to Olivier Prouvost from comment #14)
> Really in 4.6 ??

It's too late for Mars. If this is important and proves to work in Neon, we can still consider 4.5.1.
Comment 16 Lars Vogel CLA 2015-06-02 11:21:58 EDT
(In reply to Dani Megert from comment #15)
> It's too late for Mars. If this is important and proves to work in Neon, we
> can still consider 4.5.1.

Lets try 4.5.1. This requires that this is merged in master for Neon and if it works fine, we can cherry pick it onto the maintenance branch.
Comment 17 Olivier Prouvost CLA 2015-06-02 11:50:48 EDT
Ok. I will retest it for 4.5.1. That would be great to have if for this release...

Must check for instance this kind of url : 

platform:/plugin/org.eclipse.ui.ide.application/$nl$/icons/full/eview16/resource_persp.png
Comment 19 Lars Vogel CLA 2015-07-15 05:15:11 EDT
Dani, once this has been intensively tested (I will use this change in my next RCP training in two weeks), it would be great to downport it to 4.5.1. 

I forgot the process for this, can you shared you link to the process description? https://www.eclipse.org/eclipse/development/plans/freeze_plan_4_5.php seem not to cover it.
Comment 20 Dani Megert CLA 2015-07-15 08:49:44 EDT
(In reply to Lars Vogel from comment #19)
> Dani, once this has been intensively tested (I will use this change in my
> next RCP training in two weeks), it would be great to downport it to 4.5.1. 

To approve I need someone stating here that the patch does not change or remove any API and list all API additions (if any).

 
> I forgot the process for this, can you shared you link to the process
> description?
> https://www.eclipse.org/eclipse/development/plans/freeze_plan_4_5.php seem
> not to cover it.

We have similar freeze plans for the maintenance releases. It's on my list to post it. Stay tuned!
Comment 21 Olivier Prouvost CLA 2015-07-15 09:13:58 EDT
Additionnel API, only in AbstractComponentEditor : 

* public Image getImageFromIconURI(MUILabel element)
  returns the Image if there is an IconURI value. It deals with platform:/plugin, platform:/resource and platform:/.../ $nls$

* public Image getImage(Object element, String key)
 returns the Image for an element with a default key if there is no IconURI. Compute the grey icon too.

* public Image getImage(Object element)
   abstract must be implemented in subclasses with a call to getImage(element, key)

* private ImageDescriptor getImageDescriptorFromUri(String uri)
  computes the ImageDescriptor from a string URI

* private Image getImage(String key, boolean grey)
  returns the Image for a key (when no IconURI) and compute the grey variation.

* private boolean shouldBeGrey(Object element)
  returns true if this element should display a grey image (not rendered...)

I guess it is all.
Comment 22 Lars Vogel CLA 2015-07-15 13:57:03 EDT
(In reply to Olivier Prouvost from comment #21)
> Additionnel API, only in AbstractComponentEditor : 

AFACS org.eclipse.e4.tools exports no API, everything is marked as x-internal
Comment 23 Lars Vogel CLA 2015-07-15 13:57:44 EDT
(In reply to Dani Megert from comment #20)
> To approve I need someone stating here that the patch does not change or
> remove any API and list all API additions (if any).

All is still x-internal in org.eclipse.e4.tools
Comment 24 Eclipse Genie CLA 2015-08-17 17:49:11 EDT
New Gerrit change created: https://git.eclipse.org/r/53919
Comment 26 Lars Vogel CLA 2015-08-18 02:56:57 EDT
(In reply to Eclipse Genie from comment #25)
> Gerrit change https://git.eclipse.org/r/53919 was merged to
> [R4_5_maintenance].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.ui.tools.git/commit/
> ?id=e59968c4739b901833550e1f4fe71b33b64fa29f

Update the MANIFEST and pom version with Gerrit change https://git.eclipse.org/r/53920 was merged to [R4_5_maintenance].
Commit: http://git.eclipse.org/c/platform/eclipse.platform.ui.tools.git/commit/?id=a2c8702e9dc7ea82f908b10afce58a9f6d00dd9e
Comment 27 Olivier Prouvost CLA 2018-02-21 11:08:20 EST
*** Bug 466540 has been marked as a duplicate of this bug. ***