Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » "Persistence" of RADIO and CHECK MenuItems
"Persistence" of RADIO and CHECK MenuItems [message #994625] Thu, 27 December 2012 16:46 Go to next message
Marco Descher is currently offline Marco Descher
Messages: 75
Registered: October 2010
Location: Austria
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 06: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 13:32 Go to previous messageGo to next message
Marco Descher is currently offline Marco Descher
Messages: 75
Registered: October 2010
Location: Austria
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 04:25 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5286
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!
Re: "Persistence" of RADIO and CHECK MenuItems [message #995309 is a reply to message #995177] Sat, 29 December 2012 13:16 Go to previous message
Marco Descher is currently offline Marco Descher
Messages: 75
Registered: October 2010
Location: Austria
Member
Thanks a lot for your help Tom. For the interested reader; besides of the information here the discussion is also made in the e4-dev mailing list, see http://dev.eclipse.org/mhonarc/lists/e4-dev/msg07072.html
Previous Topic:E4 with Spring remoting integration problem
Next Topic:Eclipse Juno error
Goto Forum:
  


Current Time: Sat Aug 23 15:49:13 EDT 2014

Powered by FUDForum. Page generated in 0.02557 seconds