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

Bug 328091

Summary: [e4] clicking on activation button in task list activates wrong task
Product: z_Archived Reporter: Steffen Pingel <steffen.pingel>
Component: MylynAssignee: Steffen Pingel <steffen.pingel>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: emoffatt, pwebster, remy.suen
Version: unspecified   
Target Milestone: 3.5   
Hardware: PC   
OS: Linux   
Whiteboard:
Bug Depends on: 328165    
Bug Blocks: 321278, 336432    
Attachments:
Description Flags
fix none

Description Steffen Pingel CLA 2010-10-19 00:04:13 EDT
Steps:
1. Select task
2. Click in task list to activate a different task

The selected task activated but not the clicked task as expected.
Comment 1 Steffen Pingel CLA 2010-10-19 00:26:16 EDT
This the code that programmatically invokes the command. Object is set to the task to be activated:

 EvaluationContext context = new EvaluationContext(service.getCurrentState(), object);
 context.addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, new StructuredSelection(object));
 service.executeCommandInContext(new ParameterizedCommand(command, null), event, context);

In the command handler the following code is invoked which gets the old selection of the task list which has the wrong task:

 selection = HandlerUtil.getCurrentSelection(event)
 
It seems that  LegacyHandlerService.executeCommandInContext() simply ignores the context since it does not extend  LegacyEvalContext.

Is there already an e4 bug for this?
Comment 2 Remy Suen CLA 2010-10-19 06:21:29 EDT
(In reply to comment #1)
> Is there already an e4 bug for this?

No, there isn't. Although Paul has changed some of those services recently so this might no longer be a problem. Please open one anyway.
Comment 3 Remy Suen CLA 2010-10-19 08:43:17 EDT
(In reply to comment #2)
> Although Paul has changed some of those services recently so
> this might no longer be a problem.

Actually, looking at the code now, I don't think this is going to make a difference. You can try...

IEvaluationContext context = context.createContextSnapshot(true);
context.addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, new
    StructuredSelection(object));
service.executeCommandInContext(new ParameterizedCommand(command, null),
    event, context);
Comment 4 Remy Suen CLA 2010-10-19 08:58:39 EDT
(In reply to comment #3)
> Actually, looking at the code now, I don't think this is going to make a
> difference. You can try...

Actually, no, this code is bad too. What do you exactly mean by "The selected task activated but not the clicked task as expected." anyway? The selection is not what you have clicked on?
Comment 5 Steffen Pingel CLA 2010-10-19 13:46:46 EDT
Created attachment 181209 [details]
fix
Comment 6 Remy Suen CLA 2010-10-19 13:51:47 EDT
(In reply to comment #5)
> Created an attachment (id=181209) [details]
> fix

That actually works? I am baffled. :o
Comment 7 Steffen Pingel CLA 2010-10-19 14:11:08 EDT
(In reply to comment #4)
> (In reply to comment #3)
> > Actually, looking at the code now, I don't think this is going to make a
> > difference. You can try...
> 
> Actually, no, this code is bad too. What do you exactly mean by "The selected
> task activated but not the clicked task as expected." anyway? The selection is
> not what you have clicked on?

The selection that is set in the evaluation context is not what ends up in the command handler. 

Your suggestion worked perfectly. That way the created evaluation context actually extends the expected legacy class. Thanks!