|Re: commands and handler enable/disable [message #488346 is a reply to message #488333]
||Mon, 28 September 2009 06:57
| Daniel KrÃ¼gler
Registered: July 2009
> I have a own command and a handler. This handler is enable when the
> activeEditor implement my own interface IClearable.
> This works:
> public interface IClearable
> public boolean isClear();
> But now I want a 2nd condition. The command should only be enabled, if
> the activeEditor implements IClearable and the isClear methode returns
> How could I do this?
I strongly suggest to study some introductory material like that
The short answer is: Constraints provided for enablement and
visibility can be combined via and and or. Just have a look at
the extension point description for org.eclipse ui.handlers
and org.eclipse.ui.menus. Provided you have not added yet
a current enabledWhen element, one of the choices are "and"
and "or". I agree that this is not very obvious, because typically
you start with one constraint (where you typically don't foresee
to start with "and") and after some time you consider to
add a *further* one. But at this point of time, no further
element will be suggested for you.
Another typical error is that for sequences of elements (even
if this sequence may be restricted to 0..1 selections), you
are required to add the and/or combinations below an <iterate>
element - this is also sometimes quite annoying.
Powered by FUDForum
. Page generated in 0.01879 seconds