My question is about the template code which does currently not use the
active selection. Of course in general @Named and Active makes sense and
have their use cases.

But IMHO not for the handler code as we generate it at the moment as the
handler is always executed in the active context.

@Execute
public void execute(
IEclipseContext context,
@Named(IServiceConstants.ACTIVE_SHELL) Shell shell,
@Named(IServiceConstants.ACTIVE_PART) final MContribution contribution)
throws InvocationTargetException, InterruptedException {


2013/9/16 Patrick Paulin <[email protected]>

> How about getting the active selection? My understanding was that the
> @Named annotation should be used when you don't know the type to be
> injected.
>
> On Sep 16, 2013, at 2:30 PM, Lars Vogel <[email protected]> wrote:
>
> Anyone with a example why these @Named tags are useful in a handler?
> Otherwise I remove them.
>
>
> 2013/9/12 Lars Vogel <[email protected]>
>
>> Hello,
>>
>> The example code from the e4 wizard uses
>>  @Named(ServiceConstants.ACTIVE_*) regulary. For example:
>>
>> @Execute
>> public void execute(
>> IEclipseContext context,
>> @Named(IServiceConstants.ACTIVE_SHELL) Shell shell,
>>  @Named(IServiceConstants.ACTIVE_PART) final MContribution contribution)
>> throws InvocationTargetException, InterruptedException {
>> ............
>> }
>>
>> AFAIK these service constants are useless in a handler, as the handler is
>> always executed in the active context.
>>
>> Is anyone aware of a situation in which @Inject MPart would fail (in a
>> handler class) and the usage of  @Named(IServiceConstants.ACTIVE_PART)
>> would return the correct part?
>>
>> I'm unable to construct one, so I'm thinking about changing the template
>> code.
>>
>> I understand that the constants are useful somewhere else, e.g. another
>> part but IMHO not in a handler.
>>
>> Best regards, Lars
>>
>>
>>
>>
>>
> _______________________________________________
> e4-dev mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/e4-dev
>
>
>
>
> _______________________________________________
> e4-dev mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/e4-dev
>
>
_______________________________________________
e4-dev mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/e4-dev

Reply via email to