Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Create connection between two classes
Create connection between two classes [message #1285670] Sat, 05 April 2014 21:45 Go to next message
Brian Tost is currently offline Brian TostFriend
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 #1285767 is a reply to message #1285670] Sun, 06 April 2014 00:25 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

Hi Brian,

To create connections between elements in the editor you will need to use a @gmf.link annotation either on a reference (e.g. like Shortcut.target) or on a class (e.g. like Sync) in [1].

Cheers,
Dimitris

[1] http://eclipse.org/epsilon/doc/articles/eugenia-gmf-tutorial/
Re: Create connection between two classes [message #1286569 is a reply to message #1285670] Sun, 06 April 2014 22:15 Go to previous messageGo to next message
Brian Tost is currently offline Brian TostFriend
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 Go to previous message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

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

Previous Topic:Profile not recognized in ETL when started from standalone plug-in
Next Topic:Handling Epsilon keywords as metamodel element names
Goto Forum:
  


Current Time: Fri Apr 26 03:25:19 GMT 2024

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

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

Back to the top