"Persistence" of RADIO and CHECK MenuItems [message #994625] |
Thu, 27 December 2012 21:46 |
Marco Descher Messages: 197 Registered: October 2010 Location: Austria |
Senior Member |
|
|
I am currently trying to figure out how to correctly apply MenuItems of type RADIO and CHECK. Meaning, I want to initialize them according to some state I have in my application and naturally want to synchronize this.
It is no problem to handle selections and get them into my code, but what is the official way I have to do this?
An example:
I have a filter defined on Persons where RADIO is either MALE or FEMALE according to the selection stored in the system. How and where in the application model am I supposed to set the initial sychronization of the filter configuration to the options presented in the menu? A processor? A handler? Same counts for the CHECK elements!
thanks!
[Updated on: Fri, 28 December 2012 11:50] Report message to a moderator
|
|
|
Re: "Persistence" of RADIO and CHECK MenuItems [message #994962 is a reply to message #994625] |
Fri, 28 December 2012 18:32 |
Marco Descher Messages: 197 Registered: October 2010 Location: Austria |
Senior Member |
|
|
I am currently trying a different approach: I have an element of type DirectMenuItem, with a defined Class Uri. In the respective class Uri file I have a method with @PostConstruct annotation, which is called just when the MenuItem is instantiated somwhere. Generally this should do the trick, but the problem is, that I don't seem to get MMenuElement injected within the methods signature.
Interesting is the following fact:
I have one instance of DirectMenuItem within the Applications Main Menu, and one within a ViewPart menu, both pointing to the same class Uri. If I change the injection to MUIElement I get injected a TrimmedWindow and Part element respectively?!
Why is that, why can't I simply get the DirectMenuItem I am looking for, especially, as even when querying the MApplication Model (changing the injection of the method) I am not able to find the DirectMenuItem from the EModelService providing MApplication!
|
|
|
Re: "Persistence" of RADIO and CHECK MenuItems [message #995177 is a reply to message #994962] |
Sat, 29 December 2012 09:25 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
Hi,
I don't think that there's currently a good way to do it. In case of a
direct menu-item you could use DI inside your Handler
@Inject
public void valueChanged(@Named("my-global-state")String value) {
}
but I'd consider this a bad solution because it won't work if you use
command/handlers because there's not 1:1 relation to the menu-item.
The other option is to use an addon and there do the injection of your
state and modify the selection of the element - this i'd consider the
better solution.
I think this could be one more good use case for
https://bugs.eclipse.org/bugs/show_bug.cgi?id=392903.
The reason you only get the Window/Part is that DirectMenuItem is not of
type MContext and so there's no context created for it and we can
naturally only push on MUIElement into the context of Window/Part.
The reason you can't find it through the EModelService is explained and
discussed https://bugs.eclipse.org/bugs/show_bug.cgi?id=383403 I think
especially comment 15 is interesting in the way that if you query for
MDirectMenuItem we could do a deeper search!
Tom
Am 28.12.12 19:32, schrieb Marco Descher:
> I am currently trying a different approach: I have an element of type
> DirectMenuItem, with a defined Class Uri. In the respective class Uri
> file I have a method with @PostConstruct annotation, which is called
> just when the MenuItem is instantiated somwhere. Generally this should
> do the trick, but the problem is, that I don't seem to get MMenuElement
> injected within the methods signature.
> Interesting is the following fact:
>
> I have one instance of DirectMenuItem within the Applications Main Menu,
> and one within a ViewPart menu, both pointing to the same class Uri. If
> I change the injection to MUIElement I get injected a TrimmedWindow and
> Part element respectively?!
> Why is that, why can't I simply get the DirectMenuItem I am looking for,
> especially, as even when querying the MApplication Model (changing the
> injection of the method) I am not able to find the DirectMenuItem from
> the EModelService providing MApplication!
|
|
|
|
Powered by
FUDForum. Page generated in 0.01919 seconds