Home » Modeling » GMF (Graphical Modeling Framework) » ER like connections
ER like connections [message #641843] |
Sun, 28 November 2010 12:18  |
Eclipse User |
|
|
|
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 #642622 is a reply to message #642562] |
Wed, 01 December 2010 22:05   |
Eclipse User |
|
|
|
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 .
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 #643782 is a reply to message #643662] |
Wed, 08 December 2010 04:40   |
Eclipse User |
|
|
|
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
|
|
| | | | | | |
Goto Forum:
Current Time: Sun Jul 06 01:45:52 EDT 2025
Powered by FUDForum. Page generated in 0.20760 seconds
|
Back to the top
|