Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [EMFForms] Get label + control from view model elements as SWT control?
icon5.gif  [EMFForms] Get label + control from view model elements as SWT control? [message #1754599] Mon, 20 February 2017 17:11 Go to next message
Roman Zimmer is currently offline Roman ZimmerFriend
Messages: 27
Registered: November 2010
Junior Member
Hey @ll,

I'm using EMFForms to create the UI for editing domain models and I'm really happy with it! Now I have the requirement to implement a very custom SWT layout. Dangling with custom LayoutProvider and SWTGridDescriptions seem too hard for my use case so I thought, I build up the UI by myself outside the framework and only use labels and controls created by EMFForms. So I wonder if it is somehow "easily" possible to get the rendered SWT label and control of an element defined in the view model with all bindings?

Looking at the documentation I have the impression that it should be possible with EMFFormsLabelProvider and EMFFormsRendererFactory, but I can't seem to find easily to provide all the variables in the provided snippet, in particular vControl and myViewModelElement. Are there helper methods to get them, e.g. by a domain model reference?

Any help is appreciated, thanks a lot in advance!
Re: [EMFForms] Get label + control from view model elements as SWT control? [message #1754632 is a reply to message #1754599] Tue, 21 February 2017 08:19 Go to previous messageGo to next message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 55
Registered: September 2016
Member
Hi Roman,

I wonder how the layout looks like that you want to implement. Have you had a look at control grid? Maybe that is a solution. If not, I would recommend to implement your custom layout renderer. This way, you have a good frame to do any custom layout you want, but you have direct access to all parameters that you need to created embedded elements (i.e. controls).

Best regards
Jonas

--
Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: [EMFForms] Get label + control from view model elements as SWT control? [message #1754637 is a reply to message #1754632] Tue, 21 February 2017 08:54 Go to previous messageGo to next message
Roman Zimmer is currently offline Roman ZimmerFriend
Messages: 27
Registered: November 2010
Junior Member
Hey Jonas,
thanks for your reply! Essentially, the desired layout is basically a grid. I've seen that you can describe grid-based layouts (via VerticalLayout and HorizontalLayout) good enough in the EMFForms view model editor. But I didn't find an easy way to specify vertical and horizontal span, grab excess and preferred sizes for my controls without sub-classing the EMFForms-provided controls or creating custom ones as the SWTGridDescription is not exposed to the view model. Have I missed something? Is there a direct, configurable grid control in EMFForms' view model editor?

Using a layout provider, the only way I see for now is to provide different LayoutData objects in LayoutProvider.getLayoutData() based on EStructuralFeature referenced in the passed VElement, i.e. manage a huge switch-case for every control I want to layout differently. Seems a bit tedious, but feasible. Is this the preferred way to go?

FYI: I'm using EMFForms version 1.11.0.
Re: [EMFForms] Get label + control from view model elements as SWT control? [message #1754787 is a reply to message #1754637] Wed, 22 February 2017 11:53 Go to previous message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 55
Registered: September 2016
Member
Hi,

first: have you had a look at ControlGrid (View Model Element). It is a simplyfied version of a Grid and might fit your requirements.

If not, you have two choices. We implemented both of them for custom project before:
1. Custom Layout element
If you can define a generic pattern in your layouts, let us say you always want to span the last controls in the last column or anything with a pattern, you can implement your own renderer.

2. Implement a custom layout provider
As you already found out, the LayoutProvider is responsible to create the Grid information. A simple case would indeed be to restrict the length on controls. As you also write, it would not be a good solution to do that based on specific features, as your layout provider would be model specific then. Instead, I would define the length EITHER:
In the Ecore model (e.g. using the XSD annotation "mayLength") This option makes sense if the length is actually really a constraint, as it could be validated then, too.
OR
In the view model using an annotation. This option makes sense if the length restriction is a UI concern, only, menaing if you can actually enter more characters, but the control should not grow.

By specifiying the length at one of those two places, you can actually just consume it in the Layout Provider, so you do not need any switch statemenent.

Please note that I would not recommend to specify anything in pixels, but rather in characters. However, you need to calculate the width hint then based on the current display settings.

What I would find interesting is adding the capability of restricting the length to the default layout provider.

Best regards

Jonas

--
Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Previous Topic:[EMF Forms] Working with TransactionalEditingDomain
Next Topic:[EMFForms] Support for Nebula's GeoMap widget
Goto Forum:
  


Current Time: Tue Sep 26 14:46:19 GMT 2017

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

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