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

Bug 327742

Summary: HandledMenuItem command parameter names and ids in fragment.e4xmi must be identical to Command´s id, due to incorrect choice of map keys in HandledMenuItemRenderer.generateParameterizedCommand().
Product: [Eclipse Project] e4 Reporter: Karin <karin.fetzer>
Component: UIAssignee: Project Inbox <e4.ui-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: karin.fetzer, Lars.Vogel
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Karin CLA 2010-10-14 04:57:46 EDT
Build Identifier: I20100727-1520

On line 172 in org.eclipse.e4.ui.workbench.renderers.swt.HandledMenuItemRenderer.java a command is being created (calling createCommand(...) on a ECommandService). 

The command parameters are given as input to the createCommand-method, and they are given as a Map with the parameter _names_ as the key (and the parameter values as values). 

As a result line 313 in ParameterizedCommand.java is executed (deeper in the call stack) at which point the getParameter-method is called on the command, and the key (that is the _name_ of the parameter) is being passed as an argument to it. 

On line 740 in Command.java however, the parameters are compared by id, and not name…, and unless the parameter name and the parameter id are equal, the parameter will not be found.

This forces the use of identical names and ids on the parameters in the fragment.e4xmi.


Reproducible: Always

Steps to Reproduce:
1. Create a fragment.e4xmi file which has a ModelFragment which has a StringModelFragment which has a handledMenuItem which has a Parameter which has different name and id.

2. In the same fragment.e4xmi now create a different StringModelFragment which has a command which has a parameter such that a) its name=the name of the parameter of the HandledMenuItem, and b) its id = the id of the parameter of the HandledMenuItem.

3. Add an org.eclipse.e4.workbench.model-extension and point it to the fragment.e4xmi file. 

3. Put to gether all other required parts and run the application and select the menu item. Nothing happens, i.e. the command (handler) is not being executed.

4. Set a breakpoint on line 172 in HandledMenuItemRenderer.java and notice how the HandledMenuItemRenderer (indirectly) passes a map where <key, value> = <command parameter name, command parameter value> to the org.eclipse.core.commands.ParameterizedCommand.generateCommand-method which takes a map of <command parameter id, command parameter value>-pairs as an argument. 

org.eclipse.core.commands.Command.getParameter(String parameterId) then uses these parameterid-keys to find the parameter, and this comparison fails since name and id are different.
Comment 1 Lars Vogel CLA 2012-10-03 00:36:49 EDT
This is fixed in Eclipse 4.2, ID don't need to be identical anymore.