[
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
|
Hi,
I already replied on the newsgroup but let me do here as well. You
should not use @Execute for this type of things. Currently there's no
nice solution to the problem but I'd say an addon is the way to go.
public class MyCheckAddon {
@Inject
MApplication app;
public void valueChanged(@Named("my-special-value") String value) {
MDirectMenuItem m = ....;
m.setSelected("A".equals(value));
}
}
I think this request can be one more use case for our Model-Lifecycle
story defined at https://bugs.eclipse.org/bugs/show_bug.cgi?id=392903
Tom
Am 29.12.12 09:54, schrieb Marco Descher:
> 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
> <pwebster@xxxxxxxxxxxxxxxxxxx <mailto:pwebster@xxxxxxxxxxxxxxxxxxx>>:
>
>> On Fri, Dec 28, 2012 at 4:49 PM, Marco Descher <marco@xxxxxxxxxx
>> <mailto: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
>> _______________________________________________
>> e4-dev mailing list
>> e4-dev@xxxxxxxxxxx <mailto:e4-dev@xxxxxxxxxxx>
>> https://dev.eclipse.org/mailman/listinfo/e4-dev
>
>
>
> _______________________________________________
> e4-dev mailing list
> e4-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/e4-dev
>
--
B e s t S o l u t i o n . a t EDV Systemhaus GmbH
------------------------------------------------------------------------
tom schindl geschäftsführer/CEO
------------------------------------------------------------------------
eduard-bodem-gasse 5-7/1 A-6020 innsbruck fax ++43 512 935833
http://www.BestSolution.at phone ++43 512 935834