0

I'm migrating my E3 to a pure E4 application. The E3 application used the activeWhen-Core Expression in Combination with propertyTesters to enable/disable ToolItems live. Now in E4 there is only the VisibleWhen Core Expression supported (right?).

Would I do this with the @CanExecute-Annotation now or is there a (hidden) activeWhen Expression? And if so, can I use the already existing Testers in this case or would it be better to use a new approach (like and inidividual Test for the individual cases)?

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Elias S
  • 118
  • 10

1 Answers1

0

There is no activeWhen expression in e4.

If you define a Handler for a Command in the main Handlers table in the Application.e4xmi then that is active everywhere and you will have to use its @CanExecute to control if the ToolItem/MenuItem is enabled.

An alternative is to define a Handler for a Command in the handler table for a Part (or Window). Then the ToolItem/MenuItem will only be active if there is a handler defined for the active part and its @CanExecute returns true.

greg-449
  • 109,219
  • 232
  • 102
  • 145
  • Thanks for the response! What do you mean by a single Handler? Right now i got multiple Commands and Handlers. Each for each ToolItem. Now I´d like to enable/disable them and i used to do that with the activeWhen expression. You mean to do that now by the @CanExecute ? – Elias S Jan 03 '16 at 14:55
  • I have expanded the answer. – greg-449 Jan 03 '16 at 15:23
  • Ah I see, so you mean that I could create 2 Handlers for the same Command on 2 Application-Levels, right ? I already went a little into the CanExecute, what could be a pssoböe reason for why the CanExecute is always executed 4 times in a row ? – Elias S Jan 03 '16 at 16:33
  • Eclipse is free to run the @CanExecute whenever it wants. You would have to look at the source code to see what it is doing for each call. – greg-449 Jan 03 '16 at 16:40
  • What exactly do you mean by "it is free to run". Isn´t there a rule ? E.g. Lars Vogels Book says, that if connected to a ToolBarItem, it should be runned every 400ms, but in my case it isn´t – Elias S Jan 03 '16 at 16:57
  • I mean whenever the Eclipse developers think they need it to run. If I remember correctly the 400ms was dropped some time ago as it caused too much load. When nothing is happening the @CanExecute is not called at all. – greg-449 Jan 03 '16 at 17:07
  • 1
    Note: The **Third** edition of Lars's book (now called 'Eclipse Rich Client Platform') drops the mention of 400ms. – greg-449 Jan 03 '16 at 17:24