Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [e4-dev] DirectMenuItem and HandledMenuItem with style CHECK or RADIO

On Fri, Dec 28, 2012 at 4:49 PM, Marco Descher <marco@xxxxxxxxxx> wrote:
I have problems understanding the concept of state synchronization of the application model with my code for DirectMenuItems and HandledMenuItems of type CHECK or RADIO.

The problem is as follows:

I populate a Menu with either Direct or HandledMenuItems and except their selection states (in CHECK or RADIO) style to be according to my code. The problem is that I can't figure
out how to realize this.

I'm not sure I follow you.  Are you saying that if you modify the checked model item, it's not reflected in the GUI?

You can't depend on anything in a  @PostConstruct with handler contributions (handlers for commands or direct contributions) that isn't available in the global application context.  And we recommend not to use @Inject with handlers in general.

Instead, you should be able to ask for an MMenuItem in your execute(*) method.  See org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.getStaticContext(Event) and org.eclipse.e4.ui.workbench.renderers.swt.DirectContributionItem.getStaticContext(Event) for how the model element is supposed to be made available to the @Execute or @CanExecute.


PW


--
Paul Webster
Hi floor.  Make me a sammich! - GIR

Back to the top