Create connection between two classes [message #1285670] |
Sat, 05 April 2014 21:45 |
Brian Tost Messages: 4 Registered: April 2013 |
Junior Member |
|
|
I'm trying to create a GMF editor to create classes, attributes and association between two classes using a subset of the class diagram metamodel developed by OMG.
The problem is that I can't create a connection between two properties (actually, an association).
Here is the metamodel:
@gmf(foo="bar")
@namespace(uri="model", prefix="model")
package model;
@gmf.diagram(foo="bar")
class Model {
val Class[*] classes;
}
abstract class Classifier {
}
@gmf.node(label="name", figure="rectangle", label.icon="false")
class Class extends Classifier {
@gmf.compartment(layout="list", collapsible="false")
val Attribute[*] attributes;
@gmf.affixed
val Property[*] properties;
attr String name;
}
@gmf.node(label="name", figure="rectangle", label.icon="false")
class Attribute {
attr String name;
}
abstract class MultiplicityElement {
attr int lower;
attr int upper;
}
class Association extends RelationShip, Classifier {
}
@gmf.node(figure="rectangle", size="10,10", label="lower,upper", label.placement="external", label.icon="false", label.pattern="{0}..{1}")
class Property extends MultiplicityElement {
ref Association association;
attr AggregationKind aggregation;
}
abstract class RelationShip {
}
enum AggregationKind {
none = 0;
share = 1;
aggregation = 2;
}
How can I create a connection between two properties? I tried to create a source and target Property in Association class but it did not work.
Thank you!
|
|
|
|
Re: Create connection between two classes [message #1286569 is a reply to message #1285670] |
Sun, 06 April 2014 22:15 |
Brian Tost Messages: 4 Registered: April 2013 |
Junior Member |
|
|
Hi Dimitris!
First of all, thank you for your response. Yes I know that I must use @gmf.link annotation to create a connection between two nodes. The problem is if I use @gmf.link in this node:
class Property extends MultiplicityElement {
@gmf.link
ref Association association;
attr AggregationKind aggregation;
}
A connection between two properties using the association class is not possible. So I tried to extend the original metamodel and create a target reference:
class Association extends RelationShip, Classifier {
ref Property target;
}
But it is not yet possible create a connection between two properties.. I do not want to make many changes in the original metamodel.. but how can I do this?
Thank you!
[Updated on: Sun, 06 April 2014 22:17] Report message to a moderator
|
|
|
Re: Create connection between two classes [message #1286860 is a reply to message #1286569] |
Mon, 07 April 2014 06:09 |
|
Hi Brian,
I suspect that you'll need to add another property to your association:
@gmf.link(source="source", target="target")
class Association extends RelationShip, Classifier {
ref Property source;
ref Property target;
}
Another potential problem in your metamodel is that associations can't be contained anywhere in the structure. To fix this, I'd suggest changing
val Class[*] classes;
to
val Classifier[*] classifiers;
If your metamodel is immutable, you could either go with pure GMF or with a hybrid approach where you specify what you can using Eugenia's annotations and then fill in the gaps using a polishing transformation [1].
Cheers,
Dimitris
[1] http://eclipse.org/epsilon/doc/articles/eugenia-polishing/
[Updated on: Mon, 07 April 2014 06:09] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03297 seconds