Home » Modeling » EMF » Decimal precision for eStructuralFeatures
| | |
Re: Decimal precision for eStructuralFeatures [message #902476 is a reply to message #902473] |
Fri, 17 August 2012 16:01   |
Eclipse User |
|
|
|
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!
>>
>
|
|
|
Re: Decimal precision for eStructuralFeatures [message #902500 is a reply to message #902476] |
Fri, 17 August 2012 20:12   |
Eclipse User |
|
|
|
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!
>>>
>>
>
|
|
|
Re: Decimal precision for eStructuralFeatures [message #902521 is a reply to message #902500] |
Sat, 18 August 2012 01:28   |
Eclipse User |
|
|
|
AJ,
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!
>>>>
>>>
>>
>
|
|
| | | |
Goto Forum:
Current Time: Sun Jul 27 16:10:52 EDT 2025
Powered by FUDForum. Page generated in 0.04541 seconds
|