Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Affixed parent side
Affixed parent side [message #237031] Tue, 21 July 2009 04:40 Go to next message
Gary is currently offline Gary
Messages: 125
Registered: July 2009
Senior Member
I have been unable to find much info about Affixed Parent Side, but I
think that the use of it may be the solution to one of my problems.
Note: I have tried using this attribute, but what ever I do it makes all
my nodes go to the top left corner.

The problem:
I have a node(A) that contains child(B),
I want the child(B) to be attached to the edge of its parent (node A) like
a port.

The Question:
Will Affixed Parent Side solve my problem?
If yes how?
If no, then what is it used for?

(any info would be appreciated)

Thanks in advance,
Gary
Re: Affixed parent side [message #237230 is a reply to message #237031] Wed, 22 July 2009 08:56 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios Kolovos
Messages: 1776
Registered: July 2009
Senior Member
Hi Gary,

This may be of assistance:

http://epsilonlabs.wiki.sourceforge.net/EuGENia+GMF+Affixed+ Nodes

If you don't want to install EuGENia, I'm happy to send you the
generated .gmfgraph, .gmfmap models.

Cheers,
Dimitris

Gary wrote:
> I have been unable to find much info about Affixed Parent Side, but I
> think that the use of it may be the solution to one of my problems.
> Note: I have tried using this attribute, but what ever I do it makes all
> my nodes go to the top left corner.
>
> The problem:
> I have a node(A) that contains child(B),
> I want the child(B) to be attached to the edge of its parent (node A)
> like a port.
>
> The Question:
> Will Affixed Parent Side solve my problem?
> If yes how?
> If no, then what is it used for?
>
> (any info would be appreciated)
>
> Thanks in advance,
> Gary
>
Re: Affixed parent side [message #237271 is a reply to message #237230] Thu, 23 July 2009 04:59 Go to previous messageGo to next message
Gary is currently offline Gary
Messages: 125
Registered: July 2009
Senior Member
Hi Dimitris,
Thanks for the reply, the link you provided demenstrates exactly what I
want to produce, with the port attached to its parent node!

Do you know how I can produce this using the 'affixed parent node' option
in the ***.gmfgraph ?
(I have tried using this option, but it just doesn't work, I think I might
be missing something ..do I need to change the mapping model to get this
to work?)

I would like to produce it without editing the generated code where
possible.

Thanks for your help,
Gary
Re: Affixed parent side [message #237313 is a reply to message #237271] Thu, 23 July 2009 07:56 Go to previous messageGo to next message
Tobias Lingemann is currently offline Tobias Lingemann
Messages: 11
Registered: July 2009
Junior Member
Hi,

it's pretty simple.

Step0:
In your ecore model the parent node should have a containment reference
for your ports, as they are child nodes of the parent node.

Step1:
In your *.gmfgraph you define a node and figure for your port like you do
with every node. With one little difference: You set the option affixed
parent side in the node of your port. With this option you set the default
side, on which side of the parent node the port will be added. But the
generated code doesn't prevent the user to move the port at any side of
the parent node. You have to modify your source code for that.

Step2:
In your *.gmfmap go to the parent node mapping and a child reference for
your port. The compartment option can (maybe even has to???) left empty.
Just enter the contaiment feature of your model and the referenced child
node mapping (your port).

Best regards,
Tobias



Gary wrote:

> Hi Dimitris,
> Thanks for the reply, the link you provided demenstrates exactly what I
> want to produce, with the port attached to its parent node!

> Do you know how I can produce this using the 'affixed parent node' option
> in the ***.gmfgraph ?
> (I have tried using this option, but it just doesn't work, I think I might
> be missing something ..do I need to change the mapping model to get this
> to work?)

> I would like to produce it without editing the generated code where
> possible.

> Thanks for your help,
> Gary
Re: Affixed parent side [message #237319 is a reply to message #237031] Thu, 23 July 2009 07:57 Go to previous messageGo to next message
Peter Lang is currently offline Peter Lang
Messages: 153
Registered: July 2009
Senior Member
> The problem:
> I have a node(A) that contains child(B),
> I want the child(B) to be attached to the edge of its parent (node A) like
> a port.

> The Question:
> Will Affixed Parent Side solve my problem?
Yes :)

> If yes how?
In gmfmap:
* Under your Node Mapping for "A", add a "Child Reference"
** Set "Children Feature" and "Containment Feature" to your child of type B
* Add a "Node Mapping" under the new "Children Feature"
** Set "Element" to "B"
** Set "Diagram Node" and "Tool" as you would do for a usual node

In gmfgraph:
Set "Affixed Parent Side" of Node (B) to anything but NONE.

Regenerate and enjoy, hope that helps.
Re: Affixed parent side [message #237330 is a reply to message #237313] Thu, 23 July 2009 09:12 Go to previous messageGo to next message
Gary is currently offline Gary
Messages: 125
Registered: July 2009
Senior Member
Thanks for your responce,
The method you mentioned is exactly what I tried but I get an error, I've
just tried again to be sure and I still get the error.

Error:
The problem is if the affixed parent side is selected for any node, all
nodes added to the diagram go to the top left corner (they also lose all
their content).
But I don't get any kind of error message, so I don't realy know whats
happening!

Any ideas?

Thanks again,
Gary
Re: Affixed parent side [message #237348 is a reply to message #237330] Fri, 24 July 2009 03:03 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander Shatalin
Messages: 2928
Registered: July 2009
Senior Member
Hello Gary,

Is there eny exceptions in a .log?

-----------------
Alex Shatalin
Re: Affixed parent side [message #237380 is a reply to message #237330] Fri, 24 July 2009 03:34 Go to previous messageGo to next message
Tobias Lingemann is currently offline Tobias Lingemann
Messages: 11
Registered: July 2009
Junior Member
I'm not sure if I understand you correctly.
You set the affixed parent side option only for the nodes, that represent
your port. Not for the nodes that represent your parent node and
definitely not for any node.
After adding the child reference you should be able to add a port to the
parent node and only to the parent node you have added a child refernece
to.

Best regards,
Tobias


Gary wrote:

> Thanks for your responce,
> The method you mentioned is exactly what I tried but I get an error, I've
> just tried again to be sure and I still get the error.

> Error:
> The problem is if the affixed parent side is selected for any node, all
> nodes added to the diagram go to the top left corner (they also lose all
> their content).
> But I don't get any kind of error message, so I don't realy know whats
> happening!

> Any ideas?

> Thanks again,
> Gary
Re: Affixed parent side [message #237392 is a reply to message #237319] Fri, 24 July 2009 04:59 Go to previous messageGo to next message
Daniel is currently offline Daniel
Messages: 19
Registered: July 2009
Junior Member
Hi Everybody,

This method works but the problem that I have is that when I select NORTH
or another one, it always goes on WEST.

Is it the same for you? is it a bug?

thanks
Re: Affixed parent side [message #237398 is a reply to message #237330] Fri, 24 July 2009 05:08 Go to previous messageGo to next message
Gary is currently offline Gary
Messages: 125
Registered: July 2009
Senior Member
Hi all,
Thanks for your help/input.

I have spent some time trying to work out why I was getting this error and
have finaly discovered the problem!

The Affixed parent side doesn't work if your parent has XYlayout, I think
this could possibly be a bug, but I haven't added a bug report thing
because I don't know how to do that!

Anyway I can work around this for now but if you know of any solution to
this I may need it at a later stage, plus it may be useful for others!

Thanks again,
Gary
Re: Affixed parent side [message #237409 is a reply to message #237392] Fri, 24 July 2009 06:08 Go to previous messageGo to next message
Peter Lang is currently offline Peter Lang
Messages: 153
Registered: July 2009
Senior Member
> This method works but the problem that I have is that when I select NORTH
> or another one, it always goes on WEST.

> Is it the same for you? is it a bug?

In my example, it works with NORTH, EAST, SOUTH and WEST.
Note that all other options except for NONE are considered as NORTH.

If it doesn't work for you, I would suggest to start with a new model,
changing nothing except for the required modifications described in my
last post.

Once you get this example to work, you can continue by changing layouts
(and anything else) in order to find out why it does not work in your
model right now.

Regards, Peter
Re: Affixed parent side [message #237415 is a reply to message #237409] Fri, 24 July 2009 07:51 Go to previous messageGo to next message
Daniel is currently offline Daniel
Messages: 19
Registered: July 2009
Junior Member
Unfortunately, it still doesn't work.

I tried with a minimal model as you said and the child is still created on
the West.

When I look in the childEditPart I see in the method

/**
* @generated
*/
protected NodeFigure createNodePlate() {
DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(40, 40);

//FIXME: workaround for #154536
result.getBounds().setSize(result.getPreferredSize());
return result;
}


Do you think it's a bug?

thanks for your help
Re: Affixed parent side [message #237505 is a reply to message #237415] Mon, 27 July 2009 03:07 Go to previous messageGo to next message
Peter Lang is currently offline Peter Lang
Messages: 153
Registered: July 2009
Senior Member
Your createNodePlate-method is the same as mine, should be ok.

What version of GMF are you using?

Please check the method addFixedChild in your parent-EditPart.

It should set your orientation for locator:
BorderItemLocator locator = new BorderItemLocator(getMainFigure(),
PositionConstants.SOUTH);

Regards, Peter
Re: Affixed parent side [message #237539 is a reply to message #237505] Mon, 27 July 2009 04:29 Go to previous messageGo to next message
Daniel is currently offline Daniel
Messages: 19
Registered: July 2009
Junior Member
Thanks for the time spent with me,

I've downloaded the lastest version of gmf on eclipse website.

There is no method "addFixedChild" in the parent EditPart.

I think I really missed something :s

(How do you know the version og GMF? is it in
Help > About Eclipse > Installation Details ?)

Regards
Re: Affixed parent side [message #237552 is a reply to message #237539] Mon, 27 July 2009 07:59 Go to previous messageGo to next message
Peter Lang is currently offline Peter Lang
Messages: 153
Registered: July 2009
Senior Member
Hi,

I was about to write a tutorial for you, when I encountered the same
problem that you are facing ;-)
The tutorial is at the end of this post, maybe it will help others.

I do not know exactly why it does not work, but the problem seems to be in

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.gmf/plu gins/org.eclipse.gmf.codegen/templates/xpt/diagram/editparts /NodeEditPart.xpt?root=Modeling_Project&view=co
where
«IF hasFixedChildren()-»
is false.

My workaround for now is to add a "Feature Label Mapping" to the
parent-node (A). With this, AEditPart is generated correct and you get
addFixedChild as described.

I am just trying without really knowing what happens, but I'm quite sure
that this is a bug.

Let's have some closer look and then file a bugzilla, if there's not
already one.

Regards, Peter


> (How do you know the version og GMF? is it in
> Help > About Eclipse > Installation Details ?)
Yes, the Version of "Graphical Modeling Framework SDK" should be your
version.


--------
So, here's what I do (using xsd-file as definition):

# Create new project (Empty EMF Project)

# Under model:
Create bordernode.xsd:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xsd:schema
targetNamespace="http://www.example.com/bordernode"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:bn="http://www.example.com/bordernode
elementFormDefault="unqualified">
<xsd:complexType name="BorderNode">
<xsd:sequence>
<xsd:element name="a" type="bn:A" maxOccurs="unbounded"
minOccurs="0"></xsd:element>
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="A">
<xsd:sequence>
<xsd:element name="b" type="bn:B" maxOccurs="unbounded"
minOccurs="0">
</xsd:element>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string"></xsd:attribute>
</xsd:complexType>

<xsd:complexType name="B">
<xsd:attribute name="name" type="xsd:string"></xsd:attribute>
</xsd:complexType>
</xsd:schema>


# Under model:
New "EMF Generator Model"
File name: bordernode.genmodel
Model Importers: XML Schema
Select bordernode.xsd (Browse Workspace..."
Finish

# Open GMF Dashboard (Window -> Show View -> Other... -> General/GMF
Dashboard

In Dashboard:
# Select "Domain Model" -> bordernode.ecore

# Select "Domain Gen Model" -> bordernode.genmodel

# Derive "Graphical Def Model":
File name as suggested
Diagram Element: BorderNode
Leave as selected (A,B as nodes, A.name, B.name as attributes)

# Derive "Tooling Def Model":
File name as suggested
Diagram Element: BorderNode
Leave as selected (A,B as nodes)

# Combine:
File name as suggested
Class: BorderNode
Diagram Palette as suggested
Diagram Canvas as suggested
Remove B from Links

# In bordernode.gmfmap:
As already described
* Under your Node Mapping for "A", add a "Child Reference"
** Set "Children Feature" and "Containment Feature" to your child of type B
* Add a "Node Mapping" under the new "Children Feature"
** Set "Element" to "B"
** Set "Diagram Node" and "Tool" as you would do for a usual node

!!!Workaround!!!
* Add Feature Label Mapping to Node Mapping for "A"

# In bordernode.gmfgraph:
Set "Affixed Parent Side" of Node (B) to anything but NONE.
HINT: Do not open *.gmfgraph directly, always edit through *.gmfmap to
allow synchronization

# Generate bordernode.gmfgen

# Generate all sources

# Run
Re: Affixed parent side [message #237580 is a reply to message #237552] Mon, 27 July 2009 09:09 Go to previous messageGo to next message
Peter Lang is currently offline Peter Lang
Messages: 153
Registered: July 2009
Senior Member
Sorry, the previous link to NodeEditPart.xpt pointed to an older version.

The new version seems to have the same bug though, so I filed a bugzilla
for this:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=284733
Re: Affixed parent side [message #237598 is a reply to message #237580] Mon, 27 July 2009 09:41 Go to previous messageGo to next message
Daniel is currently offline Daniel
Messages: 19
Registered: July 2009
Junior Member
thanks for your tutorial!

it is very nice and quick.

Unfortunately I think it's a bug. However, When I choose to put and
external label, I can choose a kind of affixed parent side.

However when you choose NORTH or other in the .gmfmap, in the code there
is always "SOUTH", but you can change it in the ParentEditPart and it
works.

I think we can make the code ourself to put the children wherever we want
like the external label.

What do you think of it?

Regards
Re: Affixed parent side [message #237640 is a reply to message #237598] Mon, 27 July 2009 10:56 Go to previous message
Peter Lang is currently offline Peter Lang
Messages: 153
Registered: July 2009
Senior Member
Hi,

As I said, I also think that this is a bug, so I already filed a bugzilla
for it:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=284733

External labels are a different issue, they are hardcoded to be SOUTH and
do not consider "Affixed parent side" property.

I think there should be no problem with changing generated source manually
but you might want to start a different newsgroup thread to find out if
there is a way to configure the position.

Regards, Peter
Previous Topic:Fill/Font/Line styles added on View creation
Next Topic:save as. How can I make a copy from the model and diagram file?
Goto Forum:
  


Current Time: Thu Aug 28 19:23:20 EDT 2014

Powered by FUDForum. Page generated in 0.02656 seconds