Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Pre-defined command parameter type converters/TypeIDs for primitives?
Pre-defined command parameter type converters/TypeIDs for primitives? [message #1726056] Wed, 09 March 2016 10:17 Go to next message
Andreas Sewe is currently offline Andreas SeweFriend
Messages: 111
Registered: June 2013
Senior Member
When I execute a command (e.g., using the EHandlerService), I can pass a Map<String, Object> as parameters. Unfortunately, AFAIK any non-String parameter needs a command parameter type converter to String and back.

Having to write such a converter is annoying especially when you just want to parameterize your command with an int or boolean; what you save in parsing strings in the command's @Execute method you pay for double in the converter implementation.

I am hence curious whether there exists a set of pre-defined TypeIDs (with converters) for at least the primitive Java types?

More generally, how do I find our which TypeIDs are known in my application?
Re: Pre-defined command parameter type converters/TypeIDs for primitives? [message #1728927 is a reply to message #1726056] Fri, 08 April 2016 13:39 Go to previous messageGo to next message
Eclipse UserFriend
It looks like TypeIDs aren't supported within Eclipse 4 yet.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=405888
Re: Pre-defined command parameter type converters/TypeIDs for primitives? [message #1728933 is a reply to message #1728927] Fri, 08 April 2016 13:51 Go to previous messageGo to next message
Eclipse UserFriend
This is probably the better bug
Re: Pre-defined command parameter type converters/TypeIDs for primitives? [message #1728935 is a reply to message #1728927] Fri, 08 April 2016 13:55 Go to previous messageGo to next message
Andreas Sewe is currently offline Andreas SeweFriend
Messages: 111
Registered: June 2013
Senior Member
Brian de Alwis wrote on Fri, 08 April 2016 09:39
It looks like TypeIDs aren't supported within Eclipse 4 yet.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=405888

Are you sure? I have typeId="org.eclipse.recommenders.news.rcp.commandParameterType.boolean" with a straightforward BooleanParameterValueConverter in my plugin. Of course, I had to register the commandParameterType using the compatibility layer org.eclipse.ui.commands extension point, but referring to the typeId in an fragment.e4xmi works..

What is rather frustrating, though, is that I am forced to write the BooleanParameterValueConverter. Why are there no predefined value converters for at least the Java primitives?
Re: Pre-defined command parameter type converters/TypeIDs for primitives? [message #1728936 is a reply to message #1728933] Fri, 08 April 2016 13:56 Go to previous messageGo to next message
Andreas Sewe is currently offline Andreas SeweFriend
Messages: 111
Registered: June 2013
Senior Member
Brian de Alwis wrote on Fri, 08 April 2016 09:51
This is probably the better bug

What is "this"? Forgot the link?
Re: Pre-defined command parameter type converters/TypeIDs for primitives? [message #1728955 is a reply to message #1728935] Fri, 08 April 2016 16:00 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
I would question why you'd have to write such a converter in an e4 world
anyways (you really should not bother with the commands-framework at all
:-).

The DI-System needs to be able to adapt String => int.

e(fx)clipse has support for this, just write

void execute(@Adapt @Named("myStringParam") int myOriginalString) {
}

see https://wiki.eclipse.org/Efxclipse/Runtime/Recipes#.40Adapt

Tom

On 08.04.16 15:55, Andreas Sewe wrote:
> Brian de Alwis wrote on Fri, 08 April 2016 09:39
>> It looks like TypeIDs aren't supported within Eclipse 4 yet.
>>
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=405888
>
> Are you sure? I have
> typeId="org.eclipse.recommenders.news.rcp.commandParameterType.boolean"
> with a straightforward BooleanParameterValueConverter in my plugin. Of
> course, I had to register the commandParameterType using the
> compatibility layer org.eclipse.ui.commands extension point, but
> referring to the typeId in an fragment.e4xmi works..
>
> What is rather frustrating, though, is that I am forced to write the
> BooleanParameterValueConverter. Why are there no predefined value
> converters for at least the Java primitives?
Re: Pre-defined command parameter type converters/TypeIDs for primitives? [message #1728968 is a reply to message #1728955] Fri, 08 April 2016 17:29 Go to previous messageGo to next message
Eclipse UserFriend
Oops, yup forgot the link: https://bugs.eclipse.org/bugs/show_bug.cgi?id=480935
Re: Pre-defined command parameter type converters/TypeIDs for primitives? [message #1729148 is a reply to message #1728955] Mon, 11 April 2016 14:05 Go to previous messageGo to next message
Andreas Sewe is currently offline Andreas SeweFriend
Messages: 111
Registered: June 2013
Senior Member
Thomas Schindl wrote on Fri, 08 April 2016 12:00
I would question why you'd have to write such a converter in an e4 world
anyways (you really should not bother with the commands-framework at all
Smile.

Having to write the converter is annoying, yes; that's what this post is about.

But what is wrong with using the command framework as such? Is it deprecated?

Quote:

The DI-System needs to be able to adapt String => int.

e(fx)clipse has support for this, just write

void execute(@Adapt @Named("myStringParam") int myOriginalString) {
}

see https://wiki.eclipse.org/Efxclipse/Runtime/Recipes#.40Adapt

Cool. Is this usable in a plain old E4 compatibility layer application (aka "the Eclipse IDE") or only when using JavaFX?
Re: Pre-defined command parameter type converters/TypeIDs for primitives? [message #1729152 is a reply to message #1729148] Mon, 11 April 2016 14:32 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
On 11.04.16 16:05, Andreas Sewe wrote:
> Thomas Schindl wrote on Fri, 08 April 2016 12:00
>> I would question why you'd have to write such a converter in an e4 world
>> anyways (you really should not bother with the commands-framework at all
>> :).
>
> Having to write the converter is annoying, yes; that's what this post is
> about.
>
> But what is wrong with using the command framework as such? Is it
> deprecated?
>

If you look at the e4 handler story you notice that it does not care
about the low-level command/handler framework and in theory (if
EHandlerService and ECommandService would not totally leak that guy) you
could replace them with something simpler!

So why battleing with this old system if you could have simply used
OSGi-Services and some DI magic ;-)

> Quote:
>> The DI-System needs to be able to adapt String => int.
>>
>> e(fx)clipse has support for this, just write
>>
>> void execute(@Adapt @Named("myStringParam") int myOriginalString) {
>> }
>>
>> see https://wiki.eclipse.org/Efxclipse/Runtime/Recipes#.40Adapt
>
> Cool. Is this usable in a plain old E4 compatibility layer application
> (aka "the Eclipse IDE") or only when using JavaFX?
>

Yes. Most of the stuff you see on that wiki page is part of our core
codebase who is not depending on anything from the JavaFX world, our IDE
stuff also depends on that things so we contribute that to the release
train aggregration repo.

Tom
Previous Topic:How to persist setVisible/setToBeRendered changes across restarts?
Next Topic:disable console of a plugin
Goto Forum:
  


Current Time: Thu Mar 28 13:00:19 GMT 2024

Powered by FUDForum. Page generated in 0.03538 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top