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

Bug 328165

Summary: Custom evaluation contexts are not passed to command handler
Product: [Eclipse Project] e4 Reporter: Steffen Pingel <steffen.pingel>
Component: UIAssignee: Paul Webster <pwebster>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: remy.suen
Version: 1.0   
Target Milestone: 4.1 RC4   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 328091    

Description Steffen Pingel CLA 2010-10-19 13:43:47 EDT
Mylyn has the following code that programmatically invokes a command:

 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 to retrieve the current selection:

 selection = HandlerUtil.getCurrentSelection(event)

This selection is different from the selection that was set on the context using addVariable(). It seems that LegacyHandlerService.executeCommandInContext() ignores the context since it does not extend LegacyEvalContext.

Eclipse SDK 4.1M2: I20100922-0843
Comment 1 Steffen Pingel CLA 2010-10-19 14:13:53 EDT
For Mylyn we fixed it by using IHandlerService.createContextSnapshot(false) instead of constructing an EvaulationContext directly.
Comment 2 Remy Suen CLA 2011-06-20 16:17:22 EDT
Paul, I think we fixed this with bug 333506? Though I suppose there's also bug 349721 to consider.
Comment 3 Paul Webster CLA 2011-06-21 12:27:49 EDT
Fixed by bug 333506

PW