Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [EMF Forms] Iterating over properties
[EMF Forms] Iterating over properties [message #1757858] Mon, 20 March 2017 19:37 Go to next message
Alex Kravets is currently offline Alex KravetsFriend
Messages: 528
Registered: November 2009
Senior Member
Hi,

I'd like to use EMF Forms to render the following XML

<properties>
   <group="1">
     <property name="g1p1"/>
     <property name="g1p2"/>
     <property name="g1p3"/>
   </group>
  <group="2">
     <property name="g2p1"/>
     <property name="g2p2"/>
     <property name="g2p3"/>
   </group>
</properties>


What I'd like to do is render form in a such a way that properties element is iterated and groups with its property elements are rendered in sections. Do I need to create three different renders (properties, groups, property) and embed one in another? Or is there better design pattern for this?

Thanks,
Alex

[Updated on: Mon, 03 April 2017 14:53]

Report message to a moderator

Re: [EMF Forms] [message #1757865 is a reply to message #1757858] Mon, 20 March 2017 21:16 Go to previous messageGo to next message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 81
Registered: September 2016
Member
Hi,

if I understand you corretcly, you want to process the domain model to actually create the layout of the UI based on that. There are two ways to do that. Either you create a renderer for the "properties" element, which renders all sub elements like you wish. alternativly, you could derive a view model from your domain model which describes the desired layout. In this case, you can define dedicated renderers for all elements.

Best regards
Jonas

--
Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/


--
Jonas Helming
Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: [EMF Forms] [message #1757870 is a reply to message #1757865] Tue, 21 March 2017 01:43 Go to previous messageGo to next message
Alex Kravets is currently offline Alex KravetsFriend
Messages: 528
Registered: November 2009
Senior Member
Thanks Jonas,

When you say
Quote:

Alternatively, you could derive a view model from your domain model which describes the desired layout. In this case, you can define dedicated renderers for all elements.

How do I describe iteration over these renderers in View Model? It looks like these renderers would need to be called in nested loops?

Alex

Re: [EMF Forms] [message #1757871 is a reply to message #1757865] Tue, 21 March 2017 01:43 Go to previous messageGo to next message
Alex Kravets is currently offline Alex KravetsFriend
Messages: 528
Registered: November 2009
Senior Member
Thanks Jonas,

Quote:

Alternatively, you could derive a view model from your domain model which describes the desired layout. In this case, you can define dedicated renderers for all elements.

How do I describe iteration over these renderers in View Model? It looks like these renderers would need to be called in nested loops?

Alex

Re: [EMF Forms] [message #1757899 is a reply to message #1757871] Tue, 21 March 2017 14:25 Go to previous messageGo to next message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 81
Registered: September 2016
Member
The iteration will be done by the renderer of the container renderer. That is what existing container renderer do already. Have a look at an example renderer, e.g. group. It iterates over its children elements.

Best regards

Jonas


--
Jonas Helming
Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: [EMF Forms] [message #1757900 is a reply to message #1757899] Tue, 21 March 2017 14:34 Go to previous messageGo to next message
Alex Kravets is currently offline Alex KravetsFriend
Messages: 528
Registered: November 2009
Senior Member
Great, thank you!
Re: [EMF Forms] [message #1757994 is a reply to message #1757900] Wed, 22 March 2017 15:42 Go to previous messageGo to next message
Alex Kravets is currently offline Alex KravetsFriend
Messages: 528
Registered: November 2009
Senior Member
To create Renderer for Properties element would I reference org.eclipse.emf.ecp.makeithappen.view.email.renderer and use SimpleControlSWTControlSWTRenderer to base my Renderer off?
Re: [EMF Forms] [message #1758015 is a reply to message #1757994] Wed, 22 March 2017 18:30 Go to previous messageGo to next message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 81
Registered: September 2016
Member
If you go for the approach to create a view model based on your business first, then you should use a container renderer (the one the the group example inherits from)

best regards

Jonas


--
Jonas Helming
Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: [EMF Forms] [message #1758112 is a reply to message #1758015] Thu, 23 March 2017 16:21 Go to previous messageGo to next message
Alex Kravets is currently offline Alex KravetsFriend
Messages: 528
Registered: November 2009
Senior Member
Thanks Jonas, this worked.
Re: [EMF Forms] [message #1758832 is a reply to message #1758112] Mon, 03 April 2017 15:13 Go to previous messageGo to next message
Alex Kravets is currently offline Alex KravetsFriend
Messages: 528
Registered: November 2009
Senior Member
I am still trying to wrap my head around EMF Forms and wondering if it's correct tool for my particular case. As I understand EMF Forms works best to represent what model has, but what if the model elements are not known in advance? What I mean is that I have an object that has no properties in the beginning, user selects type of properties this object will have and fills out the details (by selecting element from combo box different set of properties are presented); the properties that object can have come from a properties descriptor file:

http://i.imgur.com/XIneFCu.png

As per Jonas' suggestion I extended ContainerSWTRenderer<VGroup> class, but now it looks like I am not taking advantage of EMF Forms at all, because everything is pretty much custom - the combo box, the listener to generate form based on the selection and most of all I don't have the data-binding that EMF Forms creates between model and forms that it generates. So perhaps EMF Forms is not the best solution for my particular case?

[Updated on: Mon, 03 April 2017 15:13]

Report message to a moderator

Re: [EMF Forms] [message #1758886 is a reply to message #1758832] Tue, 04 April 2017 07:25 Go to previous message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 81
Registered: September 2016
Member
Hi,

without knowing the detail about your use case:

Even if you only use custom renderers, using EMF Forms is typically an advantage. You should have a defined renderer now ideally with a custom view model element. Now you can reuse this and you can adapt the renderer at a central place. Further, you can embedd it and use it in combination with other view model elements. If you know for sure, that your view will always only show the custom content, that you never adapt it again and you will never use it anywhere else then yes, in this unlikely case EMF Forms does not really provide an advantage.

Best regards
Jonas

--
Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/


--
Jonas Helming
Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Previous Topic: [EMF Forms] Multiple views of a model class with e4
Next Topic:[EMF Forms] Multiple views for one type
Goto Forum:
  


Current Time: Fri Nov 16 02:55:24 GMT 2018

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

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

Back to the top