How to provide default values for required fields? [message #1066928] |
Fri, 05 July 2013 03:43  |
Eclipse User |
|
|
|
I've created a genmodel from an xsd file that contains boolean and integer values. When I run the generated plugin than the boolean and integer fields display "false" or "0" respectively.
However when I validate the model, than the validation fails saying that those fields have not yet been set although they display those values.
How can I specify default values for such fields or how can I make these fields not display any value at all until the user has really choosen a value?
Thank you, Thomas Koch
|
|
|
Re: How to provide default values for required fields? [message #1067033 is a reply to message #1066928] |
Fri, 05 July 2013 10:16  |
Eclipse User |
|
|
|
Thomas,
Comments below.
On 05/07/2013 2:39 PM, Thomas Koch wrote:
> I've created a genmodel from an xsd file that contains boolean and
> integer values. When I run the generated plugin than the boolean and
> integer fields display "false" or "0" respectively.
>
> However when I validate the model, than the validation fails saying
> that those fields have not yet been set although they display those
> values.
Probably those features are unsettable and must be explicitly set...
>
> How can I specify default values for such fields or how can I make
> these fields not display any value at all until the user has really
> choosen a value?
The problem is they're primitives so there is always a value in Java,
and the properties view is not a very helpful API so there's no really
nice way to distinguish how it looks when there is intrinsic default
value verses a value that has been explicitly set; worse still, it
doesn't like to let you set a value equal to the string representation
that's already present. One approach would be to specialize the
property editor so that something like "<unset>" is displayed when the
feature has eIsSet false but then you have to support parsing that too...
http://wiki.eclipse.org/EMF/Recipes#Recipe:_Create_your_own_property_editor_in_a_generated_application
>
> Thank you, Thomas Koch
|
|
|
Powered by
FUDForum. Page generated in 0.05768 seconds