Community
Participate
Working Groups
As an example: in the e4 contacts demo the SaveHandler has a @canExecute annotation. This works perfectly when putting either a direct or a handled menu item in a menu (in the contacts demo in the File menu). But is does not work when putting a direct or handled tool item into a toolbar.
even modifying class HandledContributionItem (this is used as renderer for both menu and tool items) like private boolean isEnabled(MHandledItem item) { final IEclipseContext lclContext = getContext(item); ParameterizedCommand cmd = item.getWbCommand(); if (cmd != null) { EHandlerService service = (EHandlerService) lclContext .get(EHandlerService.class.getName()); return service.canExecute(cmd); } return item.isEnabled(); } and invoking isEnabled(...) does only help when creating the toolbar. The checking of menu items (invoking the service.canExecute() method) is done every time a menu pops down. But the toolbar is static and nothing triggers the canExecute check.
We're creating RATs for the visibility of toolitems, jut not for the enabled state. PW
Paul, is this easy to fix then?
I think so ... ToolBarManagerRenderer needs to generate RATs for enabled state, similar to org.eclipse.e4.ui.workbench.renderers.swt.ToolBarManagerRenderer.processAddition(MToolBar, ToolBarManager, MToolBarContribution) does for visibility. Although because enabled is all about the handler @CanExecute, maybe HandledContributionItem should generate the RAT (and make sure it's disposed when necessary). PW
Paul, think this was the bug that Tom was talking about yesterday?
Released to HEAD PW