Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
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 07:19 Go to next message
Igor Nikiforov is currently offline Igor Nikiforov
Messages: 3
Registered: April 2013
Location: Russia
Junior Member
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 67 times)
  • Attachment: TreeView.png
    (Size: 13.53KB, Downloaded 65 times)
  • Attachment: Package2.png
    (Size: 2.19KB, Downloaded 63 times)

[Updated on: Fri, 12 April 2013 06:10]

Report message to a moderator

Re: EPackage : problem with interaction of packages [message #1039400 is a reply to message #1038689] Fri, 12 April 2013 05:50 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26050
Registered: July 2009
Senior Member
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 06:44 Go to previous messageGo to next message
Igor Nikiforov is currently offline Igor Nikiforov
Messages: 3
Registered: April 2013
Location: Russia
Junior Member
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 07:20 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26050
Registered: July 2009
Senior Member
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 #1039550 is a reply to message #1039451] Fri, 12 April 2013 09:32 Go to previous messageGo to next message
Igor Nikiforov is currently offline Igor Nikiforov
Messages: 3
Registered: April 2013
Location: Russia
Junior Member
Ed,

Thanks again!

Now everything becomes clear for me.

1. It is possible to create a new diagram inside a package and move inside it a model subset.
2. It is possible to create EPackage in the model.
3. It is possible to create EReference between classes from different EPackages and from different diagrams.
4. It is possible to Load Resource and use its types.
5. It is unnecessary to create EAttribute of EClass type, it should be done via EReference.

And some conclusion, why I was confusing to understand this at once:
I was trying to create a model with the Palette and graphical editor. Graphical representation is not powerful enough to display all objects relationships, and tree view allows to see them.
Graphical editor doesn't allow to create and display (1), (3), but context menu of outline allows.

It will be worth doing MultyPageEditor for the ecordiagram editor. Diagrams or packages can be located at the tabs of the editor.

[Updated on: Fri, 12 April 2013 09:54]

Report message to a moderator

Re: EPackage : problem with interaction of packages [message #1065589 is a reply to message #1039550] Wed, 26 June 2013 15:26 Go to previous message
V Set is currently offline V Set
Messages: 13
Registered: November 2012
Junior Member
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.
Previous Topic:[ecp] add operation to context menu
Next Topic:Problem with generate the EEF plguin with Acceleo
Goto Forum:
  


Current Time: Thu Sep 18 23:52:30 GMT 2014

Powered by FUDForum. Page generated in 0.01907 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software