Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [e4-dev] Question for the template code from the e4 wizard

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 <patrick@xxxxxxxxxxxx>
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 <lars.vogel@xxxxxxxxx> wrote:

Anyone with a example why these @Named tags are useful in a handler? Otherwise I remove them.


2013/9/12 Lars Vogel <lars.vogel@xxxxxxxxx>
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
e4-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/e4-dev



_______________________________________________
e4-dev mailing list
e4-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/e4-dev



Back to the top