|Select renderer in view model [message #1775987]
||Wed, 08 November 2017 21:39
| Hallvard Traetteberg
Registered: July 2009
Location: Trondheim, Norway
I've made a new SWT renderer for editing boolean attributes in a dropdown with false/no and true/yes options. This provides better usability in some cases.|
To use it, you must create a service that gives it priority above the default one. I find this cumbersome, it would be better if you could add a "renderer selection rule" to the control element of the view model, so you avoid the code. Something along the following:
- The renderer implementation is registered using an extension point with, and the datatype it supports is indicated, e.g. EBoolean in my case, as well as a "style" key for selecting it, e.g. "dropDown"
- The control element of the view model has a style key attribute, so you can indicate that you prefer a specific renderer if it is supported by the runtime platform
- Alternatively a control element could support a renderer child element that can both provide the style key, as well as configuration options, e.g. in my whether to use false/true or yes/no labels.
- Having an extensible renderer model element, that can be used for selecting and configuring renderers, will increase the power considerably. So when you create a renderer, you may also add an Ecore model with a RendererConfig subclass with features that allow the renderer to be configured. The instance of this RendererConfig is provided when activating the actual renderer.
I understand there's a balance between simplicity and complexity, but by supporting a renderer sub-element, you don't reduce the simplicity, but increase the power.
|Re: Select renderer in view model [message #1778470 is a reply to message #1775987]
||Thu, 14 December 2017 15:20
| Jonas Helming
Registered: September 2016
again sorry for the late answer.
About your proposals:
1. A declarative tester for renderers (e.g. by attribute type)
We had this in the past, but it turned off to be less flexible than required. We had to add more and more criteria (attribute type, attribute name, velement type). Therefore, we decided to switch to code completly. However, at least for the simple cases, we could add some declaritive ways again. If you want to do so, please open a BR
2. Style Properties
Are you aware of the template model? This is pretty much like CSS for EMF Forms. It allows you to specify style attributes based on selectors. E.g. you could sepcify "dropDownBoolean=true" and then the rendere or the tester would react accordingly. The same is possible based on criteria, e.g. based on the concrete attribute
3. Renderer Hints in the view model
From time to time we add options in the view model as hints for the renderer. We only do this if they are really generic, e.g. "collapsible" for Group. If you have proposals for extending the view model, please report them as BRs. Additionally you can add key/value pairs to the view model in case you wan to add some custom information there.
Please let me know, if you have any follow up questions.
Powered by FUDForum
. Page generated in 0.01692 seconds