Community
Participate
Working Groups
I have created a handled menu item that evaluates @CanExecute for a modifiable value in the context. @CanExecute public boolean canExecute(@Optional @Named("EXIT_ENABLED") Boolean enabled) { return enabled != null ? enabled : false; } I have a menu item for enabling/disabling the handler by setting the value in the context, and sending the event for updating the menu items via event broker: context.modify("EXIT_ENABLED", Boolean.FALSE); broker.post(UIEvents.REQUEST_ENABLEMENT_UPDATE_TOPIC, UIEvents.ALL_ELEMENT_ID); In a pure E4 application, this works fine. When the compatibility layer is involved, it doesn't work. On debugging we noticed that on pure e4 sending the event triggers the execution of @CanExecute, in compat mode it isn't.
I need to correct this ticket. It is not related to the compatibility layer and does appear always. The issue is related to MDirectToolItems. @CanExecute is never called for them, therefore the enabled state is not correctly evaluated on rendering tool items in a part toolbar. This happens for Eclipse 4 applications aswell as for Eclipse 3 applications in compatibility mode.
Created attachment 255240 [details] Eclipse 4 based application with part toolbar example This application is based on the Eclipse 4 template in PDE. The part has two menu items in the part toolbar, a handled menu item and a direct menu item. Both are connected to the same handler class. Selecting item "One" in the viewer should disable the toolbar items, selecting the other should enable them. The handled menu item is rendered disabled/enabled correctly, while the direct menu item is not. Note that the direct menu item is not executed if it is disabled, so regarding the functionality it is correct, but it is not rendered correctly according to the enabled state.
IIRC e4 on SWT never supported @CanExecute on MDirect* - what I don't get is why it should not work for e3 compat mode apps? Are extension points really translated into MDirect*?
(In reply to Thomas Schindl from comment #3) > IIRC e4 on SWT never supported @CanExecute on MDirect* - what I don't get is > why it should not work for e3 compat mode apps? Are extension points really > translated into MDirect*? Forget about the compat mode stuff. It appeared on migrating from E3 to E4. So currently we are in a mixed mode with e4views that create the toolbar programmatically, as the contribution of toolbar items via fragment is not working correctly. I just mentioned it because of the initial report. So this ticket is invalid because it was never supported that way? Or is this a missing feature? I can see that for MDirectToolItems never an update is performed in the REQUEST_ENABLEMENT_UPDATE_TOPIC event handler.
There's no reason why MDirect should not support @CanExecute and eg efxclipse does support it so it is perfectly valid to request the same from SWT
(In reply to Thomas Schindl from comment #5) > There's no reason why MDirect should not support @CanExecute and eg > efxclipse does support it so it is perfectly valid to request the same from > SWT +1
New Gerrit change created: https://git.eclipse.org/r/52064
Gerrit change https://git.eclipse.org/r/52064 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=c0d8b6bf7b5bb25e40a5fffcb0a776a8b9c62bd3
Fixed with the above patch. One question, can this be downported for SR1?
Well this no regression so i think this is not suitable for SR
(In reply to Thomas Schindl from comment #10) > Well this no regression so i think this is not suitable for SR This is currently under discussion, the foundation thinks about a higher frequency of Eclipse releases. But as of now, we do not downport new functionality to SR, so Toms statement is correct.
*** Bug 410087 has been marked as a duplicate of this bug. ***
(In reply to Thomas Schindl from comment #3) > IIRC e4 on SWT never supported @CanExecute on MDirect* - what I don't get is > why it should not work for e3 compat mode apps? Are extension points really > translated into MDirect*? So just a point: Direct* supported @CanExecute but it was only evaluation on execution rather than properly used to determine the enablement status of the corresponding UI item.