NPE for typed command parameter [message #938954] |
Wed, 10 October 2012 05:52  |
Eclipse User |
|
|
|
Hi,
I created a command with two parameters. I want one of the parameters to be of type java.lang.Boolean, so I entered java.lang.Boolean to the TypeId of the CommandParameter.
The handler looks like this:
@Execute
public void execute(EPartService partService,
@Named(PART_ID) String viewId,
@Named(HIDE_ON_RESHOW) @Optional Boolean hideOnReshow)
Then I try to add a HandledMenuItem to a menu, setting the parameter value of the boolean parameter to TRUE (also tried true).
The menu isn't rendered because of the following exception:
java.lang.NullPointerException
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.generateCommand(HandledContributionItem.java:286)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.setModel(HandledContributionItem.java:265)
at org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRenderer.processHandledItem(MenuManagerRenderer.java:703)
If I remove the TypeId there is no exception. The value for the optional Boolean parameter is null as the type doesn't match and the parameter is @Optional.
Changing the type of that parameter to String results in the correct injection of the parameter value. Of course it is then the String "TRUE".
Are typed parameters not supported in Eclipse 4? Or am I missing something on using typed parameters?
Greez,
Dirk
|
|
|
|
|
|
Re: NPE for typed command parameter [message #941316 is a reply to message #941253] |
Fri, 12 October 2012 07:52  |
Eclipse User |
|
|
|
As posted before, yes I defined a converter for java.lang.Boolean and used the id for it as TypeId for the command in application model. I don't get a NPE anymore, but there is also no conversion in the back. And I don't know how to get the configured converter. At least the whole concept doesn't make real sense in eclipse 4 if I need to retrieve a converter out of whereever to do the conversion. If this is necessary, I can do the conversion in the handler.
Please correct me if I'm seeing this wrong. At least I didn't find a solution for automatic conversion and did it manually.
|
|
|
Powered by
FUDForum. Page generated in 0.05695 seconds