问题
How can I force Eclipse to do a re-evaluation of the activeWhen-conditions of all handlers?
Situation: I have defined a command on a TreeViewer. This command has more than one possible handlers. Handlers have defined some conditions to decide whether the handler shall be activated or not.
My problem is that there is no re-evaluation of the handler conditions until I de-seclect the item in the tree (e.g. select another item) and select it again.
If the selection does not change but the raise conditions do (e.g. due to an update of the element) the wrong handler will be executed.
Is there a way to manually force an Handler re-evaluation on the selection?
回答1:
If your condition examines state in your treeviewer selection using property testers, then you need to notify the IEvaluationService that the property in question has changed. See org.eclipse.ui.services.IEvaluationService.requestEvaluation(String)
来源:https://stackoverflow.com/questions/12092661/eclipse-force-handlers-to-to-re-evaluate