[EMF Forms] How to programmatically access widget's properties [message #1695168] |
Tue, 12 May 2015 12:44 |
Volker Fervers Messages: 15 Registered: March 2015 |
Junior Member |
|
|
Hello!
I'm trying to become familiar with EMF/ECP/EMF Forms. I read in a file with XMI data (ComposedAdapterFactory, BasicCommandStack, ResourceSet, AdapterFactoryEditingDomain, Resource) to display a tree with the data in a Part. Clicking on an EObject of the Tree transfers this selection via the selectionService to another Part, where I show the properties powered by EMF Forms:
final ViewModelContext vmc = ViewModelContextFactory.INSTANCE.createViewModelContext(ViewProviderHelper.getView(eObj, null), eObj, new DefaultReferenceService());
ECPSWTViewRenderer.INSTANCE.render(content, vmc);
Now I can alter the properties in the created UI. My question is:
How can I programatically access these (altered) properties?
The tutorial "EMF Forms: A Question of Effort" states in Paragraph "Faster?" : "In the case of EMF Forms, the renderer takes over this task. Controls are not only bound to the data model, they also provide additional functionality". So I'm quite sure, that there must be a way to read and store the changes .
Thanks for your time!
GV
|
|
|
Re: [EMF Forms] How to programmatically access widget's properties [message #1695266 is a reply to message #1695168] |
Wed, 13 May 2015 07:06 |
Jonas Helming Messages: 699 Registered: July 2009 |
Senior Member |
|
|
Hi,
I am not sure, if I understand the question correctly. By default, the
changes are directly written to the data model.
Best regards
Jonas
Am 12.05.2015 um 14:44 schrieb Volker Fervers:
> Hello!
>
> I'm trying to become familiar with EMF/ECP/EMF Forms. I read in a file
> with XMI data (ComposedAdapterFactory, BasicCommandStack, ResourceSet,
> AdapterFactoryEditingDomain, Resource) to display a tree with the data
> in a Part. Clicking on an EObject of the Tree transfers this selection
> via the selectionService to another Part, where I show the properties
> powered by EMF Forms:
>
>
> final ViewModelContext vmc =
> ViewModelContextFactory.INSTANCE.createViewModelContext(ViewProviderHelper.getView(eObj,
> null), eObj, new DefaultReferenceService());
>
> ECPSWTViewRenderer.INSTANCE.render(content, vmc);
>
>
> Now I can alter the properties in the created UI. My question is:
>
> How can I programatically access these (altered) properties?
>
> The tutorial "EMF Forms: A Question of Effort" states in Paragraph
> "Faster?" : "In the case of EMF Forms, the renderer takes over this
> task. Controls are not only bound to the data model, they also provide
> additional functionality". So I'm quite sure, that there must be a way
> to read and store the changes :).
>
> Thanks for your time!
> GV
--
Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
|
|
|
|
|
Re: [EMF Forms] How to programmatically access widget's properties [message #1696675 is a reply to message #1695609] |
Wed, 27 May 2015 19:59 |
Volker Fervers Messages: 15 Registered: March 2015 |
Junior Member |
|
|
Hello again .*!
Neither the EObject nor the resource as a whole reflect the changes. The corresponding setName-Methods of the altered objects are not called on focus lost of the input fields which they do when I don't use an XMI file as data source but create a dummy object.
Obviously I'm doing something wrong. Sadly searching the web didn't let me find an example known to work.
Thank you for your help!
GV
My EMF initializing code goes as follows:
private EMFInit() {
PhiPackage.eINSTANCE.eClass();
caf = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
caf.addAdapterFactory(new ResourceItemProviderAdapterFactory());
caf.addAdapterFactory(new PhiItemProviderAdapterFactory());
caf.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
bcs = new BasicCommandStack();
rs = new ResourceSetImpl();
rs.getPackageRegistry().put(PhiPackage.eNS_URI, PhiPackage.eINSTANCE);
rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
Resource.Factory.Registry.DEFAULT_EXTENSION,
new XMIResourceFactoryImpl());
ed = new AdapterFactoryEditingDomain(caf, bcs, rs);
r = ed.createResource("file:///home/volker/.data/data.phi");
try {
r.load(null);
} catch (final IOException ex) {
// TODO Auto-generated catch block
ex.printStackTrace();
}
}
The TreeViewer's relevant code (Tree in a left part, form on the right):
public void init() {
final EMFInit emfInit = EMFInit.getInstance();
final ComposedAdapterFactory caf = emfInit.getComposedAdapterFactory();
final Resource r = emfInit.getResource();
setContentProvider(new AdapterFactoryContentProvider(caf));
setLabelProvider(new AdapterFactoryLabelProvider(caf));
final Organisation eObj = (Organisation) r.getContents().get(0);
setInput(eObj);
}
And the FormPart:
@Inject
public void receiveSelection(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) EObject eObj) {
if (eObj != null) {
eventBroker.post("Phi/selectedEObject", eObj);
// final Person p = PhiFactory.eINSTANCE.createPerson();
// p.setVorname("Johann");
// eObj = p;
for (final Control c : content.getChildren()) {
c.dispose();
}
try {
final ViewModelContext vmc = ViewModelContextFactory.INSTANCE.createViewModelContext(
ViewProviderHelper.getView(eObj, null),
eObj,
new DefaultReferenceService());
ECPSWTViewRenderer.INSTANCE.render(content, vmc);
content.layout();
} catch (final ECPRendererException ex) {
ex.printStackTrace();
}
content.getParent().layout();
}
}
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02283 seconds