|enable/disable commands handler [message #674293]
||Thu, 26 May 2011 08:47
| Gennady Gromov
Registered: May 2011
I am a beginner in eclipse RCP.
I am trying to use AbstractHandler.setBaseEnabled() for control of the handler state. But it is not enough clear how to call this method externally because it is private.
May be there is another way to control of enable state of handler programmically at runtime?
|Re: enable/disable commands handler [message #674562 is a reply to message #674469]
||Fri, 27 May 2011 07:19
| Paul Webster
Registered: July 2009
ALGROM wrote on Fri, 27 May 2011 00:25|
At runtime in my application there are different situations which are not relating to workbench. According with these states I should change the status of menu/toolbar commands (items): visible, enabled, text and icon.
I know about the "enableWhen" and "activeWhen" conditions for the commands in plugin.xml but it supports only the workbench status.
You didn't really answer my questions, and that makes it difficult to actually help you. But I'll make 4 assumptions and provide an answer anyway
visibleWhen, enabledWhen and activeWhen are core expressions, which support property testers  . You can write a property tester that examines your "situations" and returns the correct enabled state. When your "situation" changes, you use org.eclipse.ui.services.IEvaluationService.requestEvaluation(String) to have the framework re-evaluate those expressions (updating the commands).
To update text and icons, your handler needs to implement org.eclipse.ui.commands.IElementUpdater. When you "situation" needs to update text, you use org.eclipse.ui.commands.ICommandService.refreshElements(String, Map).
Powered by FUDForum
. Page generated in 0.02029 seconds