In my plugin I created an editor and EditorActionBarContributor which adds some Actions to the editor. I added the actions to the context menu of the editor programmatically. In the seletionChanged() I control which actions should be enabled in the context menu depending on the state of the editor, e.g. selections or the type of the file.
Now I want to move those actions to the eclipse toolbar as well. For this, I created an extension for the extension point org.eclipse.ui.editorActions and added an action for each action in the editor, with an IEditorActionDelegate for each action, which gets the correspondent action form the editor and runs it.
I want to control the enable/disable the buttons in the toolbar for these actions like I do in the editor, but I have no idea how I can do that. For example, I want a button to be only enabled if there is text selected in the editor.
How can I do that?
This is not a direct answer to your question, but I would consider using Eclipse commands instead. They are more cleanly separated so that you can have one place that indicates the command is enabled/disabled and then that automatically manifests in the menu/toolbar/bound keys, etc.
Also, Actions are effectively deprecated, as commands has been the preferred mechanism since about Eclipse 3.5.