Publishing to the Eclipse context using @ContextValue [message #1289478] |
Wed, 09 April 2014 07:08  |
Eclipse User |
|
|
|
Hi,
I'm getting familiar with the @ContextValue annotation for publishing objects to the Eclipse context as described on this e(fx)clipse wiki page.
I wrote a small handler class that follows the code sample in the wiki:
public class MyHandler {
@Inject
@ContextValue(contextKey = "item")
ContextBoundValue<String> value;
@Execute
public void execute(@Named(IServiceConstants.ACTIVE_SELECTION) @Optional Object selection) {
if (selection instanceof String) {
value.publish((String) selection);
}
}
}
This works fine when the handler is called once, but if I execute the handler twice, I get the following error:
Caused by: java.lang.IllegalArgumentException: Variable item is not modifiable in the context WorkbenchContext
at org.eclipse.e4.core.internal.contexts.EclipseContext.internalModify(EclipseContext.java:376)
at org.eclipse.e4.core.internal.contexts.EclipseContext.modify(EclipseContext.java:366)
at org.eclipse.fx.core.di.context.internal.EclipseContextBoundValue.publish(EclipseContextBoundValue.java:100)
at foo.MyHandler.execute(CopyHandler.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
The same happens when I use a Property<String> object instead of the ContextBoundValue<String> type.
Am I using the @ContextValue mechanism in wrong way or is this a bug in e(fx)clipse?
Thanks.
Uwe
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03889 seconds