I have a ControlContribution that I've added to a ToolBar in a ViewPart. I want to change its enabled state depending on the state of a resource known to the ViewPart code. I tried passing the ControlContribution item a reference to the view, and overriding the enablement method, like this:
@Override
public boolean isEnabled() {
return this.myView.isResourceReady();
}
But I don't know how to tell the ToolBarManager that the resource status has changed. Whenever it changes, I call
toolBarManager.update(true);
but this doesn't change the enablement state of the ControlContribution--it's always enabled.
I also tried calling
controlContribution.setVisible(false);
when I cerate controlContribution. This makes it not visible, but then there is no way to make it visible when the resource status changes. I invoke
controlContribution.setVisible(true);
toolBarManager.update(true);
But controlContribution does not become visible.