Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » ER like connections
ER like connections [message #641843] Sun, 28 November 2010 17:18 Go to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

I want to have a link that can be added like a link but looks like a node with two links. To achive this I currently have a node and a link with the target attribute set to an attribute of the node. So I need to add first the node and then the links.
What I want is to do is add a link and get a node with two links. I need something looking similar to the relations in an ER diagram ( http://en.wikipedia.org/wiki/File:Erd-entity-relationship-ex ample1.svg) but with the ability to add attributes etc. to the relation not only a label.

Thanks in advance
Re: ER like connections [message #642137 is a reply to message #641843] Tue, 30 November 2010 03:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: christian.busch2.gmx.de

Hi,
you could try using an edit helper in combination with an instead
advice. This way you should be able to create an "ER node" and the
corresponding links if you use a link (to get start and end node) as
object for the tooling/mapping and overwrite its creation process as
stated above.
Otherwise I think you would have to modify generated code, and this is
neither funny nor easy to maintain. ;)
If I have missed a better way, please someone correct me.

Best regards,
Christian

Am 28.11.2010 18:18, schrieb ralph.:
> Hi,
>
> I want to have a link that can be added like a link but looks like a
> node with two links. To achive this I currently have a node and a link
> with the target attribute set to an attribute of the node. So I need to
> add first the node and then the links.
> What I want is to do is add a link and get a node with two links. I need
> something looking similar to the relations in an ER diagram
> ( http://en.wikipedia.org/wiki/File:Erd-entity-relationship-ex ample1.svg)
> but with the ability to add attributes etc. to the relation not only a
> label.
>
> Thanks in advance
Re: ER like connections [message #642177 is a reply to message #642137] Tue, 30 November 2010 09:23 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

this sounds very good. I will take a look into EditHelpers and InsteadAdvices!

Thank you!

Ralph
Re: ER like connections [message #642202 is a reply to message #642137] Tue, 30 November 2010 11:51 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

first thank you for the quick reply. I did play around with edit helpers and advices. Unfortunately I could not to get it work.

The only method that gets executed in my advice is the getBeforeConfigureCommand command. All others like getBeforeCreateRelationshipCommand do not get executed. Do you have a idea why this methods do not get called?

In the edit helper the methods like getCreateRelationshipCommand or getCreateCommand are not executed either. Only createCommand is executed. Do you know what can cause this?

If I understood right the xxxcreateRelationshipCommands schould be called in my case as I am adding a link from the tool box to the diagram.

Another problem is that I cannot modify the ElementsToEdit list of the request to add/remove elements I want to have added to my diagram.

I could not find a very detailed description of all those techniques I used. Do you know where to find a good documentation. For example I could find nothing about instead advices.

Thank you a lot!!

Ralph
Re: ER like connections [message #642231 is a reply to message #642202] Tue, 30 November 2010 13:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: christian.busch2.gmx.de

Hey.

Am 30.11.2010 12:51, schrieb ralph.:
> Hi,
>
> first thank you for the quick reply. I did play around with edit helpers
> and advices. Unfortunately I could not to get it work.
> The only method that gets executed in my advice is the
> getBeforeConfigureCommand command. All others like
> getBeforeCreateRelationshipCommand do not get executed. Do you have a
> idea why this methods do not get called?
>
> In the edit helper the methods like getCreateRelationshipCommand or
> getCreateCommand are not executed either. Only createCommand is
> executed. Do you know what can cause this?

As far as I can tell from the javadoc getInsteadCommand has to delegate
to the other more specific classes in the editHelper. Chances are that
same applies for getBeforeConfigureCommand, but to be honest this is
just a guess.

> If I understood right the xxxcreateRelationshipCommands schould be
> called in my case as I am adding a link from the tool box to the diagthe IEditCommandRequestram.

Same as above.

> Another problem is that I cannot modify the ElementsToEdit list of the
> request to add/remove elements I want to have added to my diagram.

I am not quite shure, but the request may be immutable. But even if
that's the case there shouldn't be a problem with this as you build the
command on your own, where you don't have to use anything out of the
request if not needed.

> I could not find a very detailed description of all those techniques I
> used. Do you know where to find a good documentation. For example I
> could find nothing about instead advices.

Yes it is actually really hard to find good
documentation/literature/tutorials (that are not outdated) for many
things concerning gmf. I'm sorry but I don't know a single good
documentation either. Most of what I think to know I learned from others
and even that may be wrong, bad practices or outdated. :/ The instead
advice was mentioned in this german wiki:
https://sdqweb.ipd.uka.de/wiki/GMF_Tutorial:_Elemente_konfig urieren_w%C3%A4hrend_sie_angelegt_werden

Greetings,
Christian
Re: ER like connections [message #642541 is a reply to message #642231] Wed, 01 December 2010 17:48 Go to previous messageGo to next message
Michael Golubev is currently offline Michael GolubevFriend
Messages: 383
Registered: July 2009
Senior Member
Hello,

I my understanding correct, that in the semantic model you already have something like:

class Table {
....
}

class AssociationClassLink {
ref Table first;
ref Table second;
}

and that you already have the diagram that looks like the sample picture Artist-performs-Song, and just want to allow user to create 3 elements (2 links and rhomb in between) in 1 operation, while drawing one connection from "Artist" to "Song"?

I have recently implemented this scenario and may explain exactly how to do that, just want to be sure its relevant to your problem.

Regards,
Michael
Re: ER like connections [message #642562 is a reply to message #642541] Wed, 01 December 2010 19:19 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

that is exactly what I want!!

Thank you very much for your help in advance!!

Ralph
Re: ER like connections [message #642622 is a reply to message #642562] Thu, 02 December 2010 03:05 Go to previous messageGo to next message
Michael Golubev is currently offline Michael GolubevFriend
Messages: 383
Registered: July 2009
Senior Member
Hello,

I have posted detailed explanations, and the links to the sample code at Google docs, at https://docs.google.com/document/d/11hWszd3fyE2tRGIe08NQFXEj NraZc3r5ztBC4ruMr-U/edit?hl=en#.

Just to enable searching, here is the copy:

As you probably got by now there are no one-line solutions to this use case. The only good news is that I am going to try to push this solution to GMF-tooling, and with a bit of luck it will be possible to define and generate the code below in Indigo. To be honest, it is one of the reason for me to describe this somewhat long story here.

The complete code is available in the public SVN repoistory at http://www.assembla.com/code/gmf-association-class-links/sub version/nodes

There are 4 plugins, 2 of them are just pure EMF plugins (inthemiddle and inthemiddle.edit, nothing interesting there), + supporting .gmf plugin containing helper code, GMF artifacts and custom templates, and finally the resulting .diagram plugin.

There is very simple diagram definition in the *.gmf/gmf/def/ folder. There is nothing special here, except that we set the incoming link creations to true for both GenLink's in the gmfgen model, to allow user to start drawing of the link from the Rectangle instead of not-yet-created Rhomb.

Also I was somewhat lazy to play with gmfgraph today, so don't be surprised that Rhomb model elements are rendered as rounded rectangles at the diagram Smile.

Proposed solution consists of 2 parts:
a) modifying the GraphicalNodeEditPolicy (GNEP) to collect and pass the diagram information into the semantic creation command and
b) implementing the composite creation command itself

a) So we are going to replace org.eclipse.gmf.runtime.diagram.ui.editpolicies.GraphicalNod eEditPolicy with tweaked ITMGraphicalNodeEditPolicy from the *.gmf plugin. The changes made are as follows:

- Default GNEP packs the CompositeTransactionalCommand and then uses the ordering to access the different parts of the pack. E.g, lines 508-515 in the default GNEP looks like:
Quote:

CompositeCommand cc = (CompositeCommand) proxy.getICommand();
//....
Iterator commandItr = cc.iterator();
commandItr.next(); //0
SetConnectionEndsCommand sceCommand = (SetConnectionEndsCommand) commandItr.next(); //1
sceCommand.setNewTargetAdaptor(new EObjectAdapter(((IGraphicalEditPart) targetEP).getNotationView()));
SetConnectionAnchorsCommand scaCommand = (SetConnectionAnchorsCommand) commandItr.next(); //2
//....



This is clearly bad, so the changed code introduces ITMCreateLinkCommand with explicit access to its parts. It also has a code to register the results pack in the parameters of original request, so our semantic command will be able to access the whole pack at the execution time.

The changed code also computes an additional ITMCreateParameters describing the diagram information about the link source and target, but, while useful in general, it may be out of scope of this particular use case.

To register all the ITM* staff above in the generated diagram I used the following custom templates (*.gmf plugin, /gmf/templates/...)
itm::graphicalnodeep::Guard.qvto
it is the guard that prevents generation of the new code for unrelated diagrams (I had more than 1):
Quote:

helper requiresSpecificGraphicalNodeEditPolicy(diagram : genModel::GenDiagram) : Boolean {
return
'your.diagram.plugin.id = diagram.editorGen.plugin.iD
}



This guard allows every other affected template to have something like:

Quote:

«EXTENSION itm::graphicalnodeep::Guard»
...
«IF requiresSpecificGraphicalNodeEditPolicy(self.getDiagram())-
Re: ER like connections [message #643144 is a reply to message #641843] Sun, 05 December 2010 09:15 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

this does exactly the thing I need. However, it is a lot of source code and template which make the source code really hard to understand. I managed to get I work by executing the dynamic templates, edit the guard expression and modify Explicit Rhomb and my xxxSemanticItemPolicy as describe in the article in you google docs This last part from google docs is missing here. I needed a few days to get this work and could not completely understand what you are doing, because I am completely new to all of this. My main questions have a main foundational character.

1) What is the NodeEditingPolicy for?
2) Is all that code needed to solve the problem or could it be done in a shorter but less sophisticated way?

Maybe you should think about posting into the GMF Tips Wiki (http://wiki.eclipse.org/GMF_Tips) and submit you code to the Eclipse CVS or publish it at http://code.google.com/p/gmftools/.

Thank you

Ralph

[Updated on: Sun, 05 December 2010 09:19]

Report message to a moderator

Re: ER like connections [message #643160 is a reply to message #643144] Sun, 05 December 2010 14:57 Go to previous messageGo to next message
Michael Golubev is currently offline Michael GolubevFriend
Messages: 383
Registered: July 2009
Senior Member
Hello

It seems to be a fixed limit of the message size in the forum, I can't manage the previous reply to contain all the text from article.

1. The GraphicalNodeEditPolicy is the code that manages the creation of the links from and to the host edit part. Thats why in order to do untrivial links creation we need to install the tweaked version of the GNEP into all link possible sources and destinations at the diagram (made by custom templates in the sample).

2. Sorry, I don't know any simpler/shorter solution. Thats why I think it would be helpful to move all of proposed code into the base set of GMF templates and to support usecases like your one at the generation level.

Regards,
Michael
Re: ER like connections [message #643161 is a reply to message #643160] Sun, 05 December 2010 15:03 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

i think you are completely right as this is a commen use case for multiple modelling languages! Having the ability to model something lika a composed link in the gmfmap would be a great thing. So one could build a link out of two connections and a node and would get your code generated to solve this.

Thanks!

Ralph
Re: ER like connections [message #643162 is a reply to message #643161] Sun, 05 December 2010 15:04 Go to previous messageGo to next message
Michael Golubev is currently offline Michael GolubevFriend
Messages: 383
Registered: July 2009
Senior Member
Hello,

Do you mind to submit feature request for this?

Regards,
Michael
Re: ER like connections [message #643163 is a reply to message #643162] Sun, 05 December 2010 15:06 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

where can I do so? I will open it and post the link here.

Ralph
Re: ER like connections [message #643166 is a reply to message #643163] Sun, 05 December 2010 15:24 Go to previous messageGo to next message
Michael Golubev is currently offline Michael GolubevFriend
Messages: 383
Registered: July 2009
Senior Member
Hello,

Hum, let me guess.... Ah! You can use Bugzilla for that Smile Please make sure that the Component is set to GMF-Tooling.

Regards,
Michael





Re: ER like connections [message #643167 is a reply to message #643166] Sun, 05 December 2010 15:35 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
HI.

I filed the bug request https://bugs.eclipse.org/bugs/show_bug.cgi?id=331868.

Ralph
Re: ER like connections [message #643547 is a reply to message #643167] Tue, 07 December 2010 11:01 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi Michael,

I tried to use you plugin with my code at first glance everything works fine. But after saving the diagram, closing it and reopening a problem occurs. If I click on my source part of the link (the side where I started drawing) I get an NullPointerException in org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.resolveSe manticElement(ViewUtil.java:497). I checked my code line for line to match yours several times and debugged ImplicitRhombCreateCommand and RectangleSemanticEditPolicy. But I could not find any errors. Your plugin whithout my coding works fine. Do you have a point where I could start searching for this error? The strange thing is that after saving the diagram time, closing, reopenening it will make the source link disappear on the Diagram. That is really strange. So I could summarize:

1) Everthing is fine -> close save open
2) I get an exeception when clicking the source link -> close save open
3) The source link is dissapeared on the diagram

Thanks,

Ralph
Re: ER like connections [message #643662 is a reply to message #643547] Tue, 07 December 2010 18:49 Go to previous messageGo to next message
Michael Golubev is currently offline Michael GolubevFriend
Messages: 383
Registered: July 2009
Senior Member
Hello,

Hard to say without looking at the code or at least to more stacks of the exception.

I would recommend to carefully check the saved semantic resource for possible problems.

If everything fine, I would try to reproduce the same state of the diagram by manually creating of the rhomb and 2 part of the links and comparing both diagram and semantic resources with the results of automated creation.

Hope that helps,
Regards,
Michael

Re: ER like connections [message #643782 is a reply to message #643662] Wed, 08 December 2010 09:40 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

I found the errors when comparing my diagram xmi to the diagram xmi you plug in produces. I marked the differences in bold:

Your XMI:

<edges xmi:type="notation:Connector" xmi:id="_gP7u8AFPEeClrNQa80wp6g" type="4002" source="_gPx98AFPEeClrNQa80wp6g" target="_dPkVQAFPEeClrNQa80wp6g">
<styles xmi:type="notation:FontStyle" xmi:id="_gP7u8QFPEeClrNQa80wp6g" fontName="Segoe UI"/>
<element xsi:nil="true"/>
<bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_gP7u8gFPEeClrNQa80wp6g" points="[0, 0, 0, 0]$[0, 0, 0, 0]"/>
</edges>
<edges xmi:type="notation:Connector" xmi:id="_gQrV0AFPEeClrNQa80wp6g" type="4001" source="_gPx98AFPEeClrNQa80wp6g" target="_c_M-AAFPEeClrNQa80wp6g">
<styles xmi:type="notation:FontStyle" xmi:id="_gQrV0QFPEeClrNQa80wp6g" fontName="Segoe UI"/>
<element xsi:nil="true"/>
<bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_gQrV0gFPEeClrNQa80wp6g" points="[0, 0, -372, -173]$[352, 163, -20, -10]"/>
</edges>

My Code:

<edges xmi:type="notation:Connector" xmi:id="_AAXpIAKtEeC4ouyRqPLhGA" type="4005" source="_GehNwAKsEeC4ouyRqPLhGA" target="_JyXtIAJJEeCucI_oimNlnA">
<styles xmi:type="notation:FontStyle" xmi:id="_AAXpIQKtEeC4ouyRqPLhGA" fontName="Segoe UI"/>
<element xsi:nil="true"/>
<bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_AAXpIgKtEeC4ouyRqPLhGA" points="[0, 0, 0, 0]$[0, 0, 0, 0]"/>
</edges>
<edges xmi:type="notation:Connector" xmi:id="_O6dC0AKtEeC4ouyRqPLhGA" type="4005" source="_Jhjp8AJJEeCucI_oimNlnA" target="_GehNwAKsEeC4ouyRqPLhGA">
<styles xmi:type="notation:FontStyle" xmi:id="_O6dC0QKtEeC4ouyRqPLhGA" fontName="Segoe UI"/>
<element xsi:nil="true"/>
<bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_O6dC0gKtEeC4ouyRqPLhGA" points="[52, 1, -342, -9]$[340, -12, -54, -22]"/>
<sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_O6mMwAKtEeC4ouyRqPLhGA" id="(0.8306188925081434,0.1702127659574468)"/>
<targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_O6mMwQKtEeC4ouyRqPLhGA" id="(0.30793650793650795,0.23404255319148937)"/>
</edges>

It looks like in my case something goes fundamentally wrong but I cannot find the place when debugging everythin looks just fine. However, it creates only the target shapes (rhombRight) instead of a target and a source shape (rhombLeft). Secondly my second generated link has the source set in the target attribute. Do you know where this can go wrong in the code?

Thanks in advance,

Ralph
Re: ER like connections [message #644010 is a reply to message #641843] Thu, 09 December 2010 04:00 Go to previous messageGo to next message
Artem Tikhomirov is currently offline Artem TikhomirovFriend
Messages: 222
Registered: July 2009
Senior Member
> I don't know any simpler/shorter solution

I wonder if using custom GEF request (a tool that sends alternatives to regular REQ_CONNECTION_START/REQ_CONNECTION_END) and dedicated EditPolicy to handle this request would be better solution. At least is seems to be cleaner and less obtrusive to the templates and diagram code (e.g. no other policies/editparts need to be replaced, new EditPolicy can be declaratively and selectively added to gmfgen::GenNode).
Re: ER like connections [message #644502 is a reply to message #644010] Sun, 12 December 2010 11:50 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi Artem,

do you have an example or a bit more detailed explanation as starting point?

Thanks in advance,

Ralph
Re: ER like connections [message #1021335 is a reply to message #642622] Tue, 19 March 2013 22:12 Go to previous messageGo to next message
Simon Zutterman is currently offline Simon ZuttermanFriend
Messages: 28
Registered: October 2012
Junior Member
Hi Michael,

I'm a beginner with GMF and creating an editor for which i could very much use the node-in-the-middle method. i am trying to analyse it through the files on the SVN repository, but i can't seem to open a diagram instance of the files. When I right-click the com.borlander.samples.inthemiddle.diagram and select 'run as, eclipse application', and want to create a new example in the eclipse runtime, the inthemiddle diagram is not to be found in my examples..

can you help me with this?

Re: ER like connections [message #1021341 is a reply to message #1021335] Tue, 19 March 2013 22:31 Go to previous messageGo to next message
Michael Golubev is currently offline Michael GolubevFriend
Messages: 383
Registered: July 2009
Senior Member
Hello,

Just checked out it from that old SVN and it works fine for me out of the box in Juno SR2.

Have you checked .log file in runtime ws/.metadata? If there are problems with dependencies in your environment, it should be logged there.

Regards,
Michael

[Updated on: Tue, 19 March 2013 22:32]

Report message to a moderator

Re: ER like connections [message #1021464 is a reply to message #1021341] Wed, 20 March 2013 06:37 Go to previous messageGo to next message
Simon Zutterman is currently offline Simon ZuttermanFriend
Messages: 28
Registered: October 2012
Junior Member
thanks for the quick respons.

I don't know how to find the log file and metadata, but in the runtime error log i get the followingg message:

missing required bundle org.eclipse.gmf.tooling.runtime_0.0.0.

any help on how to resolve this?
  • Attachment: error log.PNG
    (Size: 50.93KB, Downloaded 257 times)
Re: ER like connections [message #1021471 is a reply to message #1021464] Wed, 20 March 2013 07:06 Go to previous message
Simon Zutterman is currently offline Simon ZuttermanFriend
Messages: 28
Registered: October 2012
Junior Member
problem solved by installing gmf tooling runtime extensions!
Previous Topic:GMF Filter Node
Next Topic:custom filters to reduce overload information
Goto Forum:
  


Current Time: Tue Mar 19 11:31:22 GMT 2024

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

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

Back to the top