Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Xcore] Proposed way of adding adapters to new instances
[Xcore] Proposed way of adding adapters to new instances [message #1735978] Fri, 24 June 2016 07:52 Go to next message
Alexander Aumann is currently offline Alexander AumannFriend
Messages: 8
Registered: October 2015
Junior Member
Hey there,

for the following simplified model:

class Property {
  boolean required
  refers PropertyAssignment[*] assignments opposite propType
}
class PropertyAssignment {
   refers Property propType opposite assignments
   String assignedValue
}


I would like to add an adapter such that a change to the references property's required-attribute triggers re-validation of a PropertyAssignment object.

Is there any way to add an adapter (e.g. at construction time) to every Property object in the xcore model? Or is the only way, as I expect from the sources I found, to adapt the generated code. I would like to avoid that as one of the benefits of xcore is, imho, that I can keep the generated code completely clean of customizations.

Kind regards,
Alexander
Re: [Xcore] Proposed way of adding adapters to new instances [message #1736005 is a reply to message #1735978] Fri, 24 June 2016 10:40 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Alexander,

The generated editor supports live validation. It's simply triggered by
listening to the command stack. Just set the GenModel's Decoration
property to Live in the Properties view (in the Xcore editor, with the
package selected) to enable this.


On 24.06.2016 03:53, Alexander Aumann wrote:
> Hey there,
>
> for the following simplified model:
>
>
> class Property {
> boolean required
> refers PropertyAssignment[*] assignments opposite propType
> }
> class PropertyAssignment {
> refers Property propType opposite assignments
> String assignedValue
> }
>
>
> I would like to add an adapter such that a change to the references
> property's required-attribute triggers re-validation of a
> PropertyAssignment object.
>
> Is there any way to add an adapter (e.g. at construction time) to
> every Property object in the xcore model? Or is the only way, as I
> expect from the sources I found, to adapt the generated code. I would
> like to avoid that as one of the benefits of xcore is, imho, that I
> can keep the generated code completely clean of customizations.
>
> Kind regards,
> Alexander


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [Xcore] Proposed way of adding adapters to new instances [message #1736010 is a reply to message #1736005] Fri, 24 June 2016 11:51 Go to previous messageGo to next message
Alexander Aumann is currently offline Alexander AumannFriend
Messages: 8
Registered: October 2015
Junior Member
Thanks for the fast reply.

However, I am not using the generated editor as I use EMF-forms for rendering (on e4 rap - so I cannot even include org.eclipse.ui.workbench which I understand is a dependency of the generated editor).

It might of course be possible to use something along the lines of live validation for the use case I described (though I don't know if that would be easy to integrate with EMF-forms) .

My current approach is using something close to the DerivedAttributeAdapter recipe to trigger re-validation of the "dependent" value.

I assume there is no way to this with xcore? And if I need to edit the generated code is there a "best practice way" of where to place the code (constructor, factory)?
Re: [Xcore] Proposed way of adding adapters to new instances [message #1736013 is a reply to message #1736010] Fri, 24 June 2016 12:12 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Alexander,

Comments below.


On 24.06.2016 07:51, Alexander Aumann wrote:
> Thanks for the fast reply.
>
> However, I am not using the generated editor as I use EMF-forms for
> rendering (on e4 rap - so I cannot even include
> org.eclipse.ui.workbench which I understand is a dependency of the
> generated editor).
You can still use the same underlying mechanisms as used in the
generated editor...
>
>
> It might of course be possible to use something along the lines of
> live validation for the use case I described (though I don't know if
> that would be easy to integrate with EMF-forms) .
That's an EMF forms question...
>
> My current approach is using something close to the
> DerivedAttributeAdapter
> http://wiki.eclipse.org/EMF/Recipes#Recipe:_Derived_Attribute_Notifier
> to trigger re-validation of the "dependent" value.
I don't see why you'd need to do something special like that.
>
> I assume there is no way to this with xcore? And if I need to edit the
> generated code is there a "best practice way" of where to place the
> code (constructor, factory)?
I'm not sure why you need to do anything special. What currently
triggers revalidation with EMF Forms? I imagine a command stack is
still used and you could listen to commands being executed to know when
the model changes and it needs revalidation.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [Xcore] Proposed way of adding adapters to new instances [message #1736409 is a reply to message #1736013] Wed, 29 June 2016 10:13 Go to previous message
Alexander Aumann is currently offline Alexander AumannFriend
Messages: 8
Registered: October 2015
Junior Member
Thanks Ed,

I will use the model listeners already provided for rendered models. I just would have liked the possibility to add an adapter, I guess Smile

However, I can do that from the outside just the same, so I guess I was just looking at it with a limited view of possible solutions.
Previous Topic:Setting EReference
Next Topic:[Xcore] Invariant code referencing XXXValidator constants
Goto Forum:
  


Current Time: Wed Apr 24 23:05:01 GMT 2024

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

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

Back to the top