I have a Handler with an enabledWhen filter based on a variable that I've defined and implemented with a SourceProvider
<enabledWhen>
<with
variable="MY_VARIABLE">
<equals
value="true">
</equals>
</with>
</enabledWhen>
I declare the SourceProvider as follows
<extension
point="org.eclipse.ui.services">
<sourceProvider
provider="<my class reference>">
<variable
name="MY_VARIABLE"
priorityLevel="workbench">
</variable>
</sourceProvider>
</extension>
And here's my SourceProvider implementation:
String state
@Override
public String[] getProvidedSourceNames() {
return new String[] {"MY_VARIABLE"};
}
@Override
public Map<String, String> getCurrentState() {
Map<String, String> map = new HashMap<String, String>();
map.put("MY_VARIABLE", state));
return map;
}
public void setCurrentState(String state) {
this.state = state
fireSourceChanged(ISources.WORKBENCH, "MY_VARIABLE", state);
}
Pretty straightforward, but it doesn't work. I set the state of the source provider
ISourceProviderService service = ...
sourceProvider = service.getSourceProvider("MY_VARIABLE");
sourceProvider.setEnabled("true");
I see the sourceChanged event fired in the debugger with the value set to "true". But the handler remains disabled. I tried forcing an evaluation with the evaluation service
IEvaluationService evaluationService = ...
evaluationService.requestEvaluation("MY_VARIABLE");
But this has no effect either.
Can someone please tell me what I'm missing?