Community
Participate
Working Groups
When you have a DirectMenuItem, @CanExecute is not executed before the item is displayecd. Only after clicking.
It's supposed to be called on SWT.Show by org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRendererFilter.updateElementVisibility(MMenu, MenuManagerRenderer, MenuManager, IEclipseContext, int, boolean) :351 } else if (updateEnablement && element instanceof MDirectMenuItem) { it will only be called if it has been instantiated already. PW
Created attachment 214787 [details] Example to demonstrate the bug @Paul attached you find an example project. It has a DirectMenuItem and a HandledMenuItem in the File menu. The corresponding handler returns always "false" on the method that is annotated with @CanExecute. While the HandledMenuItem behaves correctly, I would expect the DirectMenuItem being disabled, too. But it is enabled and only when you click on it, it will be disabled. This is a very confusing behavior and I consider it a bug.
(In reply to comment #2) > > While the HandledMenuItem behaves correctly, I would expect the DirectMenuItem > being disabled, too. But it is enabled and only when you click on it, it will > be disabled. This is a very confusing behavior and I consider it a bug. OK, this is the lazy loading behaviour, where it's only called if instantiated already. It differs slightly from the default platform behaviour, because DirectContribuitonItem doesn't force loading of the contribution for a @CanExecute if its contributing bundle is already active. We should align this with the platform strategy. PW
Created attachment 217657 [details] Proposed patch
Facing the same problem, will the patch make it into the next release?
The target milestone is 4.3 so it should be on Kepler. Paul, what do you think?
Yes, this will definitely be in Kepler. PW
Released as http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?h=R4_2_maintenance&id=5d583c4f05137573387494cfa3e92f58abfcd6d2 Thanks Sopot. PW
In M20130116-1800 PW
.
I think this is still valid for DirectToolItems, see attached example. The first ToolItem in the example is a direct, the second one a handled. If you click the save button, both should toggle their enabled state.
Created attachment 232046 [details] DirectTool Item example
Please open a new bug. PW
https://bugs.eclipse.org/bugs/show_bug.cgi?id=410087