Eclipse Luna: @CanExecute handler methods not called

I have a problem with command handlers in Eclipse Luna RCP.

In my E4 application model, I defined some commands and their associated handlers that should only be enabled under certain circumstances. For this reason, in my POJO handler, I implemented methods annotated with @CanExecute , where I check the required conditions.

I also defined menu items and toolbars associated with these commands.

The problem is that my @CanExecute methods @CanExecute not called correctly and, as a result, the menus and toolbar items are not enabled / disabled, respectively.

In particular, for menu items, @CanExecute methods @CanExecute called only a few times when the application starts, but never after that.

Instead of elements of the toolbar, @CanExecute methods @CanExecute called only when the active context changes (for example, when changing the active part or opening a new shell).

In Kepler, the behavior was completely different (and worked as expected):

  • for menu items, @CanExecute methods @CanExecute called every time the menu was shown.
  • there was a timer for toolbar items that called @CanExecute methods every 400 ms

Is this a known mistake in the moon? Do you know of any possible workaround to achieve the expected behavior?

Thanks!

+2
source share
1 answer

This is a design change in Eclipse Luna described in bug 427465 , also 436755

You can get @CanExecute toolbar methods using:

 eventBroker.send(UIEvents.REQUEST_ENABLEMENT_UPDATE_TOPIC, UIEvents.ALL_ELEMENT_ID); 

'eventBroker' is an IEventBroker .

+7
source

Source: https://habr.com/ru/post/971840/


All Articles