|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
| Jonas Helming
Registered: September 2016
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.
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.
Get professional Eclipse developer support:
Powered by FUDForum
. Page generated in 0.02356 seconds