i want to have a toggel type command (in popup menu) but i do not want to give default state(true|false), i want to decide that based on property of selected object at the run time. Is it possible to add this using extensions interface or i need to add menu programmatically?
Paul Webster Messages: 6813 Registered: July 2009 Location: Ottawa
For toggle commands, their is a Command State object that controls the state. But that state is valid for the command globally. One option is to just use the global command state and update it on a selection changed using org.eclipse.ui.handlers.HandlerUtil.toggleCommandState(Command).
The other possible solution would be to have your handler be an IElementUpdater. On selection change you can call org.eclipse.ui.commands.ICommandService.refreshElements(String, Map). Your handler can use the selection to figure out if it should set the toggle to checked or not.