The secret sauce seems to be:
Make your class implement
IElementUpdater
:
public class SampleHandler extends AbstractHandler implements IElementUpdater {
//...
}
Implement said interface with your required logic (this code is for my particular case):
/**
*@Override
*/
public void updateElement(UIElement element,
Map parameters) {
element.setChecked(this.image != null);
}
Now, you need to get the command service to call
updateElement
. The easiest way to do this is in your execute
method like so:
public Object execute(ExecutionEvent event) throws ExecutionException {
//... actually do something here ...
// Refresh the UI elements
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
ICommandService service = (ICommandService) window.getService(ICommandService.class);
service.refreshElements(event.getCommand().getId(), null);
return null;
}
No comments:
Post a Comment