| Summary: | @canExecute in Handlers does not effect tool items in a toolbar | ||
|---|---|---|---|
| Product: | [Eclipse Project] e4 | Reporter: | Kai Toedter <kai.toedter> |
| Component: | UI | Assignee: | Paul Webster <pwebster> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | daniel_megert, pwebster, remy.suen, tom.schindl |
| Version: | unspecified | ||
| Target Milestone: | 4.1 RC2 | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
|
Description
Kai Toedter
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 |