Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » EPackage : problem with interaction of packages(can not set type for class attribute )
EPackage : problem with interaction of packages [message #1038689] |
Thu, 11 April 2013 03:19  |
Eclipse User |
|
|
|
HI everybody,
Imagine the situation
I've create ecore file with two packages, as shown at attached figures (just a template).
Package1:
ClassA
Package2:
ClassB
Then, I'd like to create an attribute for ClassA, for example name it "attr", and set to it type ClassB.
But there is no ClassB in EType field for the attribute.
As I understand It is possible to select in EType fields only EDataType or EEnum.
And if I need to create an attribute of the EClass type then I required to create EReference between the classes.
So the question:
If I have two classes in different packages, how can I solve my problem and create the attribute of type, that is defined in different package.
Thanks in advance!
Attachment: Package1.png
(Size: 5.77KB, Downloaded 226 times)
Attachment: TreeView.png
(Size: 13.53KB, Downloaded 236 times)
Attachment: Package2.png
(Size: 2.19KB, Downloaded 245 times)
[Updated on: Fri, 12 April 2013 02:10] by Moderator
|
|
|
Re: EPackage : problem with interaction of packages [message #1039400 is a reply to message #1038689] |
Fri, 12 April 2013 01:50   |
Eclipse User |
|
|
|
Igor,
Comments below.
On 11/04/2013 2:37 PM, Igor Nikiforov wrote:
> HI everybody,
>
> Imagine the situation
>
> I've create ecore file with two packages, as shown at attached figures (just a template).
>
> Package1:
> ClassA
>
> Package2:
> ClassB
>
> Then, I'd like to create an attribute for ClassA, for example name it "attr", and set to it type ClassB.
>
> But there is no ClassB in EType field for the attribute.
> As I understand It is possible to select in EType fields only EDataType or EEnum.
> And if I need to create a attribute of the EClass type then I required to create EReference between the classes.
Yes.
>
> So the question:
> If I have two classes in different packages, how can I solve my problem and create the attribute of type, that is defined in different package.
I doubt that's what you really want. Of course you can always create
an EDataType that wraps any existing Java type, including the generated
interface from some class, but you won't be able to serialize the
attribute's value...
>
> Thanks in advance!
|
|
|
Re: EPackage : problem with interaction of packages [message #1039426 is a reply to message #1039400] |
Fri, 12 April 2013 02:44   |
Eclipse User |
|
|
|
Ed,
Thanks for the answer
The main idea why I am trying to use packages, is that ecore diagram become too huge, so I decided to separate some features to different package.
I've already tried to use EDataType and come to the serialization problem: I have to manually override toString, fromString methods for defined type. But it is bad idea, because there can be a lot of subclasses, so overriding of the methods can be compared to manually writing serialization code for the whole model.
Maybe I understand something wrong, please point me, but the questions still are:
1. What for EPackages are in ecore model, if they don't allow types interaction and EReferences?
2. What is better to use: EPackage or another ecore file? From meaning and current functionality, I understand, that this two definition are almost equals.
3. If use EDataType as a wrapper for EClassB from another package, how can I automatically resolve serialization problem without overriding toString, fromString (EMF should have information that defines how to serialize its own classes)?
|
|
|
Re: EPackage : problem with interaction of packages [message #1039451 is a reply to message #1039426] |
Fri, 12 April 2013 03:20   |
Eclipse User |
|
|
|
Igor,
Comments below.
On 12/04/2013 8:44 AM, Igor Nikiforov wrote:
> Ed,
> Thanks for the answer
>
> The main idea why I am trying to use packages, is that ecore diagram
> become too huge, so I decided to separate some features to different
> package.
You can have multiple diagrams for the same model each showing some
interesting subset.
>
> I've already tried to use EDataType and come to the serialization
> problem: I have to manually override toString, fromString methods for
> defined type. But it is bad idea, because there can be a lot of
> subclasses, so overriding of the methods can be compared to manually
> writing serialization code for the whole model.
Yes, that's what I suggested.
>
> Maybe I understand something wrong, please point me, but the questions
> still are: 1. What for EPackages are in ecore model, if they don't
> allow types interaction and EReferences?
They do allow that, but you seemed quite insistent about wanting and
attribute not a reference, which doesn't make much sense....
>
> 2. What is better to use: EPackage or another ecore file? From meaning
> and current functionality, I understand, that this two definition are
> almost equals.
Typically one puts each package in separate file, so yes, they ideas are
pretty much the same.
>
> 3. If use EDataType as a wrapper for EClassB from another package, how
> can I automatically resolve serialization problem without overriding
> toString, fromString (EMF should have information that defines how to
> serialize its own classes)?
You don't. You need an EReference. Is there some reasons you think you
don't want one? Note that you'll generally need to use "Load
Resource..." in the outline of the diagram editor to load Ecore models
you want to reference. Once you do that, you can drag classes from that
model onto your diagram and then use them to create references.
|
|
| |
Re: EPackage : problem with interaction of packages [message #1065589 is a reply to message #1039550] |
Wed, 26 June 2013 11:26  |
Eclipse User |
|
|
|
Hi,
I am creating an editor along these lines too. So far, I created 2 EPackages (One and Two) inside the main ecore (Main). Main has an EClass 'Header'. I have an EClass 'Amp' in EPackage 'One' that has an EReference 'refVolt' that connects to the EClass 'Volt' in EPackage 'Two'. refVolt is contained in 'Header'. I believe that I have to create one gmfgraph, one gmftool and 2 gmfmaps - one for each package. I hope this is right way to go...haven't tested any of this yet.
|
|
|
Goto Forum:
Current Time: Wed Jul 23 15:58:23 EDT 2025
Powered by FUDForum. Page generated in 0.05249 seconds
|