[Luna] @CanExecute not called [message #1387779] |
Wed, 25 June 2014 15:24 |
Luca Moretto Messages: 4 Registered: June 2014 |
Junior Member |
|
|
Hi all,
I'm facing an issue with command handlers in Luna.
In my application I defined some commands and associated handlers that should be enabled only in some particular situation. To this purpose, I implemented in my handlers methods annotated with @CanExecute.
I also have menu items and tool items that reference those commands.
The problem is that the @CanExecute methods aren't invoked as expected and, as a consequence, menu and tool items aren't enabled/disabled accordingly.
In particular, for menu items, the CanExecute methods are only invoked a few times at application startup, but never after that.
For tool items, instead, the CanExecute methods are only invoked when the active context changes, e.g. when changing the active part or opening a new shell.
The behavior in Kepler was quite different (and worked as expected):
- for tool items, there was a timer that invoked the CanExecute methods every few milliseconds
- for menu items, the check was performed every time a menu was shown.
Is this a known bug in Luna?
Is there any possible workaround to achieve the expected behavior?
Thank you!
|
|
|
Re: [Luna] @CanExecute not called [message #1387903 is a reply to message #1387779] |
Wed, 25 June 2014 19:08 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
The Kepler behavior was wrong and calling the @CanExecute was a
performance problem.
You can force enablement processing by sending an event on the eventbus.
eventBroker.send(UIEvents.REQUEST_ENABLEMENT_UPDATE_TOPIC,
UIEvents.ALL_ELEMENT_ID);
Tom
On 25.06.14 18:28, Luca Moretto wrote:
> Hi all,
> I'm facing an issue with command handlers in Luna.
>
> In my application I defined some commands and associated handlers that
> should be enabled only in some particular situation. To this purpose, I
> implemented in my handlers methods annotated with @CanExecute.
>
> I also have menu items and tool items that reference those commands.
>
> The problem is that the @CanExecute methods aren't invoked as expected
> and, as a consequence, menu and tool items aren't enabled/disabled
> accordingly.
>
> In particular, for menu items, the CanExecute methods are only invoked a
> few times at application startup, but never after that.
>
> For tool items, instead, the CanExecute methods are only invoked when
> the active context changes, e.g. when changing the active part or
> opening a new shell.
>
> The behavior in Kepler was quite different (and worked as expected):
> - for tool items, there was a timer that invoked the CanExecute methods
> every few milliseconds
>
> - for menu items, the check was performed every time a menu was shown.
>
> Is this a known bug in Luna? Is there any possible workaround to achieve
> the expected behavior?
>
> Thank you!
>
>
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04062 seconds