The command framework is quite lazy. It doesn't really care about your expressions and your wishes about when handlers should be enabled or not. It’s your duty to refresh the enabled state of your handlers by telling the
using the following code we can Request Evalueation of our Expressoin:
IEvaluationService
. It’s not wise to refresh the commands regularly as it can be quite expensive. Instead triggering the refresh on events is the way to go.using the following code we can Request Evalueation of our Expressoin:
protected void requestRefresh() { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); IEvaluationService evaluationService = (IEvaluationService) window.getService(IEvaluationService.class); if (evaluationService != null) { evaluationService.requestEvaluation(PROPERTY_NAMESPACE + "." + PROPERTY_CAN_FOO); evaluationService.requestEvaluation(PROPERTY_NAMESPACE + "." + PROPERTY_CAN_BAR); } }
More information can be found:
http://www.robertwloch.net/2011/01/eclipse-tips-tricks-property-testers-with-command-core-expressions/
No comments:
Post a Comment