Hello Paul, thanks for your answer! No, the problem is not, that the model item is not in sync with the GUI.
Let me explain it with an example Assume I have a filter for a viewer with a DirectMenuItem "Filter Male" of type CHECK. Now during startup I need to synchronize the state of my filter class with the state of the DirectMenuItem (isSelected). If I do not do that, the DirectMenuItem may show isSelected: true while FilterMale is set to false. So I have to set the DirectMenuItem state according to the initial setting of the filter or vice versa. The sychronization I hence talk about is between the application model and my code! So, what and where is the correct e4 style way to do this initial synchronization? In the handler? In a processor? In the part with the viewer? Suppose a the handler (i.e. classURI for DirectMenuItem): At @Execute it is to late, as the item is already presented. It could be handled by @CanExecute, this, however, is called everytime the MenuItem is shown (it however solves the problem). So I thought about @PostConstruct as i is called only once on instantiation and would be a perfect fit to execute the synchronization. This is for DirectMenuItem, for HandledMenuItems I see that in Eclipse 3.x there was a state available to a command which conveyed this information (see http://blog.eclipse-tips.com/2009/03/commands-part-6-toggle-radio-menu.html). But generally the same question arises. Thanks, marco Am 29.12.2012 um 00:57 schrieb Paul Webster <[email protected]>: > On Fri, Dec 28, 2012 at 4:49 PM, Marco Descher <[email protected]> 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 > _______________________________________________ > e4-dev mailing list > [email protected] > https://dev.eclipse.org/mailman/listinfo/e4-dev
_______________________________________________ e4-dev mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/e4-dev
