Bug 476045 - Commands visible in Quick Access don't show commandImage
Summary: Commands visible in Quick Access don't show commandImage
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.5   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.6.1   Edit
Assignee: Patrik Suzzi CLA
QA Contact:
URL:
Whiteboard:
Keywords: noteworthy
Depends on:
Blocks:
 
Reported: 2015-08-27 09:26 EDT by Mickael Istria CLA
Modified: 2016-08-25 16:12 EDT (History)
4 users (show)

See Also:
Lars.Vogel: pmc_approved+
bsd: review+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mickael Istria CLA 2015-08-27 09:26:23 EDT
While working on 476037, I noticed that despite the command icons show up as expected in the Shortcuts preference page, they don't appear in the quick access search.
It seems to be the same blue ball for all commands. It seems like the part which populates quick access with commands simply doesn't try to load the images associated with commands.
Comment 1 Patrik Suzzi CLA 2016-08-16 07:56:05 EDT
The issue is in CommmandElement#getImageDescriptor(), which returns null.
Comment 2 Eclipse Genie CLA 2016-08-16 08:25:19 EDT
New Gerrit change created: https://git.eclipse.org/r/79115
Comment 3 Patrik Suzzi CLA 2016-08-16 08:27:09 EDT
With the provided code, the Quick access commands are now using the associated command image. 

see: http://i.imgur.com/kPkD5UX.png
Comment 4 Mickael Istria CLA 2016-08-16 08:59:00 EDT
I believe it would be a nice candidate for 4.6.2.
Comment 6 Mickael Istria CLA 2016-08-16 09:56:29 EDT
Targettinf for 4.6.1. However, for 4.6.1, the change should include Brian's suggestion about retrieving the commandservice in a more reliable way.
Comment 7 Patrik Suzzi CLA 2016-08-16 11:51:52 EDT
As suggested, I'm going to add a method CommandProvider#getCommandImageService(), like happen for the other methods. 

private ICommandImageService commandImageService;

ICommandImageService getCommandImageService() {
	if (commandImageService == null) {
		if (currentSnapshot instanceof ExpressionContext) {
			IEclipseContext ctx = ((ExpressionContext) currentSnapshot).eclipseContext;
			commandImageService = ctx.get(CommandImageService.class);
		} else {
			commandImageService = PlatformUI.getWorkbench().getService(CommandImageService.class);
		}
	}
	return commandImageService;
}

The problem now, is I always get null when calling getService(CommandImageService .class), despite I'm getting a service instance like for the other services. 

So, I get a non null service only when calling PlatformUI.getWorkbench().getService(CommandImageService.class);

This is because the context is a child context, related to the current selection for the quickaccess. 

Can you give me an hint how to get the parent context, so I can get a non null instance of CommandImageService ?


The only point against, is that the method, as written below, doesn't work. It works only If you return straight PlatformUI.getWorkbench().getService(CommandImageService.class);
Comment 8 Patrik Suzzi CLA 2016-08-16 11:55:25 EDT
correction / clarification: with the below code: 

if (currentSnapshot instanceof ExpressionContext) {
  // (#1) get the context - but service always null
  IEclipseContext ctx = ((ExpressionContext) currentSnapshot).eclipseContext;
  commandImageService = ctx.get(CommandImageService.class);
} else {
  // (#2) the static way - but service has value
  commandImageService = PlatformUI.getWorkbench().getService(CommandImageService.class);
}

