Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF3D » intermodel connections and gmf(intermodel connections and gmf)
intermodel connections and gmf [message #492985] Thu, 22 October 2009 15:10 Go to next message
Matthias Then is currently offline Matthias Then
Messages: 10
Registered: July 2009
Junior Member
Dear GEF3D-developers,

in your article in the Eclipse-Magazine your working with intermodel connections. I tried to integrate these intermodel connections into my project the same way as you did in your demo project (de.eclipsemag.gef3d.sample).
It doesn't work, the problem is the following operation:

org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPa rt.
getTargetConnectionAnchor
(org.eclipse.gef.ConnectionEditPart connEditPart)

The operation starts with the following line:
final org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditP art connection = (org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEdit Part) connEditPart;

In my case the ShapeNodeEditPart is a org.eclipse.uml2.diagram.clazz.edit.parts.Class2EditPart and the Connection is a MarkedElementEditPart. The class cast doesn't work. (The operation works for example for Class2EditParts and Associations.)

Is anyone here, who already solved the problem to use intermodel connections with org.eclipse.uml2 - elements?

Best regards,
Matthias
Re: intermodel connections and gmf [message #493107 is a reply to message #492985] Fri, 23 October 2009 08:01 Go to previous messageGo to next message
Kristian Duske is currently offline Kristian Duske
Messages: 64
Registered: July 2009
Member
Hi Matthias,

AFAIK, Jens solved the problem for the Mitra traces by using the
ConnectedElementAdapter technique. It does not require the target and
source edit parts to be at all aware of the connection (there's a
working example that uses the UML2 tools), so the problem you're
describing should not occur. Unfortunately, I can't tell you a lot
about how to use that technique, but maybe if you look at
org.eclipse.gef3d.ext.intermodel (in org.eclipse.gef3d.ext) you'll
figure it out. The code that actually uses this stuff is in
de.feu.mitra.traces.ui. The problem here is that you'll need an extra
model that contains just the connections.

If that doesn't help, there are few options. You could replace the GMF
edit parts of the model elements you are connecting with subclasses
that override the offending methods. This could be done using the borg
factory pattern, which is also described in the Eclipse Magazin
articles, or maybe it's possible to write a version of
UndirectConnectionEditPart taht subclasses
org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditP art so that
the cast is no longer a problem.

I hope this helps you out a little.

Best regards
Kristian
Re: intermodel connections and gmf [message #493159 is a reply to message #492985] Fri, 23 October 2009 12:38 Go to previous messageGo to next message
Jens von Pilgrim is currently offline Jens von Pilgrim
Messages: 295
Registered: July 2009
Senior Member
Dear Matthias,

there are two solutions for inter-model connections:

- UnidirectConnectionEditPart
- ConnectedElementAdapter pattern (which consists of several classes,
i.e. an EditPart, a model element and a figure.

The general problem both solutions address is that a model element and
its edit part are not aware of a connection. In GEF, both ends of a
connection need to know about this connection, that is both edit parts
need to know about it (not the model). In case of inter-model
connections, this usually isn't the case, as these special type of
connection cannot be visualized in a 2D editor.

The first solution, UnidirectConnectionEditPart, is the quicker and
easier solution, but it requires the (target) edit part of the
inter-model connection to support the creation of connection anchors
for all kind of connections. Unfortunately, this is not the case for
ShapeNodeEditPart, as it requires an
org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditP art, and
UnidirectConnectionEditPart is no such GMF specific edit part. IMHO
this is an GMF bug/problem, maybe we should file a bug report (a bugfix
is really easy) -- other GMF edit parts can in fact create anchors for
non-GMF edit parts.

So you have to use ConnectedElementAdapter instead, which is a little
bit more work to use, but it works with all kind of (target) edit
parts, as the target (and/or source) end is completely capsulated from
the connected element adapter. How does it work? Instead of the real
(taget) edit part (and model/figure), a dummy element, that is the
connected element adapter, is used as the target. The connected element
adapter listens to the figure of the real target and updates the
position accordingly. So, what you have to do is as follows:
- at some (container) edit part, usually the inter-model container edit
part, you have to create new ConnectedElementAdapters, set their
attributes accordingly (using the ReverseLookupManager) and return them
in getModelElements(). You will have to create such adapter model for
each connection end which isn't aware of the inter-model connection
(and which isn't handled otherwise, e.g. by a
UnidirectConnectionEditPart).
- in the EditPartFactory, create ConnectedElementEditParts for
ConnectedElementAdapters. The default implementation creates small
cubes as figures, you can subclass the editpart in order to create
invisible or other figures.
Hmm... I think that's it. In the package description of
org.eclipse.gef3d.ext.intermodel I have explained the pattern from a
structural point of view, I will add more explanation if necessary
(maybe you can give me a hint what information is missing or is
unclear).

Cheers,

Jens

P.S.: I filed an GMF bug report: https://bugs.eclipse.org/293160

On 2009-10-22 17:10:25 +0200, Matthias Then
<matthias.then@fernuni-hagen.de> said:
> in your article in the Eclipse-Magazine your working with intermodel
> connections. I tried to integrate these intermodel connections into my
> project the same way as you did in your demo project
> (de.eclipsemag.gef3d.sample). It doesn't work, the problem is the
> following operation:
> org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPa rt.
> getTargetConnectionAnchor (org.eclipse.gef.ConnectionEditPart connEditPart)
>
> The operation starts with the following line:
> final org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditP art
> connection =
> (org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEdit Part)
> connEditPart;
>
> In my case the ShapeNodeEditPart is a
> org.eclipse.uml2.diagram.clazz.edit.parts.Class2EditPart and the
> Connection is a MarkedElementEditPart. The class cast doesn't work.
> (The operation works for example for Class2EditParts and Associations.)
>
> Is anyone here, who already solved the problem to use intermodel
> connections with org.eclipse.uml2 - elements?
>
> Best regards,
> Matthias
Re: intermodel connections and gmf [message #493185 is a reply to message #493159] Fri, 23 October 2009 14:24 Go to previous message
Matthias Then is currently offline Matthias Then
Messages: 10
Registered: July 2009
Junior Member
Dear Jens, dear Kristian,

thank you very much for your feedback! Smile
And of course for writing the bug report to the GMF-community.

Next week I'll try the solution with the ConnectedElementAdapter ...

Have a nice weekend,
Matthias
Re: intermodel connections and gmf [message #563153 is a reply to message #492985] Fri, 23 October 2009 08:01 Go to previous message
Kristian Duske is currently offline Kristian Duske
Messages: 64
Registered: July 2009
Member
Hi Matthias,

AFAIK, Jens solved the problem for the Mitra traces by using the
ConnectedElementAdapter technique. It does not require the target and
source edit parts to be at all aware of the connection (there's a
working example that uses the UML2 tools), so the problem you're
describing should not occur. Unfortunately, I can't tell you a lot
about how to use that technique, but maybe if you look at
org.eclipse.gef3d.ext.intermodel (in org.eclipse.gef3d.ext) you'll
figure it out. The code that actually uses this stuff is in
de.feu.mitra.traces.ui. The problem here is that you'll need an extra
model that contains just the connections.

If that doesn't help, there are few options. You could replace the GMF
edit parts of the model elements you are connecting with subclasses
that override the offending methods. This could be done using the borg
factory pattern, which is also described in the Eclipse Magazin
articles, or maybe it's possible to write a version of
UndirectConnectionEditPart taht subclasses
org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditP art so that
the cast is no longer a problem.

I hope this helps you out a little.

Best regards
Kristian
Re: intermodel connections and gmf [message #563175 is a reply to message #492985] Fri, 23 October 2009 12:38 Go to previous message
Jens von Pilgrim is currently offline Jens von Pilgrim
Messages: 295
Registered: July 2009
Senior Member
Dear Matthias,

there are two solutions for inter-model connections:

- UnidirectConnectionEditPart
- ConnectedElementAdapter pattern (which consists of several classes,
i.e. an EditPart, a model element and a figure.

The general problem both solutions address is that a model element and
its edit part are not aware of a connection. In GEF, both ends of a
connection need to know about this connection, that is both edit parts
need to know about it (not the model). In case of inter-model
connections, this usually isn't the case, as these special type of
connection cannot be visualized in a 2D editor.

The first solution, UnidirectConnectionEditPart, is the quicker and
easier solution, but it requires the (target) edit part of the
inter-model connection to support the creation of connection anchors
for all kind of connections. Unfortunately, this is not the case for
ShapeNodeEditPart, as it requires an
org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditP art, and
UnidirectConnectionEditPart is no such GMF specific edit part. IMHO
this is an GMF bug/problem, maybe we should file a bug report (a bugfix
is really easy) -- other GMF edit parts can in fact create anchors for
non-GMF edit parts.

So you have to use ConnectedElementAdapter instead, which is a little
bit more work to use, but it works with all kind of (target) edit
parts, as the target (and/or source) end is completely capsulated from
the connected element adapter. How does it work? Instead of the real
(taget) edit part (and model/figure), a dummy element, that is the
connected element adapter, is used as the target. The connected element
adapter listens to the figure of the real target and updates the
position accordingly. So, what you have to do is as follows:
- at some (container) edit part, usually the inter-model container edit
part, you have to create new ConnectedElementAdapters, set their
attributes accordingly (using the ReverseLookupManager) and return them
in getModelElements(). You will have to create such adapter model for
each connection end which isn't aware of the inter-model connection
(and which isn't handled otherwise, e.g. by a
UnidirectConnectionEditPart).
- in the EditPartFactory, create ConnectedElementEditParts for
ConnectedElementAdapters. The default implementation creates small
cubes as figures, you can subclass the editpart in order to create
invisible or other figures.
Hmm... I think that's it. In the package description of
org.eclipse.gef3d.ext.intermodel I have explained the pattern from a
structural point of view, I will add more explanation if necessary
(maybe you can give me a hint what information is missing or is
unclear).

Cheers,

Jens

P.S.: I filed an GMF bug report: https://bugs.eclipse.org/293160

On 2009-10-22 17:10:25 +0200, Matthias Then
<matthias.then@fernuni-hagen.de> said:
> in your article in the Eclipse-Magazine your working with intermodel
> connections. I tried to integrate these intermodel connections into my
> project the same way as you did in your demo project
> (de.eclipsemag.gef3d.sample). It doesn't work, the problem is the
> following operation:
> org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPa rt.
> getTargetConnectionAnchor (org.eclipse.gef.ConnectionEditPart connEditPart)
>
> The operation starts with the following line:
> final org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditP art
> connection =
> (org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEdit Part)
> connEditPart;
>
> In my case the ShapeNodeEditPart is a
> org.eclipse.uml2.diagram.clazz.edit.parts.Class2EditPart and the
> Connection is a MarkedElementEditPart. The class cast doesn't work.
> (The operation works for example for Class2EditParts and Associations.)
>
> Is anyone here, who already solved the problem to use intermodel
> connections with org.eclipse.uml2 - elements?
>
> Best regards,
> Matthias
Re: intermodel connections and gmf [message #563196 is a reply to message #493159] Fri, 23 October 2009 14:24 Go to previous message
Matthias Then is currently offline Matthias Then
Messages: 10
Registered: July 2009
Junior Member
Dear Jens, dear Kristian,

thank you very much for your feedback! :)
And of course for writing the bug report to the GMF-community.

Next week I'll try the solution with the ConnectedElementAdapter ...

Have a nice weekend,
Matthias
Previous Topic:intermodel connections and gmf
Next Topic:Traces
Goto Forum:
  


Current Time: Fri Oct 24 12:09:48 GMT 2014

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

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