Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsHandler enablement doesn't work unless widow focus changes
https://www.eclipse.org/forums/index.php/mv/msg/162681/514599/#msg_514599
When the system property changes such that a command should be disabled, it still shows up as enabled in the menu. But If I select it, I get an exception that says I'm trying to run a command that's disabled.
I found that if, after the system property changes such that the handler should be disabled, I select a different window and the re-select the RCP app window, the menu shows the proper enablement state. So it seems like the menu is not being refreshed when the system property changes, until the app window loses and re-gains focus.
Am I supposed to do something to refresh the menu when the system property changes? I also tried using <visibleWhen> on the menu item, with the same property tester. The same thing happens- I have to make the app window lose and re-gain focus to show the proper visibility state.
My enablement extension looks like this
<handler
class=...
commandId=... />
<enabledWhen>
<systemTest property="myPropertyName" value="theExpectedValue" />
</enabledWhen>
/handler>
]]>Mark Leone2010-02-15T22:32:11-00:00Re: Handler enablement doesn't work unless widow focus changes
https://www.eclipse.org/forums/index.php/mv/msg/162681/514673/#msg_514673
you should propably consider using a SourceProvider and you should also have a look at IEvaluationService.
The article gives everything needed to update enablement or visibility on commands or handlers in response to an arbitrarily defined variable. It also covers how to dynamically change a command or handler's label, which was also something I was interested in.]]>Mark Leone2010-02-16T20:11:16-00:00Re: Handler enablement doesn't work unless widow focus changes
https://www.eclipse.org/forums/index.php/mv/msg/162681/515016/#msg_515016
org.eclipse.ui.services.IEvaluationService.requestEvaluation (String) to
request that expressions using a specific property tester be
re-evaluated without having to create a source provider.
Source providers are really handy if you want to expose one or more
variables, that can then be used in <with/> expressions.