Search code examples
eclipse-rcpe4

Retrieving parameters from eclipse rcp/e4 in Handler


I have code to execute my handler/command, and it reaches here:

@Execute
public Object execute(Shell shell) {
    System.out.println("Executing login!");
    return null;
}

However, I cannot find the injection service to provide me the parameters I passed in the command.

I tried:

@Execute
public Object execute(ExecutionEvent event)

But it doesn't even see this method, and I suspect it's because that's not even an e4.* class. I am aware of Eclipse RCP 4 - Handler method parameters but it doesn't tell me which service the command parameters are, e.g..:

ParameterizedCommand myCommand = commandService.createCommand("mycommand.login", credentials);
Object result = handlerService.executeHandler(myCommand);

Where are my values from the credentials map?


Solution

  • You can get the whole ParameterizedCommand injected in the handler using:

    @Execute
    public void execute(ParameterizedCommand command)
    

    Or you can get the individual parameters using their ids:

    @Execute
    public void execute(@Named("parameter id") String parameter)