How to enable or disable an action based on the kind of selection? [message #576507] |
Sun, 17 August 2008 20:28 |
Nicholas Allen Messages: 10 Registered: July 2009 |
Junior Member |
|
|
Hi,
I am new to Eclipse plugin development and am having a problem that I
thought would be easy but doesn't seem to be.
Basically, I have some actions in my plugin that appear in Eclipse's
menu bar and I want to change their enabled state based on the current
selection.
What I assumed I would have to do is override the selectionChanged
method from the IWorkbenchWindowActionDelegate interface and use the
selection passed in to decide and update the action's enabled state.
Unfortunately, this does not work because the delegate is only created
after it has been invoked at least once. This means it starts off
enabled and after I select it I get an error from Eclipse "Operation not
available" and then the correct enabled state is set on it based on the
selection.
Of course, I don't want the user to have to invoke my action at least
once in order to get the correct enabled state shown. Basically, I need
to know when selection is changed before my action delegate has been
invoked. How do I do this?
Any help greatly appreciated.
Many thanks in advance,
Nicholas Allen
|
|
|
Powered by
FUDForum. Page generated in 0.03914 seconds