Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [EMFForms] How to access an EObject whose EStructuralFeature is being edited
[EMFForms] How to access an EObject whose EStructuralFeature is being edited [message #1705963] Thu, 20 August 2015 13:07 Go to next message
Radoslaw Stachowiak is currently offline Radoslaw StachowiakFriend
Messages: 3
Registered: November 2014
Junior Member
Hi

I have a model similar to the following:
class A {
    SomeType value;
    AnotherType context;
}
class B {
    A a1;
    A a2;
}

I generate editor with EMFForms for instance of class B and have defined a custom renderer for feature A.value. However, the behavior of the renderer depends on the contents of A.context field. This means, that my renderer needs access to the exact instance of A (either a1 or a2) that this renderer is editing.
In EMFForms 1.5 this was simple. getViewModelContext().getDomainModel() in renderer contains exactly what I needed.
In EMFForms 1.6 that same call always returns instance of B.
My question is: Is there a simple way to access the instance of object being edited in renderer (a1 or a2 in this case)? And I can't use TreeMasterDetail here, because all controls must be visible on screen at the same time. I can think of a couple solutions, but they will probably have a very high chance of stopping working in next EMFForms release.

Best regards
Radek Stachowiak
Re: [EMFForms] How to access an EObject whose EStructuralFeature is being edited [message #1706024 is a reply to message #1705963] Fri, 21 August 2015 08:03 Go to previous messageGo to next message
Eugen Neufeld is currently offline Eugen NeufeldFriend
Messages: 174
Registered: May 2015
Senior Member
Hi Radek,
In EMFForms 1.6 we introduced an EMFFormsDatabinding Service.
You can retrieve the currently edited instance in a renderer using it:
final IObservableValue observableValue =getModelValue();
//final EStructuralFeature structuralFeature = (EStructuralFeature) observableValue.getValueType();
final EObject eObject = (EObject) ((IObserving) observableValue).getObserved();


The reason for the more "ugly" code is our attempt to make the emfforms renderer more independent of EMF as a data model.

Cheers,
Eugen


--
Eugen Neufeld

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: [EMFForms] How to access an EObject whose EStructuralFeature is being edited [message #1706043 is a reply to message #1706024] Fri, 21 August 2015 11:11 Go to previous message
Radoslaw Stachowiak is currently offline Radoslaw StachowiakFriend
Messages: 3
Registered: November 2014
Junior Member
Hi

Thanks for the reply.
I also found this solution in one of EMFForms classes Smile

Radek
Previous Topic:[Texo] Annotation to set EAttribute for no-NULL
Next Topic:Aird from Ecore Model
Goto Forum:
  


Current Time: Fri Apr 26 09:42:23 GMT 2024

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

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

Back to the top