Create connection that is not linked to a BO [message #912047] |
Wed, 12 September 2012 17:18  |
Eclipse User |
|
|
|
Hello all and sorry for this newbie question, here is my problem.
I have designed a meta-model in EMF (let's say BPMN like meta-model) and I am developing a Graphiti editor to model instances of this meta-model.
In my metamodel I have EClasses (ex.: A and B) with 1..* relationship. So, "A" holds an EList<B>.
In my Graphiti I could create so far instances of A and B (let's say a1 and b1). Now I want to link a1 and b1 (i.e. adding b1 to the EList<B> held by a1).
The natural way of doing this is by creating a connection between A1 and B1. However, I can't seem to figure out how to do this since a Connection must be linked to a BusinessObject. (Am I right about this?).
In the tutorial, an EReference is created for each Connection. In my case, all I want to do is:
public Connection create(ICreateConnectionContext context) {
Connection newConnection = null;
A a1 = getAClass(context.getSourceAnchor());
B b1 = getBClass(context.getTargetAnchor());
if (a1 != null && b1 != null) {
// create new business object
a1.getBList.add(b1);
// add connection for business object
AddConnectionContext addContext =
new AddConnectionContext(context.getSourceAnchor(), context
.getTargetAnchor());
newConnection =
(Connection) getFeatureProvider().addIfPossible(addContext);
}
return newConnection;
}
Could someone please give me a hint how I could achieve this?
Thanks a lot!!
|
|
|
Re: Create connection that is not linked to a BO [message #912056 is a reply to message #912047] |
Wed, 12 September 2012 17:43   |
Eclipse User |
|
|
|
Anis,
I have the same issue. In general, I don't think a graphical object
needs to have a business object, so you can just create your connection
without it. You must however have enough information accessible to do
relevant things to it e.g. delete the corresponding reference if it is
deleted. If the anchors and their parent's business objects are enough
info. then you're ok, if not you can add properties, e.g. the name of
the Ecore EStructural feature to remove from.
Hope this helps.
Hallvard
On 12.09.12 14.18, Anis Boubaker wrote:
> Hello all and sorry for this newbie question, here is my problem.
> I have designed a meta-model in EMF (let's say BPMN like meta-model) and
> I am developing a Graphiti editor to model instances of this meta-model.
> In my metamodel I have EClasses (ex.: A and B) with 1..* relationship.
> So, "A" holds an EList<B>.
>
> In my Graphiti I could create so far instances of A and B (let's say a1
> and b1). Now I want to link a1 and b1 (i.e. adding b1 to the EList<B>
> held by a1).
> The natural way of doing this is by creating a connection between A1 and
> B1. However, I can't seem to figure out how to do this since a
> Connection must be linked to a BusinessObject. (Am I right about this?).
> In the tutorial, an EReference is created for each Connection. In my
> case, all I want to do is:
>
> public Connection create(ICreateConnectionContext context) {
> Connection newConnection = null;
>
> A a1 = getAClass(context.getSourceAnchor());
> B b1 = getBClass(context.getTargetAnchor());
>
> if (a1 != null && b1 != null) {
> // create new business object
> a1.getBList.add(b1);
> // add connection for business object
> AddConnectionContext addContext =
> new AddConnectionContext(context.getSourceAnchor(), context
> .getTargetAnchor());
> newConnection =
> (Connection)
> getFeatureProvider().addIfPossible(addContext);
> }
> return newConnection;
> }
>
>
> Could someone please give me a hint how I could achieve this?
>
> Thanks a lot!!
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04416 seconds