Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » [Luna] @CanExecute not called
[Luna] @CanExecute not called [message #1387779] Wed, 25 June 2014 15:24 Go to next message
Luca Moretto is currently offline Luca MorettoFriend
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 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
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!
>
>
Re: [Luna] @CanExecute not called [message #1388262 is a reply to message #1387903] Thu, 26 June 2014 07:32 Go to previous messageGo to next message
Luca Moretto is currently offline Luca MorettoFriend
Messages: 4
Registered: June 2014
Junior Member
Hi Tom,
thanks for your answer.

This is the same suggestion I got on stackoverflow (unfortunately, I cannot insert the link to the question) and it actually fixes my problem with toolbar items.

Regarding menu items, I found that my problem was related to the Unity panel under Ubuntu. If I start my application with "env UBUNTU_MENUPROXY=" (i.e., clearing the UBUNTU_MENUPROXY variable) the problem is solved.

Thanks again,
Luca
Re: [Luna] @CanExecute not called [message #1388275 is a reply to message #1388262] Thu, 26 June 2014 07:52 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
On 26.06.14 09:32, Luca Moretto wrote:
> Hi Tom, thanks for your answer.
>
> This is the same suggestion I got on stackoverflow (unfortunately, I
> cannot insert the link to the question) and it actually fixes my problem
> with toolbar items.
>
> Regarding menu items, I found that my problem was related to the Unity
> panel under Ubuntu. If I start my application with "env
> UBUNTU_MENUPROXY=" (i.e., clearing the UBUNTU_MENUPROXY variable) the
> problem is solved.

I'd consider this a bug which should be reported!

Tom
Re: [Luna] @CanExecute not called [message #1388589 is a reply to message #1388275] Thu, 26 June 2014 17:20 Go to previous message
Luca Moretto is currently offline Luca MorettoFriend
Messages: 4
Registered: June 2014
Junior Member
Hi Tom,
I opened a bug report for this: https://bugs.eclipse.org/bugs/show_bug.cgi?id=438304

Luca
Previous Topic:Eclipse 4.3.2 R2 Can't Startup
Next Topic:Using latest E4 tools with 4.3 target platform
Goto Forum:
  


Current Time: Fri Apr 19 20:03:56 GMT 2024

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

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

Back to the top