Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [EMF Forms] How to select specific view model for view(How to define multiple view models for a model element then specify which to use at render time)
[EMF Forms] How to select specific view model for view [message #1746371] Thu, 27 October 2016 16:23 Go to next message
Bob Bobson is currently offline Bob BobsonFriend
Messages: 13
Registered: April 2016
Junior Member
Hi Everyone,

I have defined several view models for one of my model elements. I want to specify which one should actually be used in a view depending on the context, but don't know how best to achieve this.

I can see that the TreeMasterDetail view is effectively doing this. It appears to achieve it by setting properties on the view registration extension point, then also setting properties in the view context.

So i suppose my question breaks down like this:

Is the TreeMasterDetail approach the best way of achieving "selecting" a view model at render time, or are there other approaches?

If so, how exactly are the provided properties used to select which view model to use?

Thanks in advance for your help!
Re: [EMF Forms] How to select specific view model for view [message #1746400 is a reply to message #1746371] Fri, 28 October 2016 07:48 Go to previous message
Eugen Neufeld is currently offline Eugen NeufeldFriend
Messages: 174
Registered: May 2015
Senior Member
Hi Bob,
The way the TreeMasterDetail does this is the easiest one. In this case when you request a View Model using the ViewProviderHelper, you can pass in VViewModelProperties which are basically Key-Value Pairs.
You can pass in multiple such properties and when you register you view models then the one that satisfies most of the properties will be taken.

The alternative would be to provide you own IViewProvider (As an OSGi-Service or register it on an extension point). Here you will have to load/create the view models by yourself and return the correct one based on the passed in EObject and VViewModelProperties.
I would only recommend to do this, if you want to filter your view models based on some attribute value, so in a dynamic way.

Cheers,
Eugen


--
Eugen Neufeld

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Previous Topic:[TEXO][ACCELEO] Web-form Vaadin editor for Texo JPA classes
Next Topic:EMF Forms RAP application with texo json webservice
Goto Forum:
  


Current Time: Fri Mar 29 10:23:37 GMT 2024

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

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

Back to the top