Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » commands and handler enable/disable
commands and handler enable/disable [message #488333] Mon, 28 September 2009 08:32 Go to next message
Sir Wayne is currently offline Sir WayneFriend
Messages: 216
Registered: July 2009
Senior Member
Hello,

I have a own command and a handler. This handler is enable when the activeEditor implement my own interface IClearable.
This works:
   <handler
            class="ui.command.MaskDeleteHandler"
            commandId="MaskDelete">
         <enabledWhen>
            <with
                  variable="activeEditor">
               <instanceof
                     value=IClerable>
               </instanceof>
            </with>
         </enabledWhen>
      </handler>


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 true.

How could I do this?

Thx a lot Smile
Re: commands and handler enable/disable [message #488346 is a reply to message #488333] Mon, 28 September 2009 10:57 Go to previous message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
SirWayne wrote:
> Hello,
>
> I have a own command and a handler. This handler is enable when the
> activeEditor implement my own interface IClearable.
> This works:
>
> <handler
> class="ui.command.MaskDeleteHandler"
> commandId="MaskDelete">
> <enabledWhen>
> <with
> variable="activeEditor">
> <instanceof
> value=IClerable>
> </instanceof>
> </with>
> </enabledWhen>
> </handler>
>
>
>
> 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
> true.
>
> How could I do this?

I strongly suggest to study some introductory material like that
provided by

http://www.vogella.de/articles/EclipseCommands/article.html

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.

- Daniel
Previous Topic:Cheat Sheet Functionality Extension
Next Topic:New Wizards
Goto Forum:
  


Current Time: Fri Nov 28 17:19:29 GMT 2014

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

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