Serialization Option [message #689228] |
Mon, 27 June 2011 03:51  |
Eclipse User |
|
|
|
Hi,
I'm looking for a options for serialize my EMF Model. My Model consisted of 1 EClass and 2 EAttributes.
That follow part code shows how i create my dynamic EMF model.
EClass purchaseOrderClass = ecoreFactory.createEClass();
purchaseOrderClass.setName("PurchaseOrder");
EAttribute shipTo = ecoreFactory.createEAttribute();
shipTo.setName("shipTo");
shipTo.setEType(EcorePackage.Literals.ESTRING);
purchaseOrderClass.getEStructuralFeatures().add(shipTo);
EAttribute billTo = ecoreFactory.createEAttribute();
billTo.setName("billTo");
billTo.setEType(EcorePackage.Literals.ESTRING);
purchaseOrderClass.getEStructuralFeatures().add(billTo);
This small part of code shows how create an instance of my dynamic EMF model.
EFactory poFactory = poPackage.getEFactoryInstance();
EObject purchaseOrder = poFactory.create(purchaseOrderClass);
purchaseOrder.eSet(purchaseOrderClass.getEStructuralFeature("shipTo"),
"123 Maple Street");
purchaseOrder.eSet(purchaseOrderClass.getEStructuralFeature("billTo"),
"200 Maple Street");
And then, after serialization when i open the serialiezd model with "sample reflective ecore Model editor" ,i have this view.
Purchase Order123 Maple Street
Is there an option of serialization for choice the EAttributes for display like that:
Purchase Order 200 Maple Street
Any help will be appreciated.
Ben
|
|
|
Re: Serialization Option [message #689443 is a reply to message #689228] |
Mon, 27 June 2011 12:14   |
Eclipse User |
|
|
|
Ben,
Comments below.
On 27/06/2011 12:51 AM, ben wrote:
> Hi,
>
> I'm looking for a options for serialize my EMF Model. My Model
> consisted of 1 EClass and 2 EAttributes.
>
> That follow part code shows how i create my dynamic EMF model. EClass
> purchaseOrderClass = ecoreFactory.createEClass();
> purchaseOrderClass.setName("PurchaseOrder");
> EAttribute shipTo = ecoreFactory.createEAttribute();
> shipTo.setName("shipTo");
> shipTo.setEType(EcorePackage.Literals.ESTRING);
> purchaseOrderClass.getEStructuralFeatures().add(shipTo);
> EAttribute billTo = ecoreFactory.createEAttribute();
> billTo.setName("billTo");
> billTo.setEType(EcorePackage.Literals.ESTRING);
> purchaseOrderClass.getEStructuralFeatures().add(billTo);
> This small part of code shows how create an instance of my dynamic
> EMF model. EFactory poFactory = poPackage.getEFactoryInstance();
>
> EObject purchaseOrder = poFactory.create(purchaseOrderClass);
>
> purchaseOrder.eSet(purchaseOrderClass.getEStructuralFeature("shipTo"),
> "123 Maple Street");
>
> purchaseOrder.eSet(purchaseOrderClass.getEStructuralFeature("billTo"),
> "200 Maple Street");
> And then, after serialization when i open the serialiezd model with
> "sample reflective ecore Model editor" ,i have this view.
> Purchase Order123 Maple Street
>
> Is there an option of serialization for choice the EAttributes for
> display like that: Purchase Order 200 Maple Street
No, the reflective editor has no idea which feature you'd prefer to use
as the label. It just picks one using a heuristic. If you make the
billTo address feature earlier in the list of the class' features, it
should pick that one instead.
>
> Any help will be appreciated.
>
> Ben
|
|
|
Re: Serialization Option [message #689789 is a reply to message #689443] |
Tue, 28 June 2011 07:18  |
Eclipse User |
|
|
|
Hi,
You are right Ed, for that billTo address feature display as label, i should build the billTo address feature at the earlier in the list of the EClass features.
Thank you
Ben
|
|
|
Powered by
FUDForum. Page generated in 0.07739 seconds