Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » How to enable or disable an action based on the kind of selection?
How to enable or disable an action based on the kind of selection? [message #576507] Sun, 17 August 2008 20:28
Nicholas Allen is currently offline Nicholas AllenFriend
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
Previous Topic:Need help with 'menus' extension
Next Topic:Getting list of selected files from ISelection
Goto Forum:
  


Current Time: Wed Sep 25 21:19:41 GMT 2024

Powered by FUDForum. Page generated in 0.03914 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top