Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsDecimal precision for eStructuralFeatures
https://www.eclipse.org/forums/index.php/mv/msg/369613/902333/#msg_902333
<eStructuralFeatures xsi:type="dict:EAttributeParameter" name="toControl" eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//Decimal">
Also, can one indicate the precision (e.g. 2 decimals)?
Thanks in advance!]]>Al B2012-08-17T06:39:34-00:00Re: Decimal precision for eStructuralFeatures
https://www.eclipse.org/forums/index.php/mv/msg/369613/902341/#msg_902341
Yes, with extended metadata annotations on an EDataType you can specify
the number of fractional digits as in XML Schema http://www.w3.org/TR/xmlschema-2/#rf-fractionDigits
On 17/08/2012 8:39 AM, AJ Ben wrote:
> Is it possible declare the eType of an eStructuralFeatures as decimal?
> Will this be valid?
>
> <eStructuralFeatures xsi:type="dict:EAttributeParameter"
> name="toControl" eType="ecore:EDataType
> http://www.eclipse.org/emf/2003/XMLType#//Decimal">
>
> Also, can one also indicate the precision (e.g. 2 decimals)?
>
> Thanks in advance!]]>Ed Merks2012-08-17T08:04:48-00:00Re: Decimal precision for eStructuralFeatures
https://www.eclipse.org/forums/index.php/mv/msg/369613/902473/#msg_902473
Do you mean doing something like this?
On 8/17/12 1:04 AM, Ed Merks wrote:
> AJ,
>
> Yes, with extended metadata annotations on an EDataType you can specify
> the number of fractional digits as in XML Schema
> http://www.w3.org/TR/xmlschema-2/#rf-fractionDigits
>
>
> On 17/08/2012 8:39 AM, AJ Ben wrote:
>> Is it possible declare the eType of an eStructuralFeatures as decimal?
>> Will this be valid?
>>
>> <eStructuralFeatures xsi:type="dict:EAttributeParameter"
>> name="toControl" eType="ecore:EDataType
>> http://www.eclipse.org/emf/2003/XMLType#//Decimal">
>>
>> Also, can one also indicate the precision (e.g. 2 decimals)?
>>
>> Thanks in advance!
>]]>Al B2012-08-17T19:09:16-00:00Re: Decimal precision for eStructuralFeatures
https://www.eclipse.org/forums/index.php/mv/msg/369613/902476/#msg_902476
No, the annotation must be on the EDataType. So you need to define an
EDataType that wraps BigDecimal and put the annotation on that. Easiest
is to write a small schema and look at how that's converted to Ecore.
On 17/08/2012 9:09 PM, AJ wrote:
> Hi Ed,
>
> Do you mean doing something like this?
>
> <eStructuralFeatures xsi:type="dict:EAttributeParameter" name="acrPitch">
> <eAnnotations source="descriptor">
> <details key="display_name" value="Pitch"/>
> </eAnnotations>
> <eType xsi:type="ecore:EDataType"
> href="http://www.w3.org/TR/xmlschema-2/#rf-fractionDigits"/>
> </eStructuralFeatures>
>
> Or, do you mean embed another eAnnotations like this?
>
> <eStructuralFeatures xsi:type="dict:EAttributeParameter" name="acrPitch">
> <eAnnotations source="descriptor">
> <details key="display_name" value="Pitch"/>
> </eAnnotations>
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="baseType"
> value="http://www.w3.org/TR/xmlschema-2/#rf-fractionDigits"/>
> <details key="value" value="2"/>
> </eAnnotations>
> </eStructuralFeatures>
>
>
> Thanks!
>
> On 8/17/12 1:04 AM, Ed Merks wrote:
>> AJ,
>>
>> Yes, with extended metadata annotations on an EDataType you can specify
>> the number of fractional digits as in XML Schema
>> http://www.w3.org/TR/xmlschema-2/#rf-fractionDigits
>>
>>
>> On 17/08/2012 8:39 AM, AJ Ben wrote:
>>> Is it possible declare the eType of an eStructuralFeatures as decimal?
>>> Will this be valid?
>>>
>>> <eStructuralFeatures xsi:type="dict:EAttributeParameter"
>>> name="toControl" eType="ecore:EDataType
>>> http://www.eclipse.org/emf/2003/XMLType#//Decimal">
>>>
>>> Also, can one also indicate the precision (e.g. 2 decimals)?
>>>
>>> Thanks in advance!
>>
>]]>Ed Merks2012-08-17T20:01:16-00:00Re: Decimal precision for eStructuralFeatures
https://www.eclipse.org/forums/index.php/mv/msg/369613/902500/#msg_902500
As you suggested, I created a small schema:
I can see that BasicExtendedMetaData::basicGetBaseType() detects the new
type, but neither basicGetFractionDigitsFacet() or
setFractionDigitsFacet() are called.
Did I miss anything else?
Thanks again!
On 8/17/12 1:01 PM, Ed Merks wrote:
> AJ,
>
> No, the annotation must be on the EDataType. So you need to define an
> EDataType that wraps BigDecimal and put the annotation on that. Easiest
> is to write a small schema and look at how that's converted to Ecore.
>
>
> On 17/08/2012 9:09 PM, AJ wrote:
>> Hi Ed,
>>
>> Do you mean doing something like this?
>>
>> <eStructuralFeatures xsi:type="dict:EAttributeParameter" name="acrPitch">
>> <eAnnotations source="descriptor">
>> <details key="display_name" value="Pitch"/>
>> </eAnnotations>
>> <eType xsi:type="ecore:EDataType"
>> href="http://www.w3.org/TR/xmlschema-2/#rf-fractionDigits"/>
>> </eStructuralFeatures>
>>
>> Or, do you mean embed another eAnnotations like this?
>>
>> <eStructuralFeatures xsi:type="dict:EAttributeParameter" name="acrPitch">
>> <eAnnotations source="descriptor">
>> <details key="display_name" value="Pitch"/>
>> </eAnnotations>
>> <eAnnotations
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> <details key="baseType"
>> value="http://www.w3.org/TR/xmlschema-2/#rf-fractionDigits"/>
>> <details key="value" value="2"/>
>> </eAnnotations>
>> </eStructuralFeatures>
>>
>>
>> Thanks!
>>
>> On 8/17/12 1:04 AM, Ed Merks wrote:
>>> AJ,
>>>
>>> Yes, with extended metadata annotations on an EDataType you can specify
>>> the number of fractional digits as in XML Schema
>>> http://www.w3.org/TR/xmlschema-2/#rf-fractionDigits
>>>
>>>
>>> On 17/08/2012 8:39 AM, AJ Ben wrote:
>>>> Is it possible declare the eType of an eStructuralFeatures as decimal?
>>>> Will this be valid?
>>>>
>>>> <eStructuralFeatures xsi:type="dict:EAttributeParameter"
>>>> name="toControl" eType="ecore:EDataType
>>>> http://www.eclipse.org/emf/2003/XMLType#//Decimal">
>>>>
>>>> Also, can one also indicate the precision (e.g. 2 decimals)?
>>>>
>>>> Thanks in advance!
>>>
>>
>]]>Al B2012-08-18T00:12:28-00:00Re: Decimal precision for eStructuralFeatures
https://www.eclipse.org/forums/index.php/mv/msg/369613/902521/#msg_902521
EObjectValidator validates such things, but only when you invoke the
validator. I'd expect PropertyDescriptor.EDataTypeValueHandler.isValid
to invoke validation. What do you mean by "able to enter"? Via the
properties view?
On 18/08/2012 2:12 AM, AJ wrote:
> Ed,
>
> As you suggested, I created a small schema:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> ecore:nsPrefix="test" ecore:package="test" targetNamespace="test">
> <xsd:simpleType ecore:name="ThreeDecimalsType"
> name="ThreeDecimals_Type">
> <xsd:restriction base="xsd:decimal">
> <xsd:fractionDigits value="3"/>
> </xsd:restriction>
> </xsd:simpleType>
> </xsd:schema>
>
>
> And EMF generated an EDataType like this:
>
> <eClassifiers xsi:type="ecore:EDataType" name="ThreeDecimalsType"
> instanceClassName="java.math.BigDecimal">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="ThreeDecimals_Type"/>
> <details key="baseType"
> value="http://www.eclipse.org/emf/2003/XMLType#decimal"/>
> <details key="fractionDigits" value="3"/>
> </eAnnotations>
> </eClassifiers>
>
>
> However, I am still able to enter more than 3 decimals when I added
> this new type to the feature:
>
> <eStructuralFeatures xsi:type="dict:EAttributeParameter"
> name="acrPitch" eType="//ThreeDecimalsType">
> <eAnnotations source="descriptor">
> <details key="display_name" value="Pitch"/>
> </eAnnotations>
> </eStructuralFeatures>
>
>
> I can see that BasicExtendedMetaData::basicGetBaseType() detects the
> new type, but neither basicGetFractionDigitsFacet() or
> setFractionDigitsFacet() are called.
>
>
> Did I miss anything else?
>
> Thanks again!
>
>
> On 8/17/12 1:01 PM, Ed Merks wrote:
>> AJ,
>>
>> No, the annotation must be on the EDataType. So you need to define an
>> EDataType that wraps BigDecimal and put the annotation on that. Easiest
>> is to write a small schema and look at how that's converted to Ecore.
>>
>>
>> On 17/08/2012 9:09 PM, AJ wrote:
>>> Hi Ed,
>>>
>>> Do you mean doing something like this?
>>>
>>> <eStructuralFeatures xsi:type="dict:EAttributeParameter"
>>> name="acrPitch">
>>> <eAnnotations source="descriptor">
>>> <details key="display_name" value="Pitch"/>
>>> </eAnnotations>
>>> <eType xsi:type="ecore:EDataType"
>>> href="http://www.w3.org/TR/xmlschema-2/#rf-fractionDigits"/>
>>> </eStructuralFeatures>
>>>
>>> Or, do you mean embed another eAnnotations like this?
>>>
>>> <eStructuralFeatures xsi:type="dict:EAttributeParameter"
>>> name="acrPitch">
>>> <eAnnotations source="descriptor">
>>> <details key="display_name" value="Pitch"/>
>>> </eAnnotations>
>>> <eAnnotations
>>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>>> <details key="baseType"
>>> value="http://www.w3.org/TR/xmlschema-2/#rf-fractionDigits"/>
>>> <details key="value" value="2"/>
>>> </eAnnotations>
>>> </eStructuralFeatures>
>>>
>>>
>>> Thanks!
>>>
>>> On 8/17/12 1:04 AM, Ed Merks wrote:
>>>> AJ,
>>>>
>>>> Yes, with extended metadata annotations on an EDataType you can
>>>> specify
>>>> the number of fractional digits as in XML Schema
>>>> http://www.w3.org/TR/xmlschema-2/#rf-fractionDigits
>>>>
>>>>
>>>> On 17/08/2012 8:39 AM, AJ Ben wrote:
>>>>> Is it possible declare the eType of an eStructuralFeatures as
>>>>> decimal?
>>>>> Will this be valid?
>>>>>
>>>>> <eStructuralFeatures xsi:type="dict:EAttributeParameter"
>>>>> name="toControl" eType="ecore:EDataType
>>>>> http://www.eclipse.org/emf/2003/XMLType#//Decimal">
>>>>>
>>>>> Also, can one also indicate the precision (e.g. 2 decimals)?
>>>>>
>>>>> Thanks in advance!
>>>>
>>>
>>
>]]>Ed Merks2012-08-18T05:28:46-00:00Re: Decimal precision for eStructuralFeatures
https://www.eclipse.org/forums/index.php/mv/msg/369613/902527/#msg_902527
Yes, via the properties view.]]>Al B2012-08-18T07:28:53-00:00Re: Decimal precision for eStructuralFeatures
https://www.eclipse.org/forums/index.php/mv/msg/369613/902588/#msg_902588
Have you set a breakpoint to see what's going on?
On 18/08/2012 9:28 AM, AJ Ben wrote:
> Ed,
>
> Yes, via the properties view.]]>Ed Merks2012-08-18T17:20:47-00:00Re: Decimal precision for eStructuralFeatures
https://www.eclipse.org/forums/index.php/mv/msg/369613/902591/#msg_902591
I think I got it.
Your previous comment about the EDataTypeValueHandler.isValid, pointed me to the right direction. Using BasicExtendedMetaData.getFractionDigitsFacet() allows me to validate/format the entered input.
Thanks a lot and best regards!
PS: I like your Roman Emperor name ]]>Al B2012-08-18T18:07:02-00:00