Community
Participate
Working Groups
Created attachment 208475 [details] initial patch BuildId: 4.2M4 Old-style Actions, without a command identifier, added to an editor toolbar never have their enablement status updated. These actions are transformed by MenuHelper#createToolItem(MApplication application, ActionContributionItem item) into MDirectToolItems, and rendered as DirectContributionItems. Unlike MHandledToolItems (and its rendered equivalent, HandlledContributionItem), DirectContributionItems have no periodic timer to check the item enablement, nor are there any property listeners registered with the action to trigger updates. Given that these items have an action, the attached patch leverages uses an action's property notification to update the item's label, tooltip, and image changes too. I realize this is just one-half of a solution, since it doesn't communicate model changes back to the action (e.g., selection changed).
Pushed the action -> model linkage in commit a62fdd23a67f6364cd5668e195b68cf626a4ce0e
Brian, if you want to use a constant for this kind of thing could you make it the FQN of the main consumer class? Thanx, PW
I based the solution on the DISPOSABLE_CHECK in HandledContributionItem.java. I wondered if this DISPOSABLE transient entry might be a pattern to semi-formalize?
Brian is this still an issue ? I've seen that you've done at least one commit here so I'm just hopin' it's fixed...;-).
(In reply to comment #4) > Brian is this still an issue ? I've seen that you've done at least one commit > here so I'm just hopin' it's fixed...;-). It's still an issue: I've only addressed the action-change -> model change side. And there's also addressing a pattern I've kind of copied from elsewhere. When an action is reified as a DirectContributionItem in MenuHelper, a property listener is installed to map action changes to the model. I also stash a runnable in the model element's transient data to be run when the widget is disposed: private void handleWidgetDispose(Event event) { // ... Object obj = model.getTransientData().get(DISPOSABLE); if (obj instanceof Runnable) { ((Runnable) obj).run(); } // ... } It's a useful pattern, though perhaps it should be in the DirectContributionItem#dispose() rather than the widget-dispose. The nice thing is that this listener is *only* called for this particular item. MenuHelper could have installed a listener through the IEventBroker, but it would have been called for all changes on DCIs, right?
Is this something you'd like to address for M7? PW
There's one-part outstanding that I haven't gotten to: > I realize this is just one-half of a solution, since it doesn't > communicate model changes back to the action (e.g., selection changed).
Created bug 378106 to track the propagation of changes to the model -> action.
Verified in I20120503-1800