Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Defining scpecific references?
Defining scpecific references? [message #625778] Wed, 22 September 2010 10:26 Go to next message
Ralph P is currently offline Ralph PFriend
Messages: 30
Registered: September 2010
Location: Frankfurt, Germany
Member
Hello,

I'm working on a generic client, based on a XML configuration file. I started with an XSD model and generated a model editor with EMF.
In my meta model there are so called 'ActionDescriptors' which contain a sequence of 'ToolDescriptors'. For reusing purposes I want to offer the possibility to override some 'Parameter' attributes of a ToolDescriptor in relationship to an ActionDescriptor. Whad I did was referencing the 'Parameter' type in an 'ParameterOverride' class. This works, but the model editor shows me a list of ALL parameters, not only these of the referenced ToolDescriptor.

Is there a way to specify the reference more accurate? Just like X-Path expressions?

Sure I could do this by editing the code of the generated edit-PlugIn, but something says me that I can simply define it in the Ecore-editor or even my XSD.

Thank you in anticipation!

[Updated on: Wed, 22 September 2010 10:58]

Report message to a moderator

Re: Defining scpecific references? [message #627883 is a reply to message #625778] Thu, 23 September 2010 06:21 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30544
Registered: July 2009
Senior Member
Ralph,

Comments below.

Ralph wrote:
> Hello,
>
> I'm working on a generic client, based on a XML configuration file. I
> started with an XSD model and generated an model editor with EMF.
> In my meta model there are so called 'ActionDescriptors' which contain
> a sequence of 'ToolDescriptors'. For reusing purposes I want to offer
> the possibility to override some 'Parameter' attributes of a
> ToolDescriptor in relationship to an ActionDescriptor. Whad I did was
> referencing the 'Parameter' type in an 'ParameterOverride' class. This
> works, but the model editor shows me a list of ALL parameters, not
> only these of the referenced ToolDescriptor.
>
> Is there a way to specify the reference more accurate? Just like
> X-Path expressions?
>
> Sure I could do this by editing the code of the generated edit-PlugIn,
> but something says me that I can simply define it in the Ecore-editor
> or even my XSD.
In schema one could make use of keyrefs, but Ecore has nothing that
corresponds to that. Editing the generated item provider's property
descriptor is the most direct way to limit what's available to the user.
>
> Thank you in anticipation!
Re: Defining scpecific references? [message #628149 is a reply to message #625778] Thu, 23 September 2010 09:36 Go to previous messageGo to next message
Ralph P is currently offline Ralph PFriend
Messages: 30
Registered: September 2010
Location: Frankfurt, Germany
Member
Thanks for the hint, Ed! But this seems to be a lot more tricky than I thought!
The only two interesting classes which are used to create an ItemPropertyDescriptor are "ComposedAdapterFactory" and "EStructuralFeature" (see below), which will be an EReference in my case (subclass). The other parameters are genmodel options. Do I really have to set up an own item provider adapter factory (implementing ComposeableAdapterFactory)?

Here's the method which creates an ItemPropertyDescriptor:
// In the EMF implementation 'AdapterFactory' will be casted into 'ComposedAdapterFactory'
protected ItemPropertyDescriptor createItemPropertyDescriptor(AdapterFactory adapterFactory,
                                                              ResourceLocator resourceLocator,
                                                              java.lang.String displayName,
                                                              java.lang.String description,
                                                              EStructuralFeature feature,
                                                              boolean isSettable,
                                                              boolean multiLine,
                                                              boolean sortChoices,
                                                              java.lang.Object staticImage,
                                                              java.lang.String category,
                                                              java.lang.String[] filterFlags)
Re: Defining scpecific references? [message #628245 is a reply to message #628149] Thu, 23 September 2010 10:43 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30544
Registered: July 2009
Senior Member
Ralph,

No, you'd override the AbcItemProvider.addFooPropertyDescriptor. See
ETypedElementItemProvider.addETypePropertyDescriptor as an example.


Ralph wrote:
> Thanks for the hint, Ed! But this seems to be a lot more tricky than I
> thought!
> The only two interesting classes which are used to create an
> ItemPropertyDescriptor are "ComposedAdapterFactory" and
> "EStructuralFeature" (see below), which will be an EReference in my
> case (subclass). The other parameters are genmodel options. Do I
> really have to set up an own item provider adapter factory
> (implementing ComposeableAdapterFactory)?
>
> Here's the method which creates an ItemPropertyDescriptor:
>
> // In the EMF implementation 'AdapterFactory' will be casted into
> 'ComposedAdapterFactory'
> protected ItemPropertyDescriptor
> createItemPropertyDescriptor(AdapterFactory adapterFactory,
>
> ResourceLocator resourceLocator,
>
> java.lang.String displayName,
>
> java.lang.String description,
>
> EStructuralFeature feature,
> boolean
> isSettable,
> boolean
> multiLine,
> boolean
> sortChoices,
>
> java.lang.Object staticImage,
>
> java.lang.String category,
>
> java.lang.String[] filterFlags)
Re: Defining scpecific references? [message #628647 is a reply to message #625778] Thu, 23 September 2010 14:24 Go to previous message
Ralph P is currently offline Ralph PFriend
Messages: 30
Registered: September 2010
Location: Frankfurt, Germany
Member
Wow thanks, it works great now! Although it took me some time to figure out what I have to customize.


For those who also have this Problem:

I got me the ETypedElementItemProvider source from an Open Source web page, copied the addETypePropertyDescriptor (...) method it into my XyzItemProvider and edited it. Instead of deleting every Object that's in the "results" ArrayList, I created a new one and returned that one.
Luckily there's a getParent(Object object) mehtod you can use while overriding the getChoiceOfValues(...) method, making it easy to find the values you want.

Finally you need to override the setPropertyValue(...) method so your selection in the model editor will be applied. For me, some simple modification did the job (see below).

                    @Override
                    public void setPropertyValue(Object object, Object value) {
                        EditingDomain editingDomain = getEditingDomain(object);
                        if (editingDomain == null) {
                            super.setPropertyValue(object, value);
                        } else {

                            editingDomain
                                    .getCommandStack()
                                    .execute(
                                            SetCommand
                                                    .create(
                                                            editingDomain,
                                                            object,
                                                            MyPackage.Literals.RACTION_PARM_FROM_OVERRIDE__PARM_TO_OVERRIDE, // selected property
                                                            value));
                        }
                    }
Previous Topic:[CDO/Net4j] how to use PostgreSQL driver support?
Next Topic:how to verify object on object change(setter called)
Goto Forum:
  


Current Time: Tue Oct 15 10:53:07 GMT 2019

Powered by FUDForum. Page generated in 0.02067 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top