Validate property constraints before/after setting a value

I'm currently trying to build a Swing-based editor that is using tables to render and edit properties. The properties are of a constrained data type. Unlike the regular editor (with collections), which displays invalid property values in red, using "set" with an invalid value will just save it, with no feedback whatsoever. Is there a way to check whether the string constraint is satisified before or after saving, so the editor won't save invalid values or will render them in red? I'm attaching screenshots of my getter/setter code and the resulting editor for reference.



1
1 comment

Unfortunately, now there are no options to check that value is valid for a particular property neither through smodel language nor public API. But we currently working on it.
Now the only way to do it is to use 'jetbrains.mps.smodel.PropertySupport' instance:

SProperty property = property/WorkInterval : description/;
boolean isValid = PropertySupport.getPropertySupport(property).canSetValue(node, property, value);
0

Please sign in to leave a comment.