Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Source Provider State ignored by Handler(fireSourceChanged() invocation has no effect on handler enablement state)
Source Provider State ignored by Handler [message #1241271] Fri, 07 February 2014 18:35 Go to next message
Mark Leone is currently offline Mark LeoneFriend
Messages: 67
Registered: April 2012
Member
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?
Re: Source Provider State ignored by Handler [message #1241300 is a reply to message #1241271] Fri, 07 February 2014 19:33 Go to previous message
Mark Leone is currently offline Mark LeoneFriend
Messages: 67
Registered: April 2012
Member
Of course as soon as I post a message, the answer occurs to me. The tooltip for the value attribute of the "equals" element inside the "with" element used in the "enabledWhen" expression notes that the value is converted to a java base type according to the customary rules.

So my expected value of "true" was interpreted as a Boolean. I changed the SourceProvider implementation to set the value of the variable as a Boolean instead of converting it to a String. Now the enablement works as expected.
Previous Topic:drawing arrow lines between swt components/jface viewers
Next Topic:ScrolledComposite in TitleAreaDialog
Goto Forum:
  


Current Time: Sun Dec 21 23:56:00 GMT 2014

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

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