In (#1), I use the child context, but the service is always null. 
How to get the parent context, so the ctx.get(CommandImageService.class) has value?
Comment 9 Eclipse Genie CLA 2016-08-16 11:56:30 EDT
New Gerrit change created: https://git.eclipse.org/r/79144
Comment 10 Patrik Suzzi CLA 2016-08-16 11:59:19 EDT
In the latest Gerrit change you can see the issue. 

I was tempted to write the following: 

if (currentSnapshot instanceof ExpressionContext) {
  // (#1) get the context - but service always null
  IEclipseContext ctx = ((ExpressionContext) currentSnapshot).eclipseContext;
  commandImageService = ctx.get(CommandImageService.class);
} 
if(commandImageService==null){
  // at first null it simply uses the static way
  commandImageService = PlatformUI.getWorkbench().getService(CommandImageService.class);
}

But again, this would be a workaround, instead of a complete solution
Comment 11 Patrik Suzzi CLA 2016-08-17 12:33:55 EDT
With the latest change, I removed the call to PlatformUI.getWorkbench(), in favor of passing an IEclipseContext to the constructor of CommandProvider. 

--> the CommandProvider is the only responsible to provide the service

Hope you don't mind reviewing this change.
Comment 12 Patrik Suzzi CLA 2016-08-17 15:56:13 EDT
I'm also going to add a N&N Entry for this.
Comment 13 Eclipse Genie CLA 2016-08-17 16:30:07 EDT
New Gerrit change created: https://git.eclipse.org/r/79229
Comment 15 Mickael Istria CLA 2016-08-18 03:40:24 EDT
Do you think it's going to fit in 4.6.1 or should we move it to 4.6.2 ?
Comment 16 Patrik Suzzi CLA 2016-08-18 03:50:25 EDT
Thanks, Set to 4.7 M2
Comment 17 Mickael Istria CLA 2016-08-18 03:54:21 EDT
(In reply to Patrik Suzzi from comment #16)
> Thanks, Set to 4.7 M2

Why not 4.6.1 or 4.6.2? The change seems purely internal and not risky.
Comment 18 Patrik Suzzi CLA 2016-08-18 05:31:43 EDT
Ok, I will set 4.6.1 again, and send an e-mail to eclipse-pmc to request the backport. 

Please, note: to get this fix into 4.6.x, we should backport two changes:
- https://git.eclipse.org/r/#/c/79115/ : simple fix to provide images
- https://git.eclipse.org/r/#/c/79144/ : fix also the CommandProvider

Looking at #1, to backport to 4_6_maintenance in RC1, we need
 +1 from a PMC
 +1 from another committer, other than me

[#1] https://www.eclipse.org/eclipse/development/plans/freeze_plan_4_6_1.php
Comment 19 Mickael Istria CLA 2016-08-18 05:35:39 EDT
(In reply to Patrik Suzzi from comment #18)
> Please, note: to get this fix into 4.6.x, we should backport two changes:
> - https://git.eclipse.org/r/#/c/79115/ : simple fix to provide images
> - https://git.eclipse.org/r/#/c/79144/ : fix also the CommandProvider

I believe you can merge those into a single commit and put only one on Gerrit.
Comment 20 Patrik Suzzi CLA 2016-08-18 05:37:58 EDT
Yes, thanks, I'll mention this in the e-mail
Comment 21 Eclipse Genie CLA 2016-08-18 17:53:43 EDT
New Gerrit change created: https://git.eclipse.org/r/79305
Comment 22 Eclipse Genie CLA 2016-08-18 17:53:45 EDT
New Gerrit change created: https://git.eclipse.org/r/79304
Comment 23 Patrik Suzzi CLA 2016-08-18 17:58:18 EDT
Sorry, didn't squash the two cherry picks. I'm going to abandon the two above changes and submit a new one for R4_6_maintenance
Comment 24 Eclipse Genie CLA 2016-08-18 18:01:59 EDT
New Gerrit change created: https://git.eclipse.org/r/79307
Comment 25 Patrik Suzzi CLA 2016-08-18 18:07:03 EDT
The last change submitted brings command icons in Neon's quickaccess. I already tested the change on Eclipse Neon on R4_6_maintenance stream, and it works as expected. 

Note: The combined change contains the code from Change 79115 + Change 79144.

Asking Mickael to approval as another committer, other than me.
Comment 26 Patrik Suzzi CLA 2016-08-19 10:15:34 EDT
Brian, hope you don't mind reviewing this for backport
Comment 28 Patrik Suzzi CLA 2016-08-19 10:20:58 EDT
The last commit was N&N for Oxygen M2.
Comment 29 Patrik Suzzi CLA 2016-08-19 15:40:55 EDT
As discussed with Brian, for consistency reasons, I'm going to change the current state of the master. After that, I will push another change to the 4_6_maintenance. 

Details: The code will use PlatformUI.getWorkbench() only when needed, consistently w.r.t. getters for other services provided by CommandProvider.
Comment 30 Eclipse Genie CLA 2016-08-19 15:41:54 EDT
New Gerrit change created: https://git.eclipse.org/r/79377
Comment 31 Patrik Suzzi CLA 2016-08-19 17:22:16 EDT
Now both the changes have the same, consistent change: 

master: https://git.eclipse.org/r/#/c/79377/
r4_6_maintenance: https://git.eclipse.org/r/#/c/79307/
Comment 33 Patrik Suzzi CLA 2016-08-22 02:49:13 EDT
The new, consistent change is in master now.
Comment 35 Patrik Suzzi CLA 2016-08-22 02:53:12 EDT
The same, consistent change, is also in R4_6_maintenance (Neon)

Thanks everyone for helping with this!
Comment 36 Lars Vogel CLA 2016-08-22 03:08:58 EDT
Brian, please set the +1 here in the bug report.
Comment 37 Brian de Alwis CLA 2016-08-25 16:12:27 EDT
Verified in 4.6.1 RC